From patchwork Thu Aug 24 03:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363442 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 00D06C3DA6F for ; Thu, 24 Aug 2023 03:45:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97C9628007F; Wed, 23 Aug 2023 23:45:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92D0C8E0011; Wed, 23 Aug 2023 23:45:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81C0B28007F; Wed, 23 Aug 2023 23:45:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7473D8E0011 for ; Wed, 23 Aug 2023 23:45:11 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 56365B1A57 for ; Thu, 24 Aug 2023 03:45:11 +0000 (UTC) X-FDA: 81157607622.11.DA11DB5 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf12.hostedemail.com (Postfix) with ESMTP id 8C57F40003 for ; Thu, 24 Aug 2023 03:45:09 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=IiEm4cdY; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf12.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848709; a=rsa-sha256; cv=none; b=P4CrhdBRHYObha+ePGJdFP3N4UxamKpnQkkj2WoX0yB+0rtDt+DZA0Rz8njdFtzuN4Cwgd iTV8coFzkhqEfQRKEH6m156l006hY0yfI7Ysna7wojwPP6YKXDxdPrMcw6ZwvYeSnmUbxg PnANaKf7R06fv4CzWK9Gjq/pbFRqjWo= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=IiEm4cdY; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf12.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692848709; 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=AX/b0fq/KloogCdhJk2fCq89e0mYWJitbZSZYRv9394=; b=XR5U//aC39t0m5AYV/CbOZoi5813hcMnToy/sGCh2iLAT3BeGgtMCgfYicniecno4CsrZQ hDz/pvp0KhWSkHAovA6hJWfCzVKNvR7us3iPsxpkehlnSmxbefH148/3cz0jg8u7YIxA0X l+PyvHfyQsrXHGUfLXLacD1RafF66vA= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-68a32506e90so1062220b3a.1 for ; Wed, 23 Aug 2023 20:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848708; x=1693453508; 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=AX/b0fq/KloogCdhJk2fCq89e0mYWJitbZSZYRv9394=; b=IiEm4cdYuBivqLOCo7pCSLosVlnAGQWoBGclNzHv7BpQ3OzgSJ6UP4ciJP7iR8S74O XmYza0RDh78lZAcwAaqw2to1tsj0TaujHZHQwmxkxk/F3bIzysr4eF5XZvIJl9wqFyyf O6ysyVR9xv1/6F1REkzOzqeOlgu+28GZxr7XpPwdj5lxv9K6Yjv5vyAD6My5Zz/yS1l2 1ON40NeUd05shQKFTyeSlPIlli77/svXJDTpzHCfBpTOxANAmdMspbGRHm6IDisLwvvI YS0OaQDIkS/HVg8tNe5hal/7Lbr++jwwGavZV15cYsWQbTbOnv1CzLzV/bnEh7jVvMln 1gow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848708; x=1693453508; 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=AX/b0fq/KloogCdhJk2fCq89e0mYWJitbZSZYRv9394=; b=gDgm1Es4brmfiEKF7gdOGCqyMMPyDQxxwJEeyFBDqm4yyIfLgKwkCZ1jU56cjk91xa X5u3xlEeuT03daKsWzEPetYNydDCXszoVLnnrHRnmiZEE0vza4eI/QRmNBlEd/5UuBQx STUU6Xjxc2lWJs5yTeBVkhnUbmg7o+XLjMYzmDvCOdDWtgYEAwjTfuz8E2Wx4hH7PXyb 9Uh7BXuXDriVPVFcNiy6aFG3Gjh8J7ghCKxFCySybx1V+7q90Pk05ivtCo+Hu2Ew98P0 Fzhvz0/n0EVQDXuTKa7XYDYr/OGidMB5SiWOlBdVR4+MOhDG+aMeIpCMpr8ERCCsUqaJ 4FKQ== X-Gm-Message-State: AOJu0YzcQp7k1P32TD+UVG2qYlGJOp1j5TFfGP/LDnIGSqpJ9p8meGri GN7P6IVU9p2RGmU7hkAYo03UyQ== X-Google-Smtp-Source: AGHT+IH9o7SMs2SAPemrTlzGr+mXhW0/++sBcfKyWnxJ+hyFE+5KtkGkdBjg/9E4utbduecqtJoPbQ== X-Received: by 2002:a05:6a21:6da5:b0:137:3eba:b81f with SMTP id wl37-20020a056a216da500b001373ebab81fmr18793963pzb.3.1692848708610; Wed, 23 Aug 2023 20:45:08 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id t6-20020a63b246000000b005579f12a238sm10533157pgo.86.2023.08.23.20.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:45:08 -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 v5 09/45] gfs2: dynamically allocate the gfs2-qd shrinker Date: Thu, 24 Aug 2023 11:42:28 +0800 Message-Id: <20230824034304.37411-10-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230824034304.37411-1-zhengqi.arch@bytedance.com> References: <20230824034304.37411-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8C57F40003 X-Stat-Signature: 9etpd9gwmp69hnoipwfqjjfcdhjs7dss X-HE-Tag: 1692848709-521172 X-HE-Meta: U2FsdGVkX1/yhLMZvh3q6gPPMjqE49bOtWUo6mc/JzN//ThCLf1FAGoAkpWa+6qmdm+/L4Rk34B/kvggQiZMZrcBl6SCFzw4Xf2m1RI8efud2WlPOKOL8i4tQpBQGhim/Z9iSW9QZqUzTVeGO4wMQFraaiPUMM4hId7oyF2MQVHfBomgpbLIzkoijIqhLoQk4GZ5HV4QzrdVt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8RlO2UUips4izABESAslsUkfLUiYOor6dZHBALojFL0uvVYXGd2rfL4jOUc9LXcwyh+W3SidndBs0/XY3Fp5zijAugCNT5zZXBgum1YEf8GXRUL7i3OlqL3Uw+thrgAC/wtIOwhAnSg6UuWcaUrqvblxbSfTvpI6rg7ZNG7k8tTV23/qe56ZdyrqJmlIR6ZOM= 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 | 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 632806c5ed67..d1e4d8ab8fa1 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 __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; + gfs2_qd_shrinker->seeks = DEFAULT_SEEKS; + + 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);