Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp20749lqe; Tue, 9 Apr 2024 13:05:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPeXDXTontFqxbjII+LiOXcczmKdaOSiuMe4/bc7okrrjcL2vzvqrBLo1Mh/phYPL7hb19rH3sNYsovmkWhWXmsJF6YhSBcxrfKA9adg== X-Google-Smtp-Source: AGHT+IGtfX9a5gGxwuOFTSUN/A8g/NuhfW4RG+OJ24iyQYtUU4OnSRb9/yIc1o9bmPqSOhdgKfNh X-Received: by 2002:a05:6870:518:b0:22e:bcfd:deb0 with SMTP id j24-20020a056870051800b0022ebcfddeb0mr735031oao.41.1712693122891; Tue, 09 Apr 2024 13:05:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712693122; cv=pass; d=google.com; s=arc-20160816; b=SzGKdy3kIO6fb1xkLkENyAhhmHxwo7fSGFQTXbeUSXHzRkHnzW32mgZABBugBVQXlr we1rSPm0g8v6ZAlQlTaXPX0n+Dy7HdbbmVTDHVGnijDwV/c9mNpDdargOUQdfLK0jeaf cyzHxO6W6hVNmWtdcKbsPrF3ePuxfjcmP5U9MCTrnCd0hpzwN/GjPpdjDze2vFblv03/ xd92L8W3hpem28ZfveSQtHaJxjUGcQnjlKC6EGd5iFbFc6Ppt74bD7FspfRNhvVFqr2Q 2WmoMLEIHS/ECDBEdW6aS8jgT/gxspoWpyjUleqxqbNajLknaAFI9yPeexAPfd51M9U5 k3iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=bWen6s/ctyxXdsa/v73wRWXVGVRk2U5tzXGn0nivC2w=; fh=WCLPHHe9biV/2Xz3UvWPS48CcQrIiFvdTYcyjizavVU=; b=l8WLKyc9nuzdwH8p8sQ74UfIufjAifpaTbY5qM4v3gqPFdipKjUAnsXb1JFLVB2IUi DZSa/QMeq5SCpZvfFGmYWN+u5MzKlNjm9O05v1vlxQhMzSUnrMn7LIR/UVn/MAGsBoDt 39yhiq3wAr1oUI2eEOGS2BOXw2BQUIuQXdIaMuan71ajrqTRrMris2N46UAKCSODGaB/ u7xJaKdXKQKHsUP44M8bbcODY7dlMHVmvPjwWrvph37DV7U/ewFvDw5K+LD715cQ6n/B PkRLYpKkNmlfqCbTv3UnfTGPiOngwIn5CQ5RLgi2QxGLtsQpl8ceCQafiBTL6IUwazn6 zsIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=daqan8zN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137573-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l12-20020a05622a050c00b0042f513f3bc1si10966816qtx.786.2024.04.09.13.05.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 13:05:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137573-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=daqan8zN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137573-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 862941C226CA for ; Tue, 9 Apr 2024 20:05:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DE151581F3; Tue, 9 Apr 2024 20:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="daqan8zN" 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 61A06E566; Tue, 9 Apr 2024 20:05:18 +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=1712693118; cv=none; b=lMeP9Q0sVIk18Wz7l2GxA4E8rkp1xQEP+U4cT8nuJ76KinUwtiYmCbrWTKrn+a/MNNlFgg4cWh/grlxm3U+6QxvDQsijxsZA2Vj22mNLrBoiyhjzgPwM8vFPfQSLHhifylfJn4Sl5BT+TPi6KuXz09wIlojuHnFg1CARibLn9y0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712693118; c=relaxed/simple; bh=EMEDkiy24xdD1xBgPZ4U0NiuQEd7Oj7O/uHFBRj/yq0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XiAfWQPre9TapyV5XBbYAvZdjlpcFaeuevk2ZA9IG7eO0pFJq1ba4RjSvP+M4cZtE1Km3R8TLB7kgNc+mpSa3sXo1J4m7xPeIZpCooG+6Zgndg4Sc5tNEZ6vdYR9z5fiIhshbWNdV2GQkWGHo81+Y5+KKB8ynsvY7YVANvuOm7w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=daqan8zN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2CA6C433F1; Tue, 9 Apr 2024 20:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712693117; bh=EMEDkiy24xdD1xBgPZ4U0NiuQEd7Oj7O/uHFBRj/yq0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=daqan8zNDBoK15VbmlIRo7PrcDZTG0EcT8TuNvqUQ35TtmUMf7bejJHI5baNMck77 U2a0u06i8gOpxX4CzMaNPG7yX/vgZQircJiWfqk2Au7yWlzYHMEqEGGBWHgf5TU7S+ 1j+bUiaGlMDP3RDMK+xERaxKRtfExAC4UrZVhbfNgHEoQpvHSvtb70kOQvdyWodQZn SGBAEMPD8DqIW7AMXZh+SsH7kWRDXFGezOPrJNzuxaicBSkYOV3IMwZotXQ3wWw7p7 zkrhBY8uypxT046yFgqUPFHg0fFuLs2YvMKbpg5C5bJqoBLZM0vePqYDeBzqk8RNcO o6Uz603WgtDNQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 81434CE2D22; Tue, 9 Apr 2024 13:05:17 -0700 (PDT) Date: Tue, 9 Apr 2024 13:05:17 -0700 From: "Paul E. McKenney" To: Zqiang Cc: frederic@kernel.org, neeraj.upadhyay@kernel.org, joel@joelfernandes.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] rcutorture: Make rcutorture support srcu double call test Message-ID: Reply-To: paulmck@kernel.org References: <20240407112714.24460-1-qiang.zhang1211@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240407112714.24460-1-qiang.zhang1211@gmail.com> On Sun, Apr 07, 2024 at 07:27:14PM +0800, Zqiang wrote: > This commit also allows rcutorture to support srcu double call test > with CONFIG_DEBUG_OBJECTS_RCU_HEAD option enabled. the non-raw sdp > structure's->spinlock will be acquired in call_srcu(), in Preempt-RT > kernels, this spinlock is sleepable, therefore remove disable-irq and > disable-preempt protection. > > Signed-off-by: Zqiang > --- > 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 807fbf6123a7..44cc455e1b61 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); This will get us "call_srcud() test", but if there are complaints yet another string can be added to the nrcu_torture_ops structure. So I have queued this for testing and further review. Thanx, Paul > 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) > -- > 2.17.1 >