From nobody Wed Nov 27 21:48:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1690445968; cv=none; d=zohomail.com; s=zohoarc; b=RPpzMBHIR4YRw1XYum9h9qmFOcB+bBCj0g5YmTbtcjegg6egPfrICxNnyk7GbciwlQ8uTK1psuCLdVab0k5F42mSb4k8Nf1bSyaHU7YkDzxSSH3ObYoamLISbx6LuNDCQ0u+s2wpQ13q8578Nh8I8a4jpUsfVcq/Opj8RkdO/04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445968; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YHU8OaKZwBmHAPsd+ulZSL5GxfVyMtJ49ZlHBntG+/k=; b=oIldtzEvpqFdiZcdKNS+ZidHUIEqz9uno1uY4AOBRXpt0SU/F0bwbw4R1Tb4kttfMPzhKhqEg5Cplm4jqFXsD0QhB/LvEigBTH+vELYISFJi2udOk9a7P0DyLASXUuFyhgYfvPPLrOlEKN304QMR9ywiPpINf9MQDJ9asaJw0Sg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690445968354935.0385708352347; Thu, 27 Jul 2023 01:19:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570919.893522 (Exim 4.92) (envelope-from ) id 1qOwC4-00072w-GJ; Thu, 27 Jul 2023 08:17:56 +0000 Received: by outflank-mailman (output) from mailman id 570919.893522; Thu, 27 Jul 2023 08:17:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOwC3-0006vL-9Q; Thu, 27 Jul 2023 08:17:55 +0000 Received: by outflank-mailman (input) for mailman id 570919; Thu, 27 Jul 2023 08:17:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw4J-0001DS-Gc for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:09:55 +0000 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [2607:f8b0:4864:20::434]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f7be168d-2c54-11ee-b247-6b7b168915f2; Thu, 27 Jul 2023 10:09:54 +0200 (CEST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686f6231bdeso113061b3a.1 for ; Thu, 27 Jul 2023 01:09:54 -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) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f7be168d-2c54-11ee-b247-6b7b168915f2 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=JcE3udefSyuYrWXUBa74TzXuFE2IUXzC1+wzptbjJsrSzFij+1kGvnFz+ylqICnjiG exCIXY8NCFU5kBYkVaoKOPG0mCjH9EPJH5YjjeWwGVpBjbig+lH7ifNjBNZRKeQBF/sI qSjGl2HWAiwz7lqNvNCmrXbZ3Oc1DrPLP6tER46WYidrIbaDJHORK9Pt1au9UUzsBG6M o9rNyuEgFyUIq4aat+Gk9B2cty++9WIBwVuc1wzrI0O97CM6lYMjqG44mh3NyCcoR60u R5dxX9/wZw43uSoFWOM4X54k5zVhPhnB9v6VM9yaVanSyMd/yVL62MKQniK1urGqPP5v n0Lg== X-Gm-Message-State: ABy/qLZoEJbWD8zWoH2tnA526TTjdtg5u9Kgk644ROwBCGFXkjENDGVw WGB4Dn5EocUW2JeJtiQk4z0syg== 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) 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: quoted-printable X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1690445969931100001 Content-Type: text/plain; charset="utf-8" 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, struc= t shrink_control *sc) return freed =3D=3D 0 ? SHRINK_STOP : freed; } =20 -static struct shrinker kfree_rcu_shrinker =3D { - .count_objects =3D kfree_rcu_shrink_count, - .scan_objects =3D kfree_rcu_shrink_scan, - .batch =3D 0, - .seeks =3D 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; =20 /* 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 =3D true; } - if (register_shrinker(&kfree_rcu_shrinker, "rcu-kfree")) - pr_err("Failed to register kfree_rcu() shrinker!\n"); + + kfree_rcu_shrinker =3D shrinker_alloc(0, "rcu-kfree"); + if (!kfree_rcu_shrinker) { + pr_err("Failed to allocate kfree_rcu() shrinker!\n"); + return; + } + + kfree_rcu_shrinker->count_objects =3D kfree_rcu_shrink_count; + kfree_rcu_shrinker->scan_objects =3D kfree_rcu_shrink_scan; + kfree_rcu_shrinker->seeks =3D DEFAULT_SEEKS; + + shrinker_register(kfree_rcu_shrinker); } =20 void __init rcu_init(void) --=20 2.30.2