From patchwork Mon Sep 11 09:44:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13379063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0098EE7FF4 for ; Mon, 11 Sep 2023 09:46:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F32A6B01A8; Mon, 11 Sep 2023 05:46:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A1D86B01A9; Mon, 11 Sep 2023 05:46:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36A046B01AA; Mon, 11 Sep 2023 05:46:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 258C26B01A8 for ; Mon, 11 Sep 2023 05:46:32 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F0AF780930 for ; Mon, 11 Sep 2023 09:46:31 +0000 (UTC) X-FDA: 81223836582.06.53B9DA9 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf29.hostedemail.com (Postfix) with ESMTP id 2936D120002 for ; Mon, 11 Sep 2023 09:46:29 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=SSqElHnJ; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694425590; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eZxqpi7coMh8ftID9yaYhwXiGQ4pT4wdMxIpYIgs7HE=; b=X5KHKUqny6pTxg6YzeXe1NcaTpq6bgX/f58ryXZO4kCxME9WXFTQdrAlfItLgk674KbVwg TKroyQAYemZL6OmeRCBs82Bky0OqJMLobg0ghpO95MoLBZjxar3GaYX2PvjWUPkN32Iy0N HkaDnVWDQ8pDdlcyR3DYPfxV+rB3ak0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=SSqElHnJ; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425590; a=rsa-sha256; cv=none; b=J+53F3x//yocruzwA7Jaz2LQdL9ft7lnHqClyb51oBcpGVbdPbuFTVaQe7RmoxJGnKXMYd SPUwGvc6FOShxHOadAwF0jeLH9q6ocsZUKTUHsx4jp1b9Z/BBJIAOmiFM+ivTzxsRAy+ER 13dWDq9DB8Nqy9tfOJrF5Xv2/pzJDKo= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1befe39630bso9364625ad.0 for ; Mon, 11 Sep 2023 02:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425589; x=1695030389; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eZxqpi7coMh8ftID9yaYhwXiGQ4pT4wdMxIpYIgs7HE=; b=SSqElHnJng/0giGSiL2cUGSpvmCVaC7CjsotqWi2UUH0E6mCVcgZ9ppRNyZ0QuunFc MPsKVasi5kTxJ3fFjZHfa9wZ/OUfoSG1k7f9S8PR5sVKp5/7kt4ifRmxSN/QC0u+9qIp yuZ1vmi08J7pmYI4CR9RLPYEbnKml2XMtoHRGP/BAEhXyVT5AnEtABd7S2glzmBsZBgg rJjPkAOL9KVYFZ0uJgLffT+nlpErrhYeu5CESAlAa6kKL7Lq+hEfR5ZCi5Q7iJMrR2l7 3mqsO90puIM1NSx3vZxHlyHZkN9yUAmNk5wln9Ia9xPUQOJVw8uFpcGniG3jY4+FBURF Tn2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425589; x=1695030389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eZxqpi7coMh8ftID9yaYhwXiGQ4pT4wdMxIpYIgs7HE=; b=dUUIGHfPnPeGYMiaKWoKDXh9YVQReLM112iB5mZaKJWKXBBa81BrQ2WMtcWBAW7rV1 F6Y1XDretChIi668NH58trsX8hXCbw6bIJ4WsTRbH50vjE6Bq7Xdc3aikNqaEtlbq5Xu oQOhTt3FJMN7P0XMhw9wXqaFK5b8SOoIUTL7ZfNJ6g3zf2TkF35A5LdN35wzSrAru7mV RTgHNLL9no43fXoSGWhfejPYObeB1FsUr3/NfRfV+wxRrQXjmpB+qv42pIUrDn5o1EWD RIUT8UNjJSxajCCf8widVkG6VUCCVmT4AnKPxd7GWvICyZtCjCYl0a601q3GbBpwr3qN 5+zQ== X-Gm-Message-State: AOJu0YzebCFUvKGb7A9TRL/xKQLdPI64U9Ubryb+euxQGrl/kjS2aRMa XiuBUkJc+PIJVF+pw1Q8sbRiLg== X-Google-Smtp-Source: AGHT+IErSLcCsEqsbL+707FM3SjghmcKvBuY/KdVR6v7hA7UKBMg35jal9WCdltKnJHFJ2qaL3tLGg== X-Received: by 2002:a17:902:d645:b0:1c3:c687:478a with SMTP id y5-20020a170902d64500b001c3c687478amr326782plh.2.1694425589143; Mon, 11 Sep 2023 02:46:29 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:46:28 -0700 (PDT) From: Qi Zheng To: 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, muchun.song@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Qi Zheng , Muchun Song , Bob Peterson , Andreas Gruenbacher , cluster-devel@redhat.com Subject: [PATCH v6 09/45] gfs2: dynamically allocate the gfs2-qd shrinker Date: Mon, 11 Sep 2023 17:44:08 +0800 Message-Id: <20230911094444.68966-10-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2936D120002 X-Rspam-User: X-Stat-Signature: dit3py7ysxgs3n3mzqcq8btzokyxdr65 X-Rspamd-Server: rspam01 X-HE-Tag: 1694425589-52548 X-HE-Meta: U2FsdGVkX1+Je9x57CZUvx99avANPhCic8FCfv1XWSr9kYh5RN8rceeN12qJVOWWba8Q1vj8b8V4bMI49CbmKscULld7WNWS1ZVGkfgtqvzG/gm2QXmqlqajTfV+P7CEBzmFeL/KxbpBG39P6/ua1vsh4L/RxhevHY+PvxK1wiUq4Ib82TJnac+xrpl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TKtdL8nGMf386pduCqarrhIrGh8owCbIirZEdSc31Q7AS/NqMxE3qCiTL4yfm+6uxybCybiLsDGJ2pHuXI4bs3iTRPOiAdUtPQM3XDCb+GNVsKA0JyDxgbae38/0DRI2e0Of1ioSDwJZB6/KXAooAI3CKFXUXmRnDdqKNwy9LtThr9Xol1nIcMWkEzh3YgqEApJE7ylvMhhU9EQZ7NUZp89E780A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use new APIs to dynamically allocate the gfs2-qd shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Bob Peterson CC: Andreas Gruenbacher CC: cluster-devel@redhat.com --- fs/gfs2/main.c | 6 +++--- fs/gfs2/quota.c | 25 +++++++++++++++++++------ fs/gfs2/quota.h | 3 ++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 66eb98b690a2..79be0cdc730c 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(gfs2_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 171b2713d2e5..d3d013d1d5ac 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -196,13 +196,26 @@ 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 __init gfs2_qd_shrinker_init(void) +{ + 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; + + shrinker_register(gfs2_qd_shrinker); + return 0; +} + +void gfs2_qd_shrinker_exit(void) +{ + shrinker_free(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..f0d54dcbbc75 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 __init 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);