Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp651074rwb; Wed, 26 Jul 2023 00:02:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGfWspLI5mXyi8pVhAYiQbS0dGvp/BOc5LTna988FEl5ku748+a3NABQkBEM98/tR4KtR7u X-Received: by 2002:a05:6512:3690:b0:4fe:cc0:348 with SMTP id d16-20020a056512369000b004fe0cc00348mr639916lfs.66.1690354971443; Wed, 26 Jul 2023 00:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690354971; cv=none; d=google.com; s=arc-20160816; b=RoSL8CEB13NZ8H2TwfteAbo/5PPkQLAq3hUWquek4nKaLuee0+FdV09I8EfjLQfhsh Zdig5b1Klbrvr98KtWxHX+WI1xnjQOaf+ZqyJT1iX1wtvG/QnQxZgRCq8hkck8kU6EKw WDrISH2AuSek695cclvMltfXI1prg+tJ3cyEahMR/4qxh7cIBr2p12Xy/oeHlzuD47J3 LlJP6iErLh6qopFMSxd8ukINrl0CcLLgi1qFUdWYc2haD2zRLxvYlG/MB0egxSxkSSb1 zDUz35ABph/c/ffvPIuM2snr9XdpwahBdulJ/KfXcg62dcPmcJXKXI3QBRGk1lfKI3nx qdJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:mime-version:date:dkim-signature :message-id; bh=07kRInGgcVMiksfMsun8p4HGvWms170mUSINrsZDIPU=; fh=2aXCQdnPCRGWbb3+3TWBb4ivLG2Pbs4VxrYTn6yMgTk=; b=lPnrE23m3c9hvREBiD88VafElIBC3WOwdaD8/mSkTnKFtJUZVBWV62iKIyK5DN79Hj B2a6K3ADNBDz+xiTSIjmwajGtfWLqrm3AFnuGTig+oUq8baHKyRCp3THo6jTs1xDxpcm DRkuZ6+USXsUciJRuMzhrjGToCgRCeVZ1uRZiRiSASXT5lOlS8FDf/YUIJ39v4HyYX9/ bQoD8Zo9dcBihKpSerrwWowSNQPCtRyG6iXsfpHtVLP4j/KfNi98LeYzGYOg5qHGynLf 2/4W4SUQy16moU0H2GBF2mGSxELmyqOogKvEQQG0vWcH5UC6QPeM4z847hkOpu96l3oa tg1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SItOX2s1; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020aa7c743000000b0052275937198si479754eds.628.2023.07.26.00.02.26; Wed, 26 Jul 2023 00:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SItOX2s1; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbjGZGtW (ORCPT + 99 others); Wed, 26 Jul 2023 02:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjGZGtV (ORCPT ); Wed, 26 Jul 2023 02:49:21 -0400 Received: from out-33.mta0.migadu.com (out-33.mta0.migadu.com [91.218.175.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F741BE4 for ; Tue, 25 Jul 2023 23:49:20 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690354158; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=07kRInGgcVMiksfMsun8p4HGvWms170mUSINrsZDIPU=; b=SItOX2s1O2xRbklfqsU1E20kPvGPKi6lNjfeuPsz787gwDukUtasKQC+RRJ78xAQZyjij6 0JlhE8ny7YCW/WIa1zfjcf/R7sJjT11NiI0YLFw4BmC6xi+4P258FcCDYig5b0NazpkEtw pJl7w1nj4tDpMcmLDY8eVxmHbXISOTw= Date: Wed, 26 Jul 2023 14:49:05 +0800 MIME-Version: 1.0 Subject: Re: [PATCH v2 11/47] gfs2: dynamically allocate the gfs2-qd shrinker To: Qi Zheng Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mtd@lists.infradead.org, rcu@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-12-zhengqi.arch@bytedance.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20230724094354.90817-12-zhengqi.arch@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 2023/7/24 17:43, Qi Zheng wrote: > Use new APIs to dynamically allocate the gfs2-qd shrinker. > > Signed-off-by: Qi Zheng > --- > fs/gfs2/main.c | 6 +++--- > fs/gfs2/quota.c | 26 ++++++++++++++++++++------ > fs/gfs2/quota.h | 3 ++- > 3 files changed, 25 insertions(+), 10 deletions(-) > > diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c > index afcb32854f14..e47b1cc79f59 100644 > --- a/fs/gfs2/main.c > +++ b/fs/gfs2/main.c > @@ -147,7 +147,7 @@ static int __init init_gfs2_fs(void) > if (!gfs2_trans_cachep) > goto fail_cachep8; > > - error = register_shrinker(&gfs2_qd_shrinker, "gfs2-qd"); > + error = gfs2_qd_shrinker_init(); > if (error) > goto fail_shrinker; > > @@ -196,7 +196,7 @@ static int __init init_gfs2_fs(void) > fail_wq2: > destroy_workqueue(gfs_recovery_wq); > fail_wq1: > - unregister_shrinker(&gfs2_qd_shrinker); > + gfs2_qd_shrinker_exit(); > fail_shrinker: > kmem_cache_destroy(gfs2_trans_cachep); > fail_cachep8: > @@ -229,7 +229,7 @@ static int __init init_gfs2_fs(void) > > static void __exit exit_gfs2_fs(void) > { > - unregister_shrinker(&gfs2_qd_shrinker); > + gfs2_qd_shrinker_exit(); > gfs2_glock_exit(); > gfs2_unregister_debugfs(); > unregister_filesystem(&gfs2_fs_type); > diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c > index 704192b73605..bc9883cea847 100644 > --- a/fs/gfs2/quota.c > +++ b/fs/gfs2/quota.c > @@ -186,13 +186,27 @@ static unsigned long gfs2_qd_shrink_count(struct shrinker *shrink, > return vfs_pressure_ratio(list_lru_shrink_count(&gfs2_qd_lru, sc)); > } > > -struct shrinker gfs2_qd_shrinker = { > - .count_objects = gfs2_qd_shrink_count, > - .scan_objects = gfs2_qd_shrink_scan, > - .seeks = DEFAULT_SEEKS, > - .flags = SHRINKER_NUMA_AWARE, > -}; > +static struct shrinker *gfs2_qd_shrinker; > + > +int gfs2_qd_shrinker_init(void) It's better to declare this as __init. > +{ > + gfs2_qd_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE, "gfs2-qd"); > + if (!gfs2_qd_shrinker) > + return -ENOMEM; > + > + gfs2_qd_shrinker->count_objects = gfs2_qd_shrink_count; > + gfs2_qd_shrinker->scan_objects = gfs2_qd_shrink_scan; > + gfs2_qd_shrinker->seeks = DEFAULT_SEEKS; > + > + shrinker_register(gfs2_qd_shrinker); > > + return 0; > +} > + > +void gfs2_qd_shrinker_exit(void) > +{ > + shrinker_unregister(gfs2_qd_shrinker); > +} > > static u64 qd2index(struct gfs2_quota_data *qd) > { > diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h > index 21ada332d555..f9cb863373f7 100644 > --- a/fs/gfs2/quota.h > +++ b/fs/gfs2/quota.h > @@ -59,7 +59,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip, > } > > extern const struct quotactl_ops gfs2_quotactl_ops; > -extern struct shrinker gfs2_qd_shrinker; > +int gfs2_qd_shrinker_init(void); > +void gfs2_qd_shrinker_exit(void); > extern struct list_lru gfs2_qd_lru; > extern void __init gfs2_quota_hash_init(void); >