Message ID | 20230724094354.90817-11-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 80175C001DF for <linux-mm@archiver.kernel.org>; Mon, 24 Jul 2023 09:47:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21B5E280002; Mon, 24 Jul 2023 05:47:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CB3F900004; Mon, 24 Jul 2023 05:47:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09436280002; Mon, 24 Jul 2023 05:47:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EECA1900004 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 05:47:09 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C79C7B1FF0 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 09:47:09 +0000 (UTC) X-FDA: 81046026978.20.4952E0E Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf28.hostedemail.com (Postfix) with ESMTP id 0BD41C0006 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 09:47:07 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Mkbkj7G5; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 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=1690192028; a=rsa-sha256; cv=none; b=omEXA3j0AW5oLHKrjLMqpElD084Sg8ZJwc5LYQRFJzIg+yToUX0eUfmfxLR7Ciq77Mm0Gt gJ83YeBCFRUiM3ndak7xG9iydmr8MFfQJ/3WtfJdbY5mhTYfDP19ggCDJTwNtF5FGdFdtn ZYxT2b0v3eFk09t3V6A+R23NkY1iHhU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Mkbkj7G5; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 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=1690192028; 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=cYIc2pFR4p2fEyppjqJhI12Ags43zx4+1Vguh7yPn/A=; b=8SLcmcrKjKDt2Lh+3p+GdKfnstyq+Z+vyeMomXaa9W2iITtOAEJTU35slgywuxspSPRTlx b/sCdYkv2n/XPKr2EU4ZGqL5sl2HF77HIVxlRESRaw3gKk5uQU5qXH++Pt6HlV021AaI6y YrfGpOUh53zX2/IRm8RqeDt32rmQ3fs= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1bb91c20602so2227315ad.0 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 02:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690192027; x=1690796827; 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=cYIc2pFR4p2fEyppjqJhI12Ags43zx4+1Vguh7yPn/A=; b=Mkbkj7G5CQEOG8iOHz5MrSjilpa0Roglbh/CftNIU9Jg3xNX1k/Xj43vnR/S/54ttk C3FfMc3SnotTmowd/+id3GM38yUMYBJBhTZIBUulrrZgzYrxT+SQHGW3axYXz1Mzi2fV AsX/jIuEEGTsEz+JOjVZRdbKq3nZcbngqtBBtuQhz8//b37rxmcNc4kjft3yYQbvP1Zj 84eZDPKog/+vrWIKUYa0yatWxoPJwzUv5rccQj+Dyx2lWBxO8FM5qLWfEajMcNN5ZG2/ nBaypiLs1PufNQuHjnIpPNYd5QiB7rev3NHLgSVLNHqyhO1fbeGyfmflk+kru7Y0DPcw GDkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690192027; x=1690796827; 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=cYIc2pFR4p2fEyppjqJhI12Ags43zx4+1Vguh7yPn/A=; b=geE166ON9eT2Yl1f2kex8wVpYQgEFclwbJwEOMYqPDysF7YbahXIDqTnnT4sbClWPF vkeQWeFYAfVz8hHSe2wY68gsExtmbkmlrbcAAb2X2iOYvlGXmUkcYnhieHAOkisvayJ5 a+Dd4JVFC5sVgASj++7EwM5cJMxFgio9CRCObOfkyPeg+h68upIoXClvWtyPbQvGHZ65 JZDvwopPbnzWoZepOQvRu2dcIwVA9xOa0dLVLrYgW7mTA3/KSwIn1ZzLlgMNOkDAKpWE AevTxsIWa7D+6j367lMLGYh7WrvCd4Kiluu9pOL/ZYcMgRqjRH7f8YHWXvTi0/3qMo+4 dLjQ== X-Gm-Message-State: ABy/qLY+OI1Srn/kKHJ4QafeDLCyFSJg/BRU0eWtYyrt8rsVcA0mAi6Q dJv2pin9R0757FvUSg3UdH+skw== X-Google-Smtp-Source: APBJJlE71N8j7jMrL1FzeS7v4yJrry2TgN0JWUZm9wk55uK2Ve/eQ/bXmY0X5mXvJcfiEdGHzkgvbw== X-Received: by 2002:a17:902:ec8b:b0:1b3:d8ac:8db3 with SMTP id x11-20020a170902ec8b00b001b3d8ac8db3mr12337602plg.6.1690192026938; Mon, 24 Jul 2023 02:47:06 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001bb20380bf2sm8467233pld.13.2023.07.24.02.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:47:06 -0700 (PDT) From: Qi Zheng <zhengqi.arch@bytedance.com> 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, 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, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH v2 10/47] gfs2: dynamically allocate the gfs2-glock shrinker Date: Mon, 24 Jul 2023 17:43:17 +0800 Message-Id: <20230724094354.90817-11-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230724094354.90817-1-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0BD41C0006 X-Stat-Signature: 843uedgp8buwxz34hyywri4cfo5byphj X-Rspam-User: X-HE-Tag: 1690192027-954879 X-HE-Meta: U2FsdGVkX1/FDNRDveRV/dS2PnkLrCn/Z2d2UiDOnsxwkK2vuxBAXuGKCAw9YJDNJRHKbAzGVAt0U4MdIT0xIDqnjaiDFzW9memK7Mkzp/6dERBFRgqy2pzOHnx5XakrdJCNxgHPygSNdIOK3L3o1V+RQcb25x0fO3KxdmAJF8XKJBmXG1Jk1Ocau5TOEpkGlFz8LMttajxXnf9patfwxyjHc+H9kUgORffL8omcJTpqKcZu3pJD/Ge7SXch2R8T3qZyOmwOSq1iXwyxb9pHhvuPfnBXRkm3PNgq93v8HiY7CP3rPKXmwYKzUun14dNiMYlEhp21ggMtfTjlIRQiau496sL8B3ubyPqReIhs09guF1v9nTVorXdesOoSJYQ3xX+4kxbw+5kGlhRFJU9XfY2PV2ahlcKprRWHV5T/XCosM+xJHoACWojlIQuteKtZ3l+4EyLhXA4X4RoCm5+YPDYxVOUK3W5aDiklWp/KKB5vKTY9Nm/eyjnFCmJgR0lXXRo3qR9fsvIv7OaFzp72Jnfis+5PX0NCQ7R8nlNGBlAUWLoOlzBUGduchyUcykEBgBryekdgW456Hv5Wknbo1dERcoN5OMeY+6gzpUPHem2PYxE1ZtycAjU4/On7DLvI8bka1oPPzseLf36qfS8QbH9SzjTjYaN1JWIhpsfsWKlcuPJEt/falPccyQ4lgLoczTXllRmhgO1dIuoEnFuWdP9W4whMy6FfMLT6i/w5GjlfPKUH7W/ieixo4Ov+YxzIPemAGWvK4ziTeLTgJRCE2GYyvLs16xgoUVsO+G/HKOOZe/ARtNuF/jrnV+OtqRV7bLlPYfxBCifgs3coJXVML29ZnUyBrzjs+2nYoKoM5n4L61hraA66U7chabJ32LnTbNRrcQfi3sUOJeqXAbsfM4RNYijRMdweQARuA999H2tGwMVD6LXi4u1+hHf7pTVGm2jCXGeQEWfwjWJdtzT l6YyVL+n 8ldnDbCT/3LA30rqI9p9bQHgbGv61nIZLK9V/LS3+meojC7SmRvWgz6aEuyD4JRn267M8fwgu4+b6R286bwXWhjgAXiCIJ32aii7bD7nuBtG7OEstkHgBVOrTHKjXC4DP8LlgKDOqsM+gMSOr2x5vmhkXmngJFyQtorIgmNzjNbaZZpwV1yQGJYO49rEge+CL04+jOuETFB73nt0IfWdXwn2BlPAYmwLpP873zB0/DwOV0cjxYn2P+ijF8IpgzYLxya7QK5H3ZwSdFYlgJuUsmh5eO8V2tC5bBmdMlTXpjei7IMAem51JKfE1RFkZmJtWzxhTHqyW6L7QbI2QGc2LyqWGzoKT4uwhLb/6HMxb9MSwqZLKrB/OYxv+UvkST5SGvCATc14mjNUXjRtIO+3kNgzv2CmRUQsMv0lL 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: <linux-mm.kvack.org> |
Series |
use refcount+RCU method to implement lockless slab shrink
|
expand
|
> On Jul 24, 2023, at 17:43, Qi Zheng <zhengqi.arch@bytedance.com> wrote: > > Use new APIs to dynamically allocate the gfs2-glock shrinker. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Thanks.
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1438e7465e30..77da354667d9 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2046,11 +2046,7 @@ static unsigned long gfs2_glock_shrink_count(struct shrinker *shrink, return vfs_pressure_ratio(atomic_read(&lru_count)); } -static struct shrinker glock_shrinker = { - .seeks = DEFAULT_SEEKS, - .count_objects = gfs2_glock_shrink_count, - .scan_objects = gfs2_glock_shrink_scan, -}; +static struct shrinker *glock_shrinker; /** * glock_hash_walk - Call a function for glock in a hash bucket @@ -2472,13 +2468,19 @@ int __init gfs2_glock_init(void) return -ENOMEM; } - ret = register_shrinker(&glock_shrinker, "gfs2-glock"); - if (ret) { + glock_shrinker = shrinker_alloc(0, "gfs2-glock"); + if (!glock_shrinker) { destroy_workqueue(glock_workqueue); rhashtable_destroy(&gl_hash_table); - return ret; + return -ENOMEM; } + glock_shrinker->count_objects = gfs2_glock_shrink_count; + glock_shrinker->scan_objects = gfs2_glock_shrink_scan; + glock_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(glock_shrinker); + for (i = 0; i < GLOCK_WAIT_TABLE_SIZE; i++) init_waitqueue_head(glock_wait_table + i); @@ -2487,7 +2489,7 @@ int __init gfs2_glock_init(void) void gfs2_glock_exit(void) { - unregister_shrinker(&glock_shrinker); + shrinker_unregister(glock_shrinker); rhashtable_destroy(&gl_hash_table); destroy_workqueue(glock_workqueue); }
Use new APIs to dynamically allocate the gfs2-glock shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- fs/gfs2/glock.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)