Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp998203qto; Thu, 27 Jul 2023 01:24:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlEPzkgv9r6CHQV+p07ubjL2P1RNtR496HcO7n3qwyh5f5BBPiyLsvVMfVuW8qrw/65CWgOy X-Received: by 2002:a05:6402:712:b0:521:a99b:a233 with SMTP id w18-20020a056402071200b00521a99ba233mr1119883edx.10.1690446298429; Thu, 27 Jul 2023 01:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690446298; cv=none; d=google.com; s=arc-20160816; b=uQgmEqsySZmhZjozXfU9V7Pykc6uJPzymYirvlTX9FwrNJ7+tuvIreGfzIRw2yUyBx F+JwZvAnOk2vOcCPnFIVlcUBWBi1r6XP7zKt0vk2s8wb88pYSvv3Ky4rK9K4gK6sP4rM 9YNJBkM4Quqw4YHtIkoPKPeDMqNpVTYEOVnFIHAqQhSeqK21/V8uLfTXpjY4bNsnF/1P aBtCQgy/K7BnwrTfIKa3WkdVu/VNyG3SbAIirthwEpV5sQIt7GKWmuQlWNlPRXvt+Lb0 bg0dB7Vg61ns7+ONcdrr4FaX9kBPAcX6JsqEjPKYSXD9ceyYKK4aXCmzJmM7gRLjKtRl Q5TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YHU8OaKZwBmHAPsd+ulZSL5GxfVyMtJ49ZlHBntG+/k=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=BXrova4ZjvPwb75eqwP5xzzrB9NE3FrfM1XWQNPHGWJfTZdANkP+QXoDrAhK0Jb/X1 OySPY4t4VxuYmSh2gh9C1kTw6IVieV+wzwHSNStO1I3ki+0c6qXr7gjsT6BiffS9bEtp odd9o8O1kPtWlzbWDPMONiw6u4CR0e2AqEgx002MTSpCi7fmb18AXtKjyfD4pm/YHUUc qVWZSFOMAYZ3K31OXLWw5AFBV9HTbtV6ycE46L5DgTQB+JenA4h4x3J9Ro94Fxt0wrGs VYaYVKKovs1m6yfBlXlZoWACg7YmyWrvssBvrpoANW/3ppRDjqtbFoXAAbJFN4YrJnbK JLuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Ws66ywmi; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 v24-20020aa7d658000000b005223a5df62asi615309edr.198.2023.07.27.01.24.34; Thu, 27 Jul 2023 01:24:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=Ws66ywmi; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S234694AbjG0IVI (ORCPT + 99 others); Thu, 27 Jul 2023 04:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbjG0IS0 (ORCPT ); Thu, 27 Jul 2023 04:18:26 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 631215FDC for ; Thu, 27 Jul 2023 01:10:33 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686f6231bdeso113059b3a.1 for ; Thu, 27 Jul 2023 01:10:33 -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=GUcizdL4rl2tRZ+zQ1SUvMxCBkn9STEHoiaOkKKkk8vrPHxC1iETUp5/YlnN3QtSiT kpStXCmMYeZdx2O1OtNFShWVMYXcKs/DThCzoiZ9AzupdAQX6BGGHVlrv7ysEYwwthJH AcBGn26C1ZY08EFM5K8LY/UTqbIbHD9Bf63rtu2E6J4L165sBWLHvEM2cxJ+Wbla9pKQ jN286/0zJirlrazeciwFXIN/Srvdc2vevuGCBFpSfeegBlewun4GCvMEHABehZThy9Ix zQna/CQ3uBn+b2/Ej/UobZnNZAz7or3nWj9Ufs496qs3d34oSmqo6lt+lHf7aEFY/Cb/ gI6g== X-Gm-Message-State: ABy/qLaWFX6j2QOj9vkdvoNT5obzxQXwsGsiCEVcM0TGd4d0NzZJLcu5 21JPwE8FWGwmWWbQ9D2Rw+EU8Q== 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 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 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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-ext4@vger.kernel.org Use new APIs to dynamically allocate the rcu-kfree shrinker. Signed-off-by: Qi Zheng --- kernel/rcu/tree.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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) -- 2.30.2