From patchwork Thu Aug 24 03:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363448 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 5C6DDC71145 for ; Thu, 24 Aug 2023 03:46:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFB9E28008C; Wed, 23 Aug 2023 23:46:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EABA28E0011; Wed, 23 Aug 2023 23:46:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D740828008C; Wed, 23 Aug 2023 23:46:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C8ABB8E0011 for ; Wed, 23 Aug 2023 23:46:01 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A0B3D40195 for ; Thu, 24 Aug 2023 03:46:01 +0000 (UTC) X-FDA: 81157609722.16.2C2A4B3 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf21.hostedemail.com (Postfix) with ESMTP id D3DC31C0015 for ; Thu, 24 Aug 2023 03:45:59 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=cbb6YHTI; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.175 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=1692848759; 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=slvH5erABEtW2nvv6nNGvvoe5mGFS1H1V89UwcERxi4=; b=sjv+yWlyaFxq71B6JPDufnRJ6LsfBrr6s8b+p2b14VXciQxuLPqnqjg87cw+6G8fOUHMJB Ih/Xt9BRfxBYVikdWDxeFihlmAA/wr9HxgDRkUw1Faa2Kmq0x7RK+qruDTsdNdem5zUFMi nr/uyQZ5a3udqeCJ84ztb/lbndV6tro= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=cbb6YHTI; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.175 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=1692848759; a=rsa-sha256; cv=none; b=UWR6/7g61Mq5/AssV5SNthydCZWvkIOZM4xxTmnuH9ldgBSio69+aB+qjcscCHXQfmFUDk 51A0J5IxVD52V+o34LjPgdAxb8AI3uoc82dTzD39AT8uI9Pv7hZh8/sk7nMP8IakJCEtS0 MVlVXT4PZXBSFOvrgjcVsOQRDBVuSJo= Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5657ca46a56so832885a12.0 for ; Wed, 23 Aug 2023 20:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848759; x=1693453559; 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=slvH5erABEtW2nvv6nNGvvoe5mGFS1H1V89UwcERxi4=; b=cbb6YHTIFEQj4yQfjGUpRvykeBzedoRrcnJeHycSN6zpLxRKFd2K1sA1PClUDZpn4T KK49F+aIpE3Kw/cuZzQabHYGj+DcL5bEjWjkQ+qi7ft3Ev2JbxUbeVYCETHKaq602P+Y Q7oloE3/wd+SPkhUMg/xXEsiNT4bfTZky090yFESMFjiMV9iGF50YTAJEOHOG/FFlYOk wZOQ2hXf37apCQIv1XImuzja1cULLKP8EH8AUaPzctKv1kopSAYqQMUxWCHyKDVoFD4O R+sSI8aAT4VztFaIxvs+T3hnulNn+bEQZ9zTNyY0CnFLm+zjLyVeoOaFF/qATgaNLyIK PIcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848759; x=1693453559; 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=slvH5erABEtW2nvv6nNGvvoe5mGFS1H1V89UwcERxi4=; b=k24DVNLiWIovJt9bCZkeHQdJV1gAxL8tJxDQETI/a1nzbtnGdc6bIy4YvwkMxTeomK tBfsy+jXuxyI5RvwqhTpHDLuSghGxUhIHEblhBVilJM9MZEJkA4SoZXvXxfdf1iljXhd brJfUuatiwxcKfthaXhNvbfjWrabor45eLQ/IiREEjS9/0UPmVG9+57RntK9niBOBTMX RbUVeXK6kV8fapdDsSP8+ZbG97CyZqTQFLGkeLOhAOTBQzlSbD9IFMXr/esjLk3tjCCs zSsFZaRdvI5EVK9c+UR//3stjfoQcSvQmaPUkqrdGl0ULOVX9+e8KThZYYwldAXAy9M5 9buw== X-Gm-Message-State: AOJu0Yy01yXvcZZVRfavj3FL939aiR9CAdm8kRjkVXsOz0U/vnvZUmHw Q7afMqUE6ve4CDvbrQygbMszKg== X-Google-Smtp-Source: AGHT+IE20y+zxkxvqCK4atfI05RSclhW6cQ/eTGKWMSl83j87LaqFIyfEPTvaL3BQlf4vLg1/yn0UQ== X-Received: by 2002:a05:6a00:1f89:b0:68a:33fc:a091 with SMTP id bg9-20020a056a001f8900b0068a33fca091mr13891773pfb.3.1692848758726; Wed, 23 Aug 2023 20:45:58 -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.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:45:58 -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 , Joel Fernandes , rcu@vger.kernel.org Subject: [PATCH v5 15/45] rcu: dynamically allocate the rcu-lazy shrinker Date: Thu, 24 Aug 2023 11:42:34 +0800 Message-Id: <20230824034304.37411-16-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-Rspamd-Queue-Id: D3DC31C0015 X-Rspam-User: X-Stat-Signature: to3przhu4tsg93z6hoq4tdx8yrntqr3k X-Rspamd-Server: rspam01 X-HE-Tag: 1692848759-261117 X-HE-Meta: U2FsdGVkX1+1Qph+pxwt+vDN4gicggw4tz6DbngRgFt2R6cPvW8briuyPz091tXqe1cJ6++9mnORrPG/V1JUe04c3NtKk6qSIcEazLSNrP5MAzIKMVfv3INudDihehic5DJlknNTUCemfsD0h+Ragu0T+3b7EzomeLZzrlARgKOwc7gS5SIArBB7Jvntig+XupPfB1ODOdkvThKLxGTqPkV2bzMsECnhqi7LfO1obGH5bSYA/wYuqdBjSKEo6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KqlwsRy4l3HlcdBAkBmVWJbE/hTIztNW+6K6SLFXUGDdvOEIl1lNC4/ojBodNTVwB6GNMiKJXvRvRraQa4aVBlTURLaLg+goZFNfFqz33CsStEnGEq+F/loWDXdxKXXEHSJMTf+eI2XRSXGFoouekjrOG0TC+C/GP72ByLYrCs30ES6MQQ== 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 rcu-lazy shrinker. Signed-off-by: Qi Zheng Reviewed-by: Joel Fernandes (Google) CC: rcu@vger.kernel.org --- kernel/rcu/tree_nocb.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 5598212d1f27..e1c59c33738a 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1396,13 +1396,6 @@ 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, -}; #endif // #ifdef CONFIG_RCU_LAZY void __init rcu_init_nohz(void) @@ -1410,6 +1403,7 @@ void __init rcu_init_nohz(void) int cpu; struct rcu_data *rdp; const struct cpumask *cpumask = NULL; + struct shrinker * __maybe_unused lazy_rcu_shrinker; #if defined(CONFIG_NO_HZ_FULL) if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask)) @@ -1436,8 +1430,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)) {