From patchwork Tue Jun 4 22:36:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13685946 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A40014D440; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; cv=none; b=uzibc90Z+SzfgwZ6E1NVq/3hPZZOWAbEuO3HaCAyks1wWzb7IQJUevy7SaRaI3Tmgt1AVTo34yfzMlX2y+dB1feEFw5SJ/HHlsJ4xOa50VLWSXQRleTKjvov4PIA95wW84uAFbDv+DBkW/exWzYJutAbGi2uBDjbLrbU4WLD1n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; c=relaxed/simple; bh=NOwZpjRsx43legxKprMX+skO8mm2ciSTty9AOru7vw8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=puDTgdOI1WgZKRlAo+eM4cQkzRm7ITgUa3NlAKLRT+fT2oBw91obpHIdzE+oCK71SrelXaaN8XWJsj/0t9J6XfKfwIaoJUCfLW1UDtpE0CNugu7SIega62K58zZeXjqZNBW4Pv3Ha0L9heAf22PBfUAEYWiqm59vyB87nVp6Jxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R1uw6ulO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R1uw6ulO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5C4C3277B; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717540595; bh=NOwZpjRsx43legxKprMX+skO8mm2ciSTty9AOru7vw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R1uw6ulO7sCy1JuR5MRlxujDrk8+CRxHBHaowvKRKyIR4bXUA45nRTsjKYOo3j2U5 dxHbueXjjIKGRRh6BhlLbocAhdwxQb7ZE3Rp7oLrDQoc0mvaOc3dJ4TY3r31h1OGxn qH2Boa/Wwnz0lawxZMnDUy2oBVUptGesJpLZ3lVKsy2EEfvvXcEwgj8wNN6xa8suOd i/KvwPoDe0C375lPrUDmi17jhDuw4mBsmYXwi2oDROU4wbV5qDg0+ZBnw1qpZ+nRKY FfzLVpD8Z+/kraRzNGf6FHnIKowco4uVi36V7dpgwxn/UMYMmBIR3vPjjU8CbgZrMo dcwey5ulTbEpg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D5E50CE3ED6; Tue, 4 Jun 2024 15:36:34 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Zqiang , "Paul E . McKenney" Subject: [PATCH rcu 1/4] rcutorture: Make rcutorture support srcu double call test Date: Tue, 4 Jun 2024 15:36:30 -0700 Message-Id: <20240604223633.2371664-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang This commit allows rcutorture to test double-call_srcu() when the CONFIG_DEBUG_OBJECTS_RCU_HEAD Kconfig option is enabled. The non-raw sdp structure's ->spinlock will be acquired in call_srcu(), hence this commit also removes the current IRQ and preemption disabling so as to avoid lockdep complaints. Link: https://lore.kernel.org/all/20240407112714.24460-1-qiang.zhang1211@gmail.com/ Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 46 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 807fbf6123a77..44cc455e1b615 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -390,6 +390,7 @@ struct rcu_torture_ops { int extendables; int slow_gps; int no_pi_lock; + int debug_objects; const char *name; }; @@ -577,6 +578,7 @@ static struct rcu_torture_ops rcu_ops = { .irq_capable = 1, .can_boost = IS_ENABLED(CONFIG_RCU_BOOST), .extendables = RCUTORTURE_MAX_EXTEND, + .debug_objects = 1, .name = "rcu" }; @@ -747,6 +749,7 @@ static struct rcu_torture_ops srcu_ops = { .cbflood_max = 50000, .irq_capable = 1, .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU), + .debug_objects = 1, .name = "srcu" }; @@ -786,6 +789,7 @@ static struct rcu_torture_ops srcud_ops = { .cbflood_max = 50000, .irq_capable = 1, .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU), + .debug_objects = 1, .name = "srcud" }; @@ -3455,7 +3459,6 @@ rcu_torture_cleanup(void) cur_ops->gp_slow_unregister(NULL); } -#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD static void rcu_torture_leak_cb(struct rcu_head *rhp) { } @@ -3473,7 +3476,6 @@ static void rcu_torture_err_cb(struct rcu_head *rhp) */ pr_alert("%s: duplicated callback was invoked.\n", KBUILD_MODNAME); } -#endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ /* * Verify that double-free causes debug-objects to complain, but only @@ -3482,39 +3484,43 @@ static void rcu_torture_err_cb(struct rcu_head *rhp) */ static void rcu_test_debug_objects(void) { -#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD struct rcu_head rh1; struct rcu_head rh2; + int idx; + + if (!IS_ENABLED(CONFIG_DEBUG_OBJECTS_RCU_HEAD)) { + pr_alert("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_%s()\n", + KBUILD_MODNAME, cur_ops->name); + return; + } + + if (WARN_ON_ONCE(cur_ops->debug_objects && + (!cur_ops->call || !cur_ops->cb_barrier))) + return; + struct rcu_head *rhp = kmalloc(sizeof(*rhp), GFP_KERNEL); init_rcu_head_on_stack(&rh1); init_rcu_head_on_stack(&rh2); - pr_alert("%s: WARN: Duplicate call_rcu() test starting.\n", KBUILD_MODNAME); + pr_alert("%s: WARN: Duplicate call_%s() test starting.\n", KBUILD_MODNAME, cur_ops->name); /* Try to queue the rh2 pair of callbacks for the same grace period. */ - preempt_disable(); /* Prevent preemption from interrupting test. */ - rcu_read_lock(); /* Make it impossible to finish a grace period. */ - call_rcu_hurry(&rh1, rcu_torture_leak_cb); /* Start grace period. */ - local_irq_disable(); /* Make it harder to start a new grace period. */ - call_rcu_hurry(&rh2, rcu_torture_leak_cb); - call_rcu_hurry(&rh2, rcu_torture_err_cb); /* Duplicate callback. */ + idx = cur_ops->readlock(); /* Make it impossible to finish a grace period. */ + cur_ops->call(&rh1, rcu_torture_leak_cb); /* Start grace period. */ + cur_ops->call(&rh2, rcu_torture_leak_cb); + cur_ops->call(&rh2, rcu_torture_err_cb); /* Duplicate callback. */ if (rhp) { - call_rcu_hurry(rhp, rcu_torture_leak_cb); - call_rcu_hurry(rhp, rcu_torture_err_cb); /* Another duplicate callback. */ + cur_ops->call(rhp, rcu_torture_leak_cb); + cur_ops->call(rhp, rcu_torture_err_cb); /* Another duplicate callback. */ } - local_irq_enable(); - rcu_read_unlock(); - preempt_enable(); + cur_ops->readunlock(idx); /* Wait for them all to get done so we can safely return. */ - rcu_barrier(); - pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME); + cur_ops->cb_barrier(); + pr_alert("%s: WARN: Duplicate call_%s() test complete.\n", KBUILD_MODNAME, cur_ops->name); destroy_rcu_head_on_stack(&rh1); destroy_rcu_head_on_stack(&rh2); kfree(rhp); -#else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ - pr_alert("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n", KBUILD_MODNAME); -#endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ } static void rcutorture_sync(void) From patchwork Tue Jun 4 22:36:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13685945 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A3D614D43E; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; cv=none; b=AC4JcfLTyp11V2SXJJ2GvGC3Xjd7RmmfEgXmjRHuPP+gSwEPeUsjlIdZ1kzv/2ETzUCXPho6iya0DnQ4yoQSbWf6M030mVW108zQoWNCr8WRKeq/1wLqDUysXdJ0qpRIj9kTfFCmtf71uQ9w4mtsoSlj5QnAjL2fszXN/v7yMJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; c=relaxed/simple; bh=A1B89F6f71BTaBD2c6ys6oWMLDn6LLn8Xrl2YURYyWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FOGXLgkSoaZnhF5wIdx+gRlh0rgcTAVSfD+Y9FGeZwd8Bzhxc5UJbIYGzTi3rVCH4B9+pRVWC4BLVCpeZgAs8sPmm/kSRfuBxSdaKEHGUUhI8de0JgiZLUrXX8ZdAXeX6UQXgz8StSuqsiuEuxhPAOHYgivRBf31HIK0OTcRGzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fjtHMhPW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fjtHMhPW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B587C2BBFC; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717540595; bh=A1B89F6f71BTaBD2c6ys6oWMLDn6LLn8Xrl2YURYyWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fjtHMhPWw2cR4PKJ4a0oFaDUSfzScELdWeoI4yGMOj6zZsTY5rpLw4sHKmci/EDZ/ YMAlVPmKdbylzk/bLssle5qYVVtiaQkLDmcX2mboeOxYQznzlE2GEEppbSeuB4jT1O JLyT1qg1Vv2qWQYSvcsbKAixmlFLZNvEqoWB/IMppEDrOPTKUyfPBfb1WuPW3GcGaY SBiTP6nNBzvnkZ030aBFPgn9Y7qt2EHZUtKnEpQvUGqUpi8FsJrLCD5+lQyratdNq7 eIXom5hhimQr3PhG3pVl/QNUW0+yVjH4dbjqtbZ+OOv3FkJlq5c6ivT4VuQQEVzods XPbom4jpExVMg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DF4C3CE3F0F; Tue, 4 Jun 2024 15:36:34 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Marco Elver , Andrey Konovalov , kasan-dev@googlegroups.com Subject: [PATCH rcu 2/4] rcutorture: Fix rcu_torture_fwd_cb_cr() data race Date: Tue, 4 Jun 2024 15:36:31 -0700 Message-Id: <20240604223633.2371664-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On powerpc systems, spinlock acquisition does not order prior stores against later loads. This means that this statement: rfcp->rfc_next = NULL; Can be reordered to follow this statement: WRITE_ONCE(*rfcpp, rfcp); Which is then a data race with rcu_torture_fwd_prog_cr(), specifically, this statement: rfcpn = READ_ONCE(rfcp->rfc_next) KCSAN located this data race, which represents a real failure on powerpc. Signed-off-by: Paul E. McKenney Cc: Marco Elver Cc: Andrey Konovalov Cc: Acked-by: Marco Elver --- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 44cc455e1b615..cafe047d046e8 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2630,7 +2630,7 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp) spin_lock_irqsave(&rfp->rcu_fwd_lock, flags); rfcpp = rfp->rcu_fwd_cb_tail; rfp->rcu_fwd_cb_tail = &rfcp->rfc_next; - WRITE_ONCE(*rfcpp, rfcp); + smp_store_release(rfcpp, rfcp); WRITE_ONCE(rfp->n_launders_cb, rfp->n_launders_cb + 1); i = ((jiffies - rfp->rcu_fwd_startat) / (HZ / FWD_CBS_HIST_DIV)); if (i >= ARRAY_SIZE(rfp->n_launders_hist)) From patchwork Tue Jun 4 22:36:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13685943 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 654AB14D439; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; cv=none; b=OxlXw03aIYlYgc4NiYQrhoosbcYMDHTvjgsOJDp5O2d2+ETPxc0AknQSB9v+LS40OmgEGG8MiZUFephdLVNKtJETXUHyFS1hK/GikIv0XNbDtWI3JySCreNBjkt/nCb5/NzBkFSjG7hKy4nSoj4L8cWIDs3UomrJarBpuEaM4/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; c=relaxed/simple; bh=3W1hLX3CDpcxFpIRjKB9LG1doeFsN5iCPTpoG6MXxYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rrd9ivCrBQigqOr4CGxYBe4hXjQQxFKQrEuDQ3aQixq0sVe33K7ciBiUcDmfEeUp3RAwMeM6MQCw/6UK7xb1jx3dIkJeZxW/1O1uaOjU54N2VpIhgJl80++FK5SeCngIROuntxFLa6lwzEs7bvltGzOZYHzghHSqO83mY6Egg/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=laGrPfry; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="laGrPfry" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 429D1C4AF07; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717540595; bh=3W1hLX3CDpcxFpIRjKB9LG1doeFsN5iCPTpoG6MXxYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=laGrPfry+NoKRkhCtXFlV7rexL+lJdX+qFMm6Aqd2wpb1eHc4g7LZbh3D4g4HMPfB oYB/CrbXxcK77v4TuWd/2am9tNpJotqOdPaZABoYmXxipwyK383HdDXylqXEEMDdgE VfrkKKlu/Ndle6RFR//qbeFwCZ3EVVc01jLCpNfQ4T1ZOze+uFVlF0Kzo56AlVGE3u SlOGQ+j3IHhfr6exRiy/TwvWIU2YiCB9UtjFJvfFGNk0FrZZLQTgNnzpYKnt6F5M7F dSQydJKPDw/Ue+BJ3NAO2LUciZdW1Zt1kZWo36cYLreyQgeSaAZG3UfPFZ66qSJ5gt 6jy4beKCEQXOQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E2CCACE3F26; Tue, 4 Jun 2024 15:36:34 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Jeff Johnson , "Paul E . McKenney" Subject: [PATCH rcu 3/4] rcutorture: Add missing MODULE_DESCRIPTION() macros Date: Tue, 4 Jun 2024 15:36:32 -0700 Message-Id: <20240604223633.2371664-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jeff Johnson Fix the following 'make W=1' warnings: WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcutorture.o WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcuscale.o WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/refscale.o Signed-off-by: Jeff Johnson Signed-off-by: Paul E. McKenney --- kernel/rcu/rcuscale.c | 1 + kernel/rcu/rcutorture.c | 1 + kernel/rcu/refscale.c | 1 + 3 files changed, 3 insertions(+) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index 8db4fedaaa1eb..b53a9e8f5904f 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -42,6 +42,7 @@ #include "rcu.h" +MODULE_DESCRIPTION("Read-Copy Update module-based scalability-test facility"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Paul E. McKenney "); diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index cafe047d046e8..08bf7c669dd3d 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -51,6 +51,7 @@ #include "rcu.h" +MODULE_DESCRIPTION("Read-Copy Update module-based torture test facility"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Paul E. McKenney and Josh Triplett "); diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c index 2c2648a3ad306..f4ea5b1ec068a 100644 --- a/kernel/rcu/refscale.c +++ b/kernel/rcu/refscale.c @@ -63,6 +63,7 @@ do { \ #define SCALEOUT_ERRSTRING(s, x...) pr_alert("%s" SCALE_FLAG "!!! " s "\n", scale_type, ## x) +MODULE_DESCRIPTION("Scalability test for object reference mechanisms"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Joel Fernandes (Google) "); From patchwork Tue Jun 4 22:36:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13685944 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C1214D43D; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; cv=none; b=mu/ymQ370h4FR03I8bJdCCp++F49Oab93Hy//+l2wYBz2aNtgm7VVGLleER47jyCVAIHoPg07vB9nqLQJaWgVjBqCGGoG9xc/K8w9tXS2zWi87IRLP8xzI9zg6AGLwLVP5PzX+jQM1mCtWo9rykjCNeIy28xeCJ28NH41XRxh6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; c=relaxed/simple; bh=r5THsMd/X1sUAYuciSxTtdm+hIb08O9PPF9XcptyhkU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y4fAeLGVp6dRiTDFn2mecRtJ0T7gbiPsdxt3qJz6Phh+pM5yXatfy/39k4+uY9F0684sLU09f6ZF0JP1E1HLiAKnc5fCZINKN9/YbhoBXNt2gaAo54ujvEfTT+vkZCSBUYHOYDQbMXe3QhBfi0uVarCW62/OErhYEvxbBmfhfJ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T6p+YHBN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T6p+YHBN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52F6FC4AF09; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717540595; bh=r5THsMd/X1sUAYuciSxTtdm+hIb08O9PPF9XcptyhkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T6p+YHBNbARDbkcZOkS4CuSBt6shD/7vZMFuzxULbk0vpeNFJOLSv0fkLjuCft5zm W4Gg9lJL/zU9SI3PeYTjWsoqettCdtZ59fLnXnwlFKMOL1WdoNYdktV+L26RCtFH86 YLY007WajTD8ywOqxtbWEMbx8DmdY7+iaUiIhKCTHP9jr44CmoagXN9cLEwgJDj/3s 72Rcqb5ceify9DYimB22aQWZw+gMXCRrWqU2IATUz9Fh2E/3svWmi6vLn9yd6wAmgp p/hju1N+eibcfmTieFVqHhKzChjIV8KUd2E1O0M+R2wpqVDO3L4F2MIw9NPKJ6Oum3 9ac94q1MSlVVg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E5D29CE3F27; Tue, 4 Jun 2024 15:36:34 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 4/4] tools/rcu: Add rcu-updaters.sh script Date: Tue, 4 Jun 2024 15:36:33 -0700 Message-Id: <20240604223633.2371664-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds a tools/rcu/rcu-updaters.sh script that uses bpftrace to print a histogram of the RCU update-side primitives invoked during the specified time interval, or until manually terminated if no interval is specified. Sample output on an idle laptop: @counts[poll_state_synchronize_rcu]: 6 @counts[synchronize_srcu]: 13 @counts[call_rcu_tasks_trace]: 25 @counts[synchronize_rcu]: 54 @counts[kvfree_call_rcu]: 428 @counts[call_rcu]: 2134 Note that when run on a kernel missing one or more of the symbols, this script will issue a diagnostic for each that is not found, but continue normally for the rest of the functions. Signed-off-by: Paul E. McKenney --- tools/rcu/rcu-updaters.sh | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 tools/rcu/rcu-updaters.sh diff --git a/tools/rcu/rcu-updaters.sh b/tools/rcu/rcu-updaters.sh new file mode 100755 index 0000000000000..4ef1397927bbf --- /dev/null +++ b/tools/rcu/rcu-updaters.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0+ +# +# Run bpftrace to obtain a histogram of the types of primitives used to +# initiate RCU grace periods. The count associated with rcu_gp_init() +# is the number of normal (non-expedited) grace periods. +# +# Usage: rcu-updaters.sh [ duration-in-seconds ] +# +# Note that not all kernel builds have all of these functions. In those +# that do not, this script will issue a diagnostic for each that is not +# found, but continue normally for the rest of the functions. + +duration=${1} +if test -n "${duration}" +then + exitclause='interval:s:'"${duration}"' { exit(); }' +else + echo 'Hit control-C to end sample and print results.' +fi +bpftrace -e 'kprobe:kvfree_call_rcu, + kprobe:call_rcu, + kprobe:call_rcu_tasks, + kprobe:call_rcu_tasks_rude, + kprobe:call_rcu_tasks_trace, + kprobe:call_srcu, + kprobe:rcu_barrier, + kprobe:rcu_barrier_tasks, + kprobe:rcu_barrier_tasks_rude, + kprobe:rcu_barrier_tasks_trace, + kprobe:srcu_barrier, + kprobe:synchronize_rcu, + kprobe:synchronize_rcu_expedited, + kprobe:synchronize_rcu_tasks, + kprobe:synchronize_rcu_tasks_rude, + kprobe:synchronize_rcu_tasks_trace, + kprobe:synchronize_srcu, + kprobe:synchronize_srcu_expedited, + kprobe:get_state_synchronize_rcu, + kprobe:get_state_synchronize_rcu_full, + kprobe:start_poll_synchronize_rcu, + kprobe:start_poll_synchronize_rcu_expedited, + kprobe:start_poll_synchronize_rcu_full, + kprobe:start_poll_synchronize_rcu_expedited_full, + kprobe:poll_state_synchronize_rcu, + kprobe:poll_state_synchronize_rcu_full, + kprobe:cond_synchronize_rcu, + kprobe:cond_synchronize_rcu_full, + kprobe:start_poll_synchronize_srcu, + kprobe:poll_state_synchronize_srcu, + kprobe:rcu_gp_init + { @counts[func] = count(); } '"${exitclause}"