From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C68A73AFCE3 for ; Tue, 7 Jul 2026 15:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783438590; cv=none; b=ZzVJqOsEe45Hp42vI66UFo0BHIfxNjoA7X21U3pd5ApT0ViBGMdtY9QTn6hjj9QnaoAYjhFGUz7UgS6P0Jdynstew6T8NJcnaggamLiX59ZbXNRL4g1hmRhOkeEtCbvC/fRozaCPpYL82tPb5ceOETYV5s7mKWwTpTLf183ExH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783438590; c=relaxed/simple; bh=my95Fmcmesd2Y5ksKXg/vIpLCrJUuBr+NEnXGVkAhGU=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=RUctk1zczIQHII9kW7L9MNS0/rFOu53xnAfsDPscI+8RJ/qCHw7Ek68Ht5thjGkQygGgOkwAzTYSkmqrDO7s8BaWoqlvp5CwDJKTl9zuxTHMg3Do7g0Z0Dz2yCCeh5zN7P6+EzUYcB+ENmDvtOce2u8JQnlhiJy5zqh0W5chtAM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bcCl/TZb; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bcCl/TZb" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2cc7e86e7aeso29069765ad.2 for ; Tue, 07 Jul 2026 08:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783438588; x=1784043388; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=gAe/B0lmumdTAGULSnGeQVNe6lJ30++GdugJC4/lK/8=; b=bcCl/TZbSVhUvJ5jtze4oHVXIl5CH0QaZBX8Zg0XrYFK5Pn1hrAB4Wrt4WXAsxEgUR DyapMqoTcHYZbmdWd+AznW90ubWBAFa4KtzEYP8xA9jVSq3xKJmLPWdZ2Mbj+Lsn95f6 u0E4mBo7tID0xZbg2EL5bdVvNNF1LN7qYSF3fBhJr3Zj1PBLmfle6tsOz1FfKGzGc78J nF+S44v76F2rTjrYqKSS71ze94A+RPcFAcmEL+JR8QO8GQdygml1EwtCLceieG7rB94K qI33m1vLjmRGmwwODkDMkkG/jVwblmjGXnstSlY/f+pa1rsL2sekqkjGuOb1XarAiV3Q 51MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783438588; x=1784043388; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gAe/B0lmumdTAGULSnGeQVNe6lJ30++GdugJC4/lK/8=; b=YaniWHEmNdzIBJex39gEl8hQJLQDSd2IIl/GhGMHzSKs/w2MebG+lCkLj7pV89KliM p++OeF/tqiHEtT6bh06h36twuUH5T8kywQ/hbkkbLBQfbcXVf6nPWnJxdSLavIE/ErwB Q2EvtHed6GPvkFY+ScFk8UcOOYKauUciVHdglFSp7Z7ebzp5U2kbMpSMjxjoUqj5+unp hPyFppfiy/aU0Nm8GymieVWJpqeAxqm5eF8XUh023Wsq3yu9YL+90x6Qb6x8s4n9Sjcl NhL6JHUQ6rZBGwnAId8bXPmMOE1Nv2CugRLcLF0RsEvpy0V+Eo7V4vsqzQVDgXDjYlMk k8kQ== X-Forwarded-Encrypted: i=1; AHgh+RqUGSHUH5Mg6WOjE+qPp52PBL25Q3kwRV6HAKJQOGgs6/IFExubj5fISCC5v8sB+gR2NFwgp2o7/vEvKfk=@vger.kernel.org X-Gm-Message-State: AOJu0YyVvYIHu6voG5WVFnrySg1hKotnls+5DxRmToJv5tfkAmzzQRYZ uiCKws7leyRmXG1ZK/jQ82IJDy/Hcn9LrtUTVBKKKd2DCtFkgtov4Lbh X-Gm-Gg: AfdE7ckP+Be9NDmJocVvCAJMCEFGePLePBhMV8go6LbP1Z7fbCuQXjYxLtrjgTMcJWK 8TkI7qdVY/W0hr8+vEQ3lWaP0x1CwvkCENLILdLfXMYLNfnJkv+J7lJWxBcUPLRm3iEodLHb4BL HGhzm3uiEmCj157za3+YJaEPHf2dbEE9Sj+LLK+KHLQotpe4KIE1Z2oasrkATd543VOvwiYxA2n UGElSAM8QL8xgnYjc4OocVuQZTfZY0thllDqesfkYFmY2M9ZBEsnwherOw9NIUXXoHvZoIImgJ4 GqIXzorXxdCtXLZHTNAxoP1PRyJkqKmvGYoLCmJ/6jdLH98YRBmbVyjsTSRZqIKKNIHWI7VyIig a1ILt/tfaDUcooClb9OiOQkm3Y+0JCZzuENWFGFyr9W8lhDj8o+FNzcop08owihq1o3G6dheIpG FNt087QA== X-Received: by 2002:a17:903:3550:b0:2c0:b6c7:227e with SMTP id d9443c01a7336-2ccbe3f2606mr55794045ad.5.1783438587925; Tue, 07 Jul 2026 08:36:27 -0700 (PDT) Received: from smtpclient.apple ([2402:d0c0:11:86::1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9d1e1aesm14494315ad.39.2026.07.07.08.36.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2026 08:36:26 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH] rcutorture: Use __set_current_state() set task state in rcu_nocb_toggle() From: Alan Huang In-Reply-To: Date: Tue, 7 Jul 2026 23:36:18 +0800 Cc: Zqiang , frederic@kernel.org, neeraj.upadhyay@kernel.org, joelagnelf@nvidia.com, urezki@gmail.com, boqun@kernel.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <80CDCF49-23F7-4CA5-80C4-9295DCE0D5EE@gmail.com> References: <20260702101125.14100-1-qiang.zhang@linux.dev> To: paulmck@kernel.org X-Mailer: Apple Mail (2.3864.600.51.1.1) On Jul 7, 2026, at 02:48, Paul E. McKenney wrote: > > On Thu, Jul 02, 2026 at 06:11:25PM +0800, Zqiang wrote: >> In the rcu_nocb_toggle(), the schedule_hrtimeout() is called after the >> state assignment with no condition check. the release-acquire pair from >> raw_spin_unlock/lock(&cpu_base->lock), guarantee that task->__state is >> visible to the hrtimer callback: >> >> CPU0 CPU1 >> __set_current_state(TASK_INTERRUPTIBLE) >> ->WRITE_ONCE(task->__state, TASK_INTERRUPTIBLE) >> schedule_hrtimeout >> ->hrtimer_sleeper_start_expires() >> ->raw_spin_lock_irqsave(&cpu_base->lock) >> .... >> ->raw_spin_unlock_irqrestore(&cpu_base->lock) >> >> hard-irq: >> raw_spin_lock_irqsave(&cpu_base->lock) >> __hrtimer_run_queues >> ->__run_hrtimer >> ->raw_spin_unlock_irqrestore(&cpu_base->lock) >> ->fn(timer) >> ->hrtimer_wakeup >> ->wake_up_process >> ->try_to_wake_up >> ->READ task->__state >> >> This commit therefore use the __set_current_state() to replace the >> set_current_state() in rcu_nocb_toggle(). >> >> Signed-off-by: Zqiang > > This looks correct, and either drops an smp_mb() or converts an > xchg() to a WRITE_ONCE(), which does decrease overhead. Except that > rcu_nocb_toggle() is invoked very infrequently and has high overhead > that I would expect to lose this overhead decrease in the noise. And it > forces those reading the code to go figure out what is different between Agreed. I did end up reading the code. > set_current_state() and __set_current_state(). > > So I am not convinced to take this patch. But am I missing something here? > > Thanx, Paul > >> --- >> 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 b1bab59efde5..a0e6901e0f90 100644 >> --- a/kernel/rcu/rcutorture.c >> +++ b/kernel/rcu/rcutorture.c >> @@ -2947,7 +2947,7 @@ static int rcu_nocb_toggle(void *arg) >> atomic_long_inc(&n_nocb_deoffload); >> } >> toggle_delay = torture_random(&rand) % toggle_fuzz + toggle_interval; >> - set_current_state(TASK_INTERRUPTIBLE); >> + __set_current_state(TASK_INTERRUPTIBLE); >> schedule_hrtimeout(&toggle_delay, HRTIMER_MODE_REL); >> if (stutter_wait("rcu_nocb_toggle")) >> sched_set_normal(current, oldnice); >> -- >> 2.17.1 >> >