Message ID | 20230727080502.77895-21-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 37CA5C001E0 for <linux-mm@archiver.kernel.org>; Thu, 27 Jul 2023 08:09:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3B836B0089; Thu, 27 Jul 2023 04:09:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEBD76B008A; Thu, 27 Jul 2023 04:09:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8CCE6B008C; Thu, 27 Jul 2023 04:09:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AA85D6B0089 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 04:09:56 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7FA1D160FEB for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:09:56 +0000 (UTC) X-FDA: 81056668392.18.0E63D1C Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf21.hostedemail.com (Postfix) with ESMTP id A0AE81C0012 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:09:54 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Ws66ywmi; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.176 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=1690445394; 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=YHU8OaKZwBmHAPsd+ulZSL5GxfVyMtJ49ZlHBntG+/k=; b=pUzfTHYlR0mXaquL703Pn97wyRDLfe8oJ/GCBh6EbDsMZULMc75aabBqlr7fzpe/R/8ivH X1uvwhGTd6JdT1KX2LMLHHTkZwyP9sJB0+TuHF+VJYSIzKZOWNSC/skZucT5u3nScJM8dV 72xpMC8HrNlOKVgq9UMf0iVuG+Ph24Y= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Ws66ywmi; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445394; a=rsa-sha256; cv=none; b=5SFGoYfkTK1IDmyN9d+01h7Co9AGFIhIu3KbD2clpiW+pycg/8cCRjV5LD+Hdu38Dg/OIo 3JpvU5xrfLsMn+ftk8e5FICafFxfVgHkcfcGqvtUa2Yifo7nBcI6QvFxDvJpYKFnnVRoJR e4EpYY0bLHKPhbQla64SzdFYSGpp1n0= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-682eef7d752so204032b3a.0 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 01:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445393; x=1691050193; 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=YHU8OaKZwBmHAPsd+ulZSL5GxfVyMtJ49ZlHBntG+/k=; b=Ws66ywmifmcLi+WS7kmIq1OGsH1BFTj57lSknLEKHfbjZoq0FCk32P7hFix2O77y/C 4VExY7boGbko1TLXa8rf04m6+c8ScNg+Ye07GBCAr/bT75kG0yI8bdxHraEPkF+rcUYR 8BmftTtO1b4i7ZeslsgPT7KHdxn3xY8ziOGXEmWj+FzniwFS8tNvAxdGJbvq/4djXF38 gQDVTQD96XEDgWvn9v9d4yLEL0qbZzBxPnvHBbbs4StP2CGFCs0AHk/pzAfhLwFN3LYv MATNwQY8c4ti2yb34XlOR1fjl5eoQUN5qPDBlkMol6h4RrCuQdh3qGqhSkTUZQAnG9Jo zXhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445393; x=1691050193; 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=YHU8OaKZwBmHAPsd+ulZSL5GxfVyMtJ49ZlHBntG+/k=; b=bWPuIbmoaTlCPkwP3xDOqbb4yMPqhy9Gbyr+N1Qe3a4mbkghaFWYzQImxTdw3rfz5E Wz7e8X8IjDViKnScZcVgfbiCq0PyZoEVTUWduUZ9RgiVJY95QG3BI9ZPLbgboNErQ9KB Kki5j3reLljF/QUPQOLu+Rxoggq+ZRlwJ1rjR00W/cP27zX1ACqTVlLvyZpa4QPaHauB /IR1pxJqlru6TbPiBZKpMaksZYqpO9Hg2z1IAjg/sfstotwY7lJq5lyGtcQTIqYSBh9V ve1myGocuSDdFb1ox7YbWuw4Sx9j//bYoOM6SGGyscPPAPo+/dOFhcjK+LtPM+wbT9FH BIlQ== X-Gm-Message-State: ABy/qLbIfazQYs+LW4qKp0pQABGivAFEsTBwXsnK5zCdr5fbAqFvkcUD LAgAl/pg0nzh+g11qJDfNaFwzQ== X-Google-Smtp-Source: APBJJlFl46sZLt7x9x1yarGXcrDY9BzfubiI/ML/2A4f5iYMwILGEdxBDjTGuKdYIeQS2k9MfMDqhg== X-Received: by 2002:a05:6a00:4a0e:b0:677:3439:874a with SMTP id do14-20020a056a004a0e00b006773439874amr5199798pfb.3.1690445393467; Thu, 27 Jul 2023 01:09:53 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:09:53 -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 v3 20/49] rcu: dynamically allocate the rcu-kfree shrinker Date: Thu, 27 Jul 2023 16:04:33 +0800 Message-Id: <20230727080502.77895-21-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A0AE81C0012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: x4g5gwwcpseano4xs6n1g3necd587ffs X-HE-Tag: 1690445394-343728 X-HE-Meta: U2FsdGVkX19R7C9IM9DASGzMkMzX76xrwknX/0OtS00oq09Gz4OVRryxvkqCDpJdXy2NlHFUo9wv0qehZrrZao70cjlysM0nZiYuCxPE/ni8EN8bVK7Xm+1PPTAFZulpNrYLsL3x3wnPUURZ06keOKDDZVjSybP80wGYC034MmThaeKZ1fDn9aWSCLUBbidf9f22REU63UPE/ck0tyYcDSqV2B7yV2N3jmkwg4t3tNgPoMfgzA14S+wUBue2D10Ao5IkQhS/t5xWd5hO2xysj6mNynqE6hQrmzqJQvZtIGjx0swcaP+VpcAuZ4dU122axZxsaTjZWJMmA1QRA7sYeHS0rdsR9zlYKcGhcOAyYzyjokTpEBERNN6/6x2pkPOL/F/eoO/ySGOuKKGCh2ezKujnR1TGaMPAp/PGHYvzOmUk+7/HXfbvRxz3Ezy//CejbQYzxcD74pGGiGgzzb6c8aEyptOOiAbPPOYJVOlaF7E2KDUKkKyLkSHxSoh8oj6X59mTaq305V3IEwnULRotqdjJbTvo8Zv4Z0etUj+Ka4Sa9Uid+e6HfkCTR31rrZkW44oKGSj2GP3N7HTg0Lz0FC6MdnMFoq3SGHXEZcN9MQN+lh8L98gEvvt4b4H32GFDZrdrvnmbqy4TKk1VmKEylly51kUzmUJv7JanGnJO/vY8aUIvgIo/qg2AAPPC7N26N8K4+lN25q/vc8V0jqMqLdfcEHnukieUPfTbn7MORPzZmUA+VRjjgQSjY1FLxxuNxHRU5SF+43KSG0mI/fwdMB2AvFznsnaKvd9ooDM/cDJZTSfY3GdPvCvPhOs4JZm5Yl/5s/BAu7diDVdpt973Y5xBhKYNfWWV4dxeApsEmmb/1AmywywxOPm5HGi+hmFFXZKQbCvgnm42TkOVxT0MPMqVIN2yR9XBrrajrKPoGI8yBipldqhtwuMwEhleXj3WRdftrB5phy+b4IWONM6 cq60wqmt E4qgF1LC6a9+NQe3/O08UIEy5dMMuWvQ4BLix29BjiBCW27xs3rbpkec8Kk41FG/PozVu6ulHXgkUfX7C3XNZXWFgz2EFrWT0IaQxzu4rIPUeVyc/G9oEYx8AytRV/sedb+ySyvR13RdH6XVTvNZH4HlfSdOwF0ugmlcD2sj/RNBKaWlDIS2rM3KZamusr7dpH3NZWFeYUYi0H8BqkG4mR2lnt1s3AybhCW8/arwUi0S08kL7XCkqNe9XzrtbmYBMYP/jRpGEVKNkn/3SO/gjTHm+BVhqeqVilYZ78GPN+aN/NrTei4eSx7yzojXlbOA8fh/YtN7ZRSTifqhz2hWqHQVND8SCytTC7BHCOT/Qb2UxKR7Sx2RxdH/XjbOcsuXvPgjq+aXjGIzvrL2EcmrWv7kAjY3L/3nSTmo4hnz2gbv+JxC0GKOJ0KFKUy26QRA9quCS 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
|
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index cb1caefa8bd0..6d2f82f79c65 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3449,13 +3449,6 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) return freed == 0 ? SHRINK_STOP : freed; } -static struct shrinker kfree_rcu_shrinker = { - .count_objects = kfree_rcu_shrink_count, - .scan_objects = kfree_rcu_shrink_scan, - .batch = 0, - .seeks = DEFAULT_SEEKS, -}; - void __init kfree_rcu_scheduler_running(void) { int cpu; @@ -4931,6 +4924,7 @@ static void __init kfree_rcu_batch_init(void) { int cpu; int i, j; + struct shrinker *kfree_rcu_shrinker; /* Clamp it to [0:100] seconds interval. */ if (rcu_delay_page_cache_fill_msec < 0 || @@ -4962,8 +4956,18 @@ static void __init kfree_rcu_batch_init(void) INIT_DELAYED_WORK(&krcp->page_cache_work, fill_page_cache_func); krcp->initialized = true; } - if (register_shrinker(&kfree_rcu_shrinker, "rcu-kfree")) - pr_err("Failed to register kfree_rcu() shrinker!\n"); + + kfree_rcu_shrinker = shrinker_alloc(0, "rcu-kfree"); + if (!kfree_rcu_shrinker) { + pr_err("Failed to allocate kfree_rcu() shrinker!\n"); + return; + } + + kfree_rcu_shrinker->count_objects = kfree_rcu_shrink_count; + kfree_rcu_shrinker->scan_objects = kfree_rcu_shrink_scan; + kfree_rcu_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(kfree_rcu_shrinker); } void __init rcu_init(void)
Use new APIs to dynamically allocate the rcu-kfree shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- kernel/rcu/tree.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)