Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2586590lqp; Mon, 25 Mar 2024 03:38:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMWUnGg/vQPkAIzA+Z8HevKoVS/U8wCrbmCU7wLBKqIp9ug2g4/Wd3GriQuamL/RkDJyRXMH/JRknTGc7eq1NUq6hwXzuoPd54bN9YzQ== X-Google-Smtp-Source: AGHT+IFw9YoxwgBuXh61X1tElQq9y5uiXMoElYhVpB235LllBGFOWlDwNzf0cg3CYQMWC/AI2e1X X-Received: by 2002:a17:902:f683:b0:1dc:7374:fea8 with SMTP id l3-20020a170902f68300b001dc7374fea8mr7004340plg.48.1711363105912; Mon, 25 Mar 2024 03:38:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711363105; cv=pass; d=google.com; s=arc-20160816; b=PDABQEMaJiswY+q9Kd/MVvubvNlaeY2L1hPrXobDI41+wgtyRjJ0b1QY1xk90ECR+T ednG8wncvxOCEEmNDrrDUkSz7apxnOpLtkxRQkXxH+gU+t6r0GYG6ElgA5HYCq9Qq1s+ 3HGrpvcGV6bIyvX8aoS5gCS5s/ljDQJHEBSSE4E0Y5X57IVAWbQlNZqM75G9MO6+J6gY nn3kSlIb6uqYTRI1Yvo19cBNPIObqFfkquw8zf2AzcgwHlV9tz48an3D+IBeepGPuJKL 4gqtoMDBdXSSI8L3JqES6U4XJiQqqRb8yvthX1CUQS+YNyTUyYFkclsKLenrARAXm4I5 FXow== 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=ACRmhBG9IljYKTXA0ydgCzGDKyAWkwLegAF0dpWezhg=; fh=WCLPHHe9biV/2Xz3UvWPS48CcQrIiFvdTYcyjizavVU=; b=t1F66lGIeAAQmz+TSvCgYT6Ud30ugBoBjeIN+4EOdPZYkqY43Ov5VhBBur8UbQWTFb JD6HqmnNl2g/KRBRFzSbjrftEik4RWpxXECmBxYtzYHxUsaPcY2cYnyxDIwWJkKdB4re P+/5ecuvQaO1F7p+7h6lhqdAlx4wSlpGy/BwpgcNLaXah2bN8I9ZSpaLobdWzzKX8kJA mqaETUFhXqoPu+W8B3W9XgW6BNH+b9p5cdxu7mfxbGELDS7P5vuxZ6Pq+bmFNV84bd09 sdXRsasc5C47YsBWYPxlno3nJWEgTw1AJf2VcMGl4IgHYIEU3TEALsuUizJLyg2Aj7Lg Up4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VXvAkoRL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115263-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115263-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b9-20020a170903228900b001e0b8466f16si2435605plh.293.2024.03.25.03.38.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:38:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115263-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VXvAkoRL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115263-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115263-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A416B2A3D2C for ; Mon, 25 Mar 2024 10:32:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D449412880F; Mon, 25 Mar 2024 01:24:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VXvAkoRL" 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 28C162AE8D5; Sun, 24 Mar 2024 23:57:52 +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=1711324674; cv=none; b=AwlsGYDuZ+jfU4dFK0fbA8c7x0LZhjOB1nnbSGyDoiwIfGHhgOO9xS+c+TB/Rl9Z+ag6bngNNzRQWNLz0efMR0/9KKkr41AmCHwGkVCeH6YXQgODtzN3ywiZaz2kbX4OdhV2bmyVyFl4t8THVkP3NhU17Q+WmWVH1mX+NbxOttk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711324674; c=relaxed/simple; bh=B+hDJSEtZmTKGwjosQVzHLsZ21o1d5mgFIcyszz+X+s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=B9pBO2gC+l9VIVzf7RkUKV4+QhLuzKlX+FjdjR7LbFwHrSYu0O93hlpZRHa1tnccGF3y5Z2U7dZaWOrSuNqBcdxADTW1hp1Zae0DF5jkMv5DW/G+2qbUD8/Wv24KmgUpJpzt8C3aS4/Gzdr5QZnHQhA3BKT1Nh3s/SZu7KyEl7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VXvAkoRL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D5BEC433F1; Sun, 24 Mar 2024 23:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711324672; bh=B+hDJSEtZmTKGwjosQVzHLsZ21o1d5mgFIcyszz+X+s=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=VXvAkoRLMY62I9KFD5orWlj59XGpDkzi5cIA2GMV6QI8b6pBSARWzoatAMQ0GvCzn vuHY/3dprYDZHORzohPbl0n+SRwQ1hgBW70KRHkwFrxA1cl8zL1DIZdwAbnHSfrzJ3 e04as6W54Iug2x/500OYNiVWMrZFFHWBksdlqRRaXahroHaI/YSuPSQINYeERNE0mx 03l13sbMpV0to3E710lPiFc0vzkOJ9iH4NW8XirbabzfczQSIE4/f0A9b4xg352cQc WlnbCdDs2wxSskedMajEpUB6fqmB1OfwrBktVrFzVysV+iak7KdUr8JNCScNQCONYY u5PEGmiByRpXg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2AD25CE11CE; Sun, 24 Mar 2024 16:57:52 -0700 (PDT) Date: Sun, 24 Mar 2024 16:57:52 -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] rcutorture: Make rcutorture support srcu double call test Message-ID: Reply-To: paulmck@kernel.org References: <20240324124224.615-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: <20240324124224.615-1-qiang.zhang1211@gmail.com> On Sun, Mar 24, 2024 at 08:42:24PM +0800, Zqiang wrote: > This commit also allows rcutorture to support srcu double call test > with CONFIG_DEBUG_OBJECTS_RCU_HEAD option enabled. since the spinlock ^ Comma ","? > will be called in call_srcu(), in RT-kernel, the spinlock is sleepable, You lost me on "the spinlock will be called in call_srcu()". > therefore remove disable-irq and disable-preempt protection. > > Signed-off-by: Zqiang Nice! A question below. > --- > kernel/rcu/rcutorture.c | 36 +++++++++++++++++++++--------------- > 1 file changed, 21 insertions(+), 15 deletions(-) > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > index 3f9c3766f52b..6571a69142f8 100644 > --- a/kernel/rcu/rcutorture.c > +++ b/kernel/rcu/rcutorture.c > @@ -388,6 +388,7 @@ struct rcu_torture_ops { > int extendables; > int slow_gps; > int no_pi_lock; > + int debug_objects; > const char *name; > }; > > @@ -573,6 +574,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" > }; > > @@ -743,6 +745,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" > }; > > @@ -782,6 +785,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" > }; > > @@ -3481,35 +3485,37 @@ static void rcu_test_debug_objects(void) > #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD > struct rcu_head rh1; > struct rcu_head rh2; > + int idx; > + > + if (!cur_ops->debug_objects || !cur_ops->call || > + !cur_ops->cb_barrier) If this is built-in, could we please WARN if there is a conflict? Otherwise, it looks like the test succeeded. > + 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. */ What makes us not need this preempt_disable() in the RCU case? > - 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. */ Same question for the local_irq_disable()? > - 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); > + pr_alert("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_%s()\n", KBUILD_MODNAME, cur_ops->name); > #endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ It might be possible to simplify the code by turning this #ifdef into IS_ENABLED(). Thanx, Paul > } > > -- > 2.17.1 >