Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2884884rwo; Mon, 24 Jul 2023 02:54:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlEJJ4D2a1ywkILkKOWMso+RSoruI0Ezf8J6R0iNE5xI+YtckeY+nS0wsealAiQWjxQghLfA X-Received: by 2002:a05:6512:1114:b0:4fb:8987:734e with SMTP id l20-20020a056512111400b004fb8987734emr5406572lfg.68.1690192494146; Mon, 24 Jul 2023 02:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690192494; cv=none; d=google.com; s=arc-20160816; b=GyChDcpC91UuATMzykGMqMwZ8WDkSzYoBWCiSUjLcXAX9XXSLEUcdyAiiJ5eO53aKt nNwexiP9Nxz8M2hvFeevcuN8x7sWn6DDo5ESIe2ozyV/wWs5BYxZfw1aNkP7PYydElbr RpmWLTqD3r0TgZu1udpBNk8969xG7r/Ss3xDXdoi77Pmda6QGso4ZkIZYBwfBrQTNZjk LL69pA4ANSAGZV1jV5aH4gCcmdNYRoL6iAtwl468k+wkWXlDjc8hamdZbj4CBEebKhsy Znal1qgPrpmRwxC6dKExrTGDRPv9DhRtA2cOzerhhb49HNkE1b08WObwAOF9YYDCg2Dv QGHg== 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=8oqpenbl7KoJJhQpMWpio5jwf7tXqseO0h4l218M5aA=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=Rn+XAETmrAKMZ4in9+eAl9v6q7u0Nn85fBg65GZ4jioZgZIJqUrhlIrf3jZBEGYd/w cToKmFcbA4+YjgmBamtG4Gnh5unNO7VsAZeNwZH5lvU01vX1iL4xdk2ZYEoyevaX38Rj OHwTgp+5DuUf1Esy/qTkAcdc/uJ60jVvnilohy0/5Jvw2ArbZwdS+E37tk0a7CkzZy6V 6VMoc/cnMAOWU3UOnIRTJB4ggbjfE3N2w28EuKjHcbER1MLVCU937UyicpmooxLHHucU g4qCXpwEqkqKacR1SMUpyNTRL5NmDZ/L/NlQBdbqtYx97q2h9JhUVs4ozctRZnQgyrGS hLYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=aCj2BNfr; 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 g5-20020a1709064e4500b0099329251046si5890888ejw.14.2023.07.24.02.54.24; Mon, 24 Jul 2023 02:54:54 -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=aCj2BNfr; 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 S232410AbjGXJyO (ORCPT + 99 others); Mon, 24 Jul 2023 05:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232684AbjGXJxD (ORCPT ); Mon, 24 Jul 2023 05:53:03 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EE5C468C for ; Mon, 24 Jul 2023 02:49:06 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bb85ed352bso2235875ad.0 for ; Mon, 24 Jul 2023 02:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690192110; x=1690796910; 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=8oqpenbl7KoJJhQpMWpio5jwf7tXqseO0h4l218M5aA=; b=aCj2BNfrpcxtoTz1/CdONfPnB9TAYVTaqB4T4WqFv6y7Hxl9V0boEFHOTATComBNn2 xnFJ8tDKgZzO2TH4FwPeDTaYzb9x0D/uxmdjUcwFhXWgN5824wox+O8c9U9ybGUIohlv M3vK6kDUgbRBz02IXlUWPuxdPW8hkxiMWgJebr95xqiqSLJbGYOLAINvEuBU6c5+0m2D KwQfMs1a5lB1SKCsavAJR55Sjok6of8gfoBXMKjbRTfwQ6NM1BD/3dZZP6dR7OXOKSHl QBl4iWtqq0OikEBOGyMzrxqP+jJMX2cWmHkmCbYCS6DP7MDoD2ilfcJavniQ/pgHFrWu bw9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690192110; x=1690796910; 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=8oqpenbl7KoJJhQpMWpio5jwf7tXqseO0h4l218M5aA=; b=Ah1Jj/Dm8remHsSoW1StXPril2sM0vAySP0HBOv9dgZMNREyEs6/AvTlFgaQTokjC6 TWQKmtj2qgG32szjxl3IDRRWNcXxMZTD0dUw/8BS10lGyUmYapDovgnJ+RDWfgeqneBZ A2dq8aspsohVrPKfEsvfY5fSuD/1RJ6Oz21a2HqAi2xz4pGI2CPLi8ikgL1UwzzCMA4A 7szlf6+G/YnvhgSzXyegm5h9qnqRLIkZdsvXZMCy4Kn9a5Zkf2SSXxC1vb1Sfu/MvUNz ytsN+1oby4mmbrRitFy2DtIEi4DHPZfcwXssXVsHNypcxecG8Qm/GSSPc7wsCKiYojMB CLqA== X-Gm-Message-State: ABy/qLY9YvRGrQESHzjBJzdmKIbPaqYiD3gkCBpgMYI8+NB1dsoJ7Tcl 0gVf/uEBB1jRCIP98QnECDK9qQ== X-Received: by 2002:a17:902:d484:b0:1b8:a27d:f591 with SMTP id c4-20020a170902d48400b001b8a27df591mr12259746plg.5.1690192110449; Mon, 24 Jul 2023 02:48:30 -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.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:48:30 -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 v2 17/47] rcu: dynamically allocate the rcu-lazy shrinker Date: Mon, 24 Jul 2023 17:43:24 +0800 Message-Id: <20230724094354.90817-18-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-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_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-lazy shrinker. Signed-off-by: Qi Zheng --- kernel/rcu/tree_nocb.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 43229d2b0c44..919f17561733 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1397,12 +1397,7 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) return count ? count : SHRINK_STOP; } -static struct shrinker lazy_rcu_shrinker = { - .count_objects = lazy_rcu_shrink_count, - .scan_objects = lazy_rcu_shrink_scan, - .batch = 0, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *lazy_rcu_shrinker; #endif // #ifdef CONFIG_RCU_LAZY void __init rcu_init_nohz(void) @@ -1436,8 +1431,16 @@ void __init rcu_init_nohz(void) return; #ifdef CONFIG_RCU_LAZY - if (register_shrinker(&lazy_rcu_shrinker, "rcu-lazy")) - pr_err("Failed to register lazy_rcu shrinker!\n"); + lazy_rcu_shrinker = shrinker_alloc(0, "rcu-lazy"); + if (!lazy_rcu_shrinker) { + pr_err("Failed to allocate lazy_rcu shrinker!\n"); + } else { + lazy_rcu_shrinker->count_objects = lazy_rcu_shrink_count; + lazy_rcu_shrinker->scan_objects = lazy_rcu_shrink_scan; + lazy_rcu_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(lazy_rcu_shrinker); + } #endif // #ifdef CONFIG_RCU_LAZY if (!cpumask_subset(rcu_nocb_mask, cpu_possible_mask)) { -- 2.30.2