Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp772908rwb; Wed, 26 Jul 2023 02:37:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlFOti2+j6IwrwY8JF3z/lSOujXLoCdyHB5TGFeGbmxVi31qXo1UhbuQQgHsyAKGTyhEZS+W X-Received: by 2002:a17:902:7792:b0:1b0:6038:2982 with SMTP id o18-20020a170902779200b001b060382982mr1380414pll.41.1690364230894; Wed, 26 Jul 2023 02:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690364230; cv=none; d=google.com; s=arc-20160816; b=AOjFydp7dS3W9HGpLVIzJSImmrqQ9nkSHBLnQkQbZ5gguv4VhCf4uxRuPAQudMlEcB 3W44RFuW65jAnwxyUUj5d8r4tsFBLpWgns1JbIXqIQE+btCc6zfrlayKZQbwbfweGrFw FdGPSoSjc0cISI/KEdJjLytO7f50I+H9yMCaS0YXLe1eXdIYg25wyBeGxGymYWQb8LUr 5zYEqRFzN6CGRCcGXwJiTHGf3Fbr4EhF2XrbOMFZmiR7vG7VvyNl5N0fM6nlIvMCXb9D 2zrIxhYur5A5uSS6QmWoE5b01PIJ5VcRwVF+CWFP8fupOw6dXDxXRCXA6cwyP4sTrvfC vg3w== 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:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xHFf+qIXuXcHU2hnpeM9isQldhnSqSauyHf1oBu4R8I=; fh=1tw537HxJj8QfRGQ31nxiSonTz8q3rJnaObM9GVPiPs=; b=QuW6eNFk+goD5NGVshB3jDWx3DLetxEYepIQwbtB7IO1frVm0f4x0Ry/zkplyTuD8O RVApcuuHGStQEsg9dHXRQOJyKxlBX0/twoT5dkSAaeA9DSA2U+VbQ9YRr6VgKXrb2s1U 9MaxCxGM0DXZw9oXvIVrElJkjXH7N4OuxH3h3srNRlNR3FSkfExY3CWLjUmLnsrNR15q HJSoXexlcYy5oeATmXSUMflU3yoJM4YAWzRSYuwsDfklck6ib3X7fUnaAGD0v/02zuNW uPET4ew8xPAiC4LodRBXxOmhrr7guis5SQDpzLpOLaIchOduLQ4dkAGBfK3ABuU1HdsK akwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jAMndxc3; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a170902e80900b001bb1504b696si14009623plg.4.2023.07.26.02.36.58; Wed, 26 Jul 2023 02:37:10 -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=@bytedance.com header.s=google header.b=jAMndxc3; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233185AbjGZJY7 (ORCPT + 99 others); Wed, 26 Jul 2023 05:24:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233080AbjGZJY2 (ORCPT ); Wed, 26 Jul 2023 05:24:28 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6341BD9 for ; Wed, 26 Jul 2023 02:22:15 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-66d6a9851f3so1487683b3a.0 for ; Wed, 26 Jul 2023 02:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690363335; x=1690968135; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xHFf+qIXuXcHU2hnpeM9isQldhnSqSauyHf1oBu4R8I=; b=jAMndxc3vAfZ9MlugwiN2m1td4+ENgo1ZcEkULNu4w0l2e+7SjL15Aj8xsnH/hg6mq Yuh7Pj+WIpy+9FKbmqcmIZPowwXwCsZ/HE/uYPa/USpf5RWRvsmKXdX1EOhGqDHtCRhA 5Tx4ycmmPjyUjagwQ6weN00EPkG2yYEGVkFAeT+5NL38WWOxpIAWxDe7x+TtdzGSmFXw AaN6OIhFdWcuFQV9AajQEHTHNR/HQhAWIjBkgsz+1GmBQBDd2nNKfKbDgsLcpETIdF18 CdbQtqtDxhcETBnzscklNfC8QDSVXvKpexDlKf4G6IIrjU6vkXpbe5y1T2yEBA/OqHN2 vBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690363335; x=1690968135; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xHFf+qIXuXcHU2hnpeM9isQldhnSqSauyHf1oBu4R8I=; b=KyliafwFlMb7gkb6D7GeLbrOqwC60isBmVxLnnBzs9MjFzLnz2P+mGWEu0p5UoBtuu 6Ts76LpKl0yGF06iMr76rGtIYxDmmYsbUmQi19tMVbL+chdLMWi/N1e+85y9J5LaKPuB ZSeWCj2n5MvQ3JJ9CpwuZWqHI0FTiQ6lqaGAuRZc0McyRVn0/GXQ3/qRPjoCSE6PwHfW 1CZYhHh+L5OQNcSHco0h0MwirkE+o9fGNJcvMYAHveaRjt6ZPDK0ICVtrVjRjjIeHw56 1Uxqxyav4lstx3gt1Ne+1AQAUWI/p51xbzOkbLI4dqHRgH/TraDDu2HKUjxzZVAkiQYc G/YQ== X-Gm-Message-State: ABy/qLb9sSIrs6o5YgNEXYob/FwGt4+dmbVQGk/XgiGYbjGCdPIJnROm MhHQblz4LY0J+Gl630SSRCtl/Q== X-Received: by 2002:a05:6a20:729a:b0:100:b92b:e8be with SMTP id o26-20020a056a20729a00b00100b92be8bemr1779967pzk.2.1690363335131; Wed, 26 Jul 2023 02:22:15 -0700 (PDT) Received: from [10.70.252.135] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id k11-20020aa790cb000000b006827c26f147sm10955045pfk.138.2023.07.26.02.22.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 02:22:14 -0700 (PDT) Message-ID: Date: Wed, 26 Jul 2023 17:22:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2 11/47] gfs2: dynamically allocate the gfs2-qd shrinker Content-Language: en-US To: Muchun Song 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> From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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/26 14:49, Muchun Song wrote: > > > 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. OK, Will do. > >> +{ >> +    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); >