From nobody Sat Jun 13 07:51:40 2026 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 D4820410D34; Fri, 8 May 2026 17:43:56 +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=1778262236; cv=none; b=ZGxSxsnmV9Xx5KsASWEJdStz4togjNVXRLjrQW3XzoI2Lvyc1xKSyKqvj5cD1Lb0TjMu26fbY+U1BVWglBTfR/MDocJMKIzcw0XMU17TdImzePZs8CCbVsfX4pkTlklLwOIDfu4hts6s9kEF6jrXdit/hP15opUjD46+TR3ALNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778262236; c=relaxed/simple; bh=jDUIv5GSBmuhjUG+/Jy9X5I9h/1y72j84vtbUTmUpHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZldCUw12Qt6lZk8sqKm2vhAHcmfBCS+5qtjIVugGfoHLulyoZkrSaiuYeBXk5T1kw8ErudYe4X21aH4667vGojRamKhftUhe++fqKWLufx01yP13UGSZh4+bpGqF7wZXmr9Wyy3zIidwIoQI18DZzTBLnFRgBp3TGhixi6PNBHQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KFZx9di3; 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="KFZx9di3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 885ACC2BCF5; Fri, 8 May 2026 17:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778262236; bh=jDUIv5GSBmuhjUG+/Jy9X5I9h/1y72j84vtbUTmUpHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFZx9di3wLDvmp1C5rKrvLZJLcJ+8sK3MDJPd0lT5F8kyYHTH569IQKASvKh3YEAH xVXeb7upCPcL6E5LeWKqcws2ZjGcye89yoLeauLHMrXt/6qGPtpMN3ON2fSYhISkfV skhsodm+fGMpq6dD8qav5Hf00InSIDclYYur9Uat6aM30UzUSdJPfKM569aUGglyw+ 4azmUSV9iw43/13JpmVQABrrnQTw2eyXKqaae/WGFjoI9XTJqCImSEn+EnrGJhXMhs OdnvILxfySkp5cwLzNNyYmD8vP3+d2FyhAAOD8HzR35zHMmNret0BtpD7o/mt3LmYM wuQupiwsZIR/A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3AD99CE06FB; Fri, 8 May 2026 10:43:56 -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" , Vasily Gorbik , Samir , Shrikanth Hegde , Tejun Heo Subject: [PATCH v2 1/6] srcu: Don't queue workqueue handlers to never-online CPUs Date: Fri, 8 May 2026 10:43:48 -0700 Message-Id: <20260508174353.905746-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> References: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While an srcu_struct structure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not in cpu_possible_mask. This can cause hangs on s390, which is not set up to deal with workqueue handlers being scheduled on such CPUs. This commit therefore causes Tree SRCU to refrain from queueing workqueue handlers on CPUs that have not yet (and might never) come online. Because callbacks are not invoked on CPUs that have not been online, it is an error to invoke call_srcu(), synchronize_srcu(), or synchronize_srcu_expedited() on a CPU that is not yet fully online. However, it turns out to be less code to redirect the callbacks from too-early invocations of call_srcu() than to warn about such invocations. This commit therefore also redirects callbacks queued on not-yet-fully-online CPUs to the boot CPU. Reported-by: Vasily Gorbik Fixes: 61bbcfb50514 ("srcu: Push srcu_node allocation to GP when non-preemp= tible") Signed-off-by: Paul E. McKenney Tested-by: Vasily Gorbik Tested-by: Samir Reviewed-by: Shrikanth Hegde Cc: Tejun Heo --- kernel/rcu/srcutree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 0d01cd8c4b4a7b..7c2f7cc131f7ae 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -897,11 +897,9 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *= ssp, struct srcu_node *snp { int cpu; =20 - for (cpu =3D snp->grplo; cpu <=3D snp->grphi; cpu++) { - if (!(mask & (1UL << (cpu - snp->grplo)))) - continue; - srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay); - } + for (cpu =3D snp->grplo; cpu <=3D snp->grphi; cpu++) + if ((mask & (1UL << (cpu - snp->grplo))) && rcu_cpu_beenfullyonline(cpu)) + srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay); } =20 /* @@ -1322,7 +1320,9 @@ static unsigned long srcu_gp_start_if_needed(struct s= rcu_struct *ssp, */ idx =3D __srcu_read_lock_nmisafe(ssp); ss_state =3D smp_load_acquire(&ssp->srcu_sup->srcu_size_state); - if (ss_state < SRCU_SIZE_WAIT_CALL) + // If !rcu_cpu_beenfullyonline(), interrupts are still disabled, + // so no migration is possible in either direction from this CPU. + if (ss_state < SRCU_SIZE_WAIT_CALL || !rcu_cpu_beenfullyonline(raw_smp_pr= ocessor_id())) sdp =3D per_cpu_ptr(ssp->sda, get_boot_cpu_id()); else sdp =3D raw_cpu_ptr(ssp->sda); --=20 2.40.1 From nobody Sat Jun 13 07:51:40 2026 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 D48BB410D3D; Fri, 8 May 2026 17:43:56 +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=1778262236; cv=none; b=NpS/9OTTIknlzmg4BfO1qUpfP4Yf2dWbtkhiWTC9wqBQxveCpUloobweH7P4VwBQOLtPSHyXjxSKWYy79VJ4j/ZDpJjDChFv5to4JMjiPNG13mdCdvaJgjKDG9zP0zevWPIzFcSZvisC/zTFpwTWqImuXG9p+c4EU5epAB2MLqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778262236; c=relaxed/simple; bh=/Y++xnjbRpcunrSUKXCI4237l43LWEtuXPunx3ckXv4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=m+IBJpnB6e9eYfjYUkwC9EKUdDgMElWLQaiwAy+vD79+xg+JeDShrLb+lUB0HtbT/LKhXJykMSS76a5ppOikg4pcUknUfOeOY2z3gOgB29HDYvqiLbxqe0bOA1RL0VD3K8ApkeCM6+gf/x6F074/HrpmNlYc++NO5+cugd5iskY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tje978lL; 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="tje978lL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96790C2BCF6; Fri, 8 May 2026 17:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778262236; bh=/Y++xnjbRpcunrSUKXCI4237l43LWEtuXPunx3ckXv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tje978lLKSftcyBje+2oii3H/okJYfU5doS2t0hHegaB8GZeIzLW+CIX9AIfxKcmb U7gHhyAQaJ15qNf1OcmsQ2d3qV6udNuBHUyjMsZQHcmh7Hodhi97Fq9aQCmnMQbssF 4nycc9AiEsLangZl84+8Z11KfoXi/c/PVbkRpLvcXfPre8d1UA5CCuZvwGUd6QfybD FmDXSdXGEfIhALImfC0ynXmugusNfazZ0LCt/gZgxwYR243qDU5rHcopM3GXZMJAd1 l8/8GETTs3P2ZoW7Z/rkGjcCrhCUWCGkv6My7EKmjFfRlfyGgF+FT8iL9XIMekAAbb +64O3siEREgpw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3DA7ACE0863; Fri, 8 May 2026 10:43:56 -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 v2 2/6] srcu: Fix kerneldoc header comment typo in srcu_down_read_fast() Date: Fri, 8 May 2026 10:43:49 -0700 Message-Id: <20260508174353.905746-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> References: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" s/srcu_read_lock_safe()/srcu_read_lock_fast_updown(), there being no such thing as srcu_read_lock_safe(). Signed-off-by: Paul E. McKenney --- include/linux/srcu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/srcu.h b/include/linux/srcu.h index 81b1938512d5d1..a54ce9e808b92c 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -397,7 +397,7 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_= fast_notrace(struct srcu_ * * The same srcu_struct may be used concurrently by srcu_down_read_fast() * and srcu_read_lock_fast(). However, the same definition/initialization - * requirements called out for srcu_read_lock_safe() apply. + * requirements called out for srcu_read_lock_fast_updown() apply. */ static inline struct srcu_ctr __percpu *srcu_down_read_fast(struct srcu_st= ruct *ssp) __acquires_shared(ssp) { --=20 2.40.1 From nobody Sat Jun 13 07:51:40 2026 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 D478A407573; Fri, 8 May 2026 17:43:56 +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=1778262236; cv=none; b=O2XH73xzUSzCfJA6zSYOt1z9Qj9xPKvL4XMoF7K6tqhNyK7lfBGYcd/11Aetx82CHCCKa2VewFeygMUu5ZF5xDew29AMX405CjU9GLLoE+Zc8BBCcKLd20W3Np7wU+qzCglnTN/aPt3lGSbhwXiGwEBIIxtrG6h9SANFJOrtBk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778262236; c=relaxed/simple; bh=bK0caIrz9kRi5yHZgG08qzzOGCM4PuqQ6vEGFPiFY94=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rD721CkU9k4TPGNPMsjv1GLHK0T5SO02dlo2Gn40cgxaiAge6x/rqHAjVSwJEgD4RmIWrFXlaMKV8SyKH5ug8jHmfmuzWJtSYwb0IydIMzrkcrh4pNr/8uHHYZKMgDknYEu9IlidnaukvTtVC36fBgcLRds78EPqw7q1tdCCG08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LR405yhb; 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="LR405yhb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C096C2BCFA; Fri, 8 May 2026 17:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778262236; bh=bK0caIrz9kRi5yHZgG08qzzOGCM4PuqQ6vEGFPiFY94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LR405yhbrTwoAbgoQ/1yGIBGb21tLPLKpMu8BPmGAtCnntetoigYmlUTUX0lxVAN7 0x+x8wgzjoHkurCh77DTdDcSxSKAmmV0szoUi77ND4NA9b5OpUTNHlF3cIQrA8Sqlm Dk3F9TiqZQ8RpSE7v13JfAlu7YpHUWLpRIl4CWjvpu8zpDli4h+KI2Z8lMLexw/fAR EtV2T0kJ6Hh0Vmf8HEhA3dP5pmmvN1JG/wkSVN6J2mKusGUZbyBXFWaggAmt3AFZtJ XPgjlDhd9nFsqhjDSqJ0NVZmdeoNSpQPlBUQqXstT1EG94T4xI51iefdD6ka8g++8F yZ0onPh36yy3g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 40DA6CE08B6; Fri, 8 May 2026 10:43:56 -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" , Puranjay Mohan , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v2 3/6] checkpatch: Undeprecate rcu_read_lock_trace() and rcu_read_unlock_trace() Date: Fri, 8 May 2026 10:43:50 -0700 Message-Id: <20260508174353.905746-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> References: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It turns out that there are BPF use cases that rely on nesting RCU Tasks Trace readers. These use cases are well-served by the old rcu_read_lock_trace() and rcu_read_unlock_trace() functions that maintain a nesting counter in the task_struct structure. But these use cases incur a performance penalty when using the shiny new rcu_read_lock_tasks_trace() and rcu_read_unlock_tasks_trace() functions, which nest in the same way that SRCU does. This means that rcu_read_lock_trace() and rcu_read_unlock_trace() will be with us for some time. Therefore, remove the checkpatch.pl deprecation. Also, the rcu_read_lock_tasks_trace() and rcu_read_unlock_tasks_trace() functions are intended for use only by BPF. Therefore, add them to the list of functions that checkpatch complains about outside of BPF (and of course, RCU). Reported-by: Puranjay Mohan Signed-off-by: Paul E. McKenney Cc: Andy Whitcroft Cc: Joe Perches Cc: Dwaipayan Ray Cc: Lukas Bulwahn --- scripts/checkpatch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0492d6afc9a1fc..cc5bbd70cb843e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -865,8 +865,6 @@ our %deprecated_apis =3D ( "DEFINE_IDR" =3D> "DEFINE_XARRAY", "idr_init" =3D> "xa_init", "idr_init_base" =3D> "xa_init_flags", - "rcu_read_lock_trace" =3D> "rcu_read_lock_tasks_trace", - "rcu_read_unlock_trace" =3D> "rcu_read_unlock_tasks_trace", ); =20 #Create a search pattern for all these strings to speed up a loop below @@ -7596,12 +7594,15 @@ sub process { =20 # Complain about RCU Tasks Trace used outside of BPF (and of course, RCU). our $rcu_trace_funcs =3D qr{(?x: + rcu_read_lock_tasks_trace | rcu_read_lock_trace | rcu_read_lock_trace_held | rcu_read_unlock_trace | + rcu_read_unlock_tasks_trace | call_rcu_tasks_trace | synchronize_rcu_tasks_trace | rcu_barrier_tasks_trace | + rcu_tasks_trace_expedite_current | rcu_request_urgent_qs_task )}; our $rcu_trace_paths =3D qr{(?x: --=20 2.40.1 From nobody Sat Jun 13 07:51:40 2026 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 E5C32413227; Fri, 8 May 2026 17:43:56 +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=1778262237; cv=none; b=P70KgdrVdmTEvrSTIoqKPuBv5Rsy+o+YSyDx9Y14HufIROcZbChA+GCvHj88/WI6Udy1pCnquvF+ae/jXavEH9z+Jrgy/YJzaBtpyil/oUwekojdouphNOlfLl/v9uJB2E7UquCXlpURgvQBu3PmpYxkStEGBmxMCDimwI5VDZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778262237; c=relaxed/simple; bh=dn0eKgumMKWPgv8A6Qf9JhTroZyknKKkxSEsAf1Np/I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FtW8rpu3lP/iQuFKXH+J0VOY9IK4RQnN+hOuATJtsmYTrqQqqnwqPqkxzMrMc8gbGDbl1XGiCJ3QHIiVfI0o9jFef2cZLXjtjlAB1RhkraoP4+Begkltbm019L9AAMjSbRZhyuWykzvmcsMbZhdeZ4r/awqYDRIuCRI2ZWuYBm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DuEHUUOT; 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="DuEHUUOT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD6FFC2BCFC; Fri, 8 May 2026 17:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778262236; bh=dn0eKgumMKWPgv8A6Qf9JhTroZyknKKkxSEsAf1Np/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DuEHUUOTbxXVyny+lmkazWLIY1UIPqCOlqgZK7Buvekb43oaPpvh3QUksmuaeIgB7 +VEM8DmgnolCnpVOgWySzw/T0hL0hRjyJ4fD6Xu6UPWkkR7nHj8UkNnDFipbtlOMBV j+7QoQq5l9cFzqPfLt+5XBFDGfml/2HBY9XzT8Q+BeMFtJpRUc8HoS9MhFjoLc/q1r OnsAXcES/yzrxaAvTutYwLhCbvRlz5qWk7aKY9WDn9Y8KJ8NmbiTp0rtr8CJPz0ayh 03wSmyatuGkqpgdbKHgCoMj6jLRASlXZEeQolcyoCOpJtIxmiZIb6QRXq4/vXsZrRE jKdwoWwpxzNaQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 43569CE0B15; Fri, 8 May 2026 10:43:56 -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 v2 4/6] rcu: Simplify rcu_do_batch() by applying clamp() Date: Fri, 8 May 2026 10:43:51 -0700 Message-Id: <20260508174353.905746-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> References: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This commit replaces a nested ?: sequence with clamp(). This does not reduce the number of lines of code, but it does simplify the line that it modifies. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 55df6d37145e87..e46a5124c3eb88 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2584,7 +2584,7 @@ static void rcu_do_batch(struct rcu_data *rdp) const long npj =3D NSEC_PER_SEC / HZ; long rrn =3D READ_ONCE(rcu_resched_ns); =20 - rrn =3D rrn < NSEC_PER_MSEC ? NSEC_PER_MSEC : rrn > NSEC_PER_SEC ? NSEC_= PER_SEC : rrn; + rrn =3D clamp(rrn, NSEC_PER_MSEC, NSEC_PER_SEC); tlimit =3D local_clock() + rrn; jlimit =3D jiffies + (rrn + npj + 1) / npj; jlimit_check =3D true; --=20 2.40.1 From nobody Sat Jun 13 07:51:40 2026 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 E5B25413220; Fri, 8 May 2026 17:43:56 +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=1778262237; cv=none; b=g2TlN4oakXFyoJhzeiaXYGT6m1kh+kugoROZ9tObKN6cDH0PbZkKHArUHu2byzbCECDmCjSjI8/S3zC1wmp9XDr0RcImwFbCxWejGQfB8GWOki5KkUNlmUrGfa9cOyv2rOKT+Rm/a8+U+G0AOqC+3kgZ/aa460uRzz7SKsJy9uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778262237; c=relaxed/simple; bh=Ju+wGquknA9vH4d8msEHqAowyOOhmN7jnTkXKOHQ2O0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iI7tQG6PDO04xQO8wjDA/pu97BrDCfU0QirJtUIXHpmhrTc4mbjb+8pz5PML/N7bsMzHjQ1BYGleBr4IVpSwgVRgdcKufs8Ru8cAQXyYwwHTMiLXjWSLgLO8gjeR/BLdD3oN3NbSnaj4ZSMqGMsshDSzc49bAJMlw3859PYtEAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gNFOo/Ng; 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="gNFOo/Ng" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C39BCC2BD00; Fri, 8 May 2026 17:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778262236; bh=Ju+wGquknA9vH4d8msEHqAowyOOhmN7jnTkXKOHQ2O0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNFOo/NgnJlFtaGTQ8E6ByezEjtaiDmKCNdMOOLo0oWWINjsTfYS30tZGRo0EX0dT BCumnYiLBetPRSGFHBch42qjwDtRSWOvdkNhictc8Da0lbs+NgDzkm3vp64T42fzFB Xf/V3F6YNbabxzLVrkXONzN3zvDvVsHU1WZY5f8PQfD87ISMubieDNWykJ0c/FutaF wTR1Wdc9G3UB2Ix6aXrpeB7gIMn8c6TAR6b0EWLphsIIt0u+/ajJqetPp+HjSNWLdH xIWnyRfPovV5IL0vVmRzMFwHF8id3SXn4SPUj4JpeKhrOz8hjWu33Kifm6U3segIwk 9jdXcm/YIALtA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 45DD4CE0C96; Fri, 8 May 2026 10:43:56 -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 v2 5/6] rcu: Simplify param_set_next_fqs_jiffies() by applying clamp_val() Date: Fri, 8 May 2026 10:43:52 -0700 Message-Id: <20260508174353.905746-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> References: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This commit replaces a nested ?: sequence with clamp_val(). This does not reduce the number of lines of code, but it does simplify the line that it modifies. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index e46a5124c3eb88..09f0cef5014c7c 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -492,7 +492,7 @@ static int param_set_next_fqs_jiffies(const char *val, = const struct kernel_param int ret =3D kstrtoul(val, 0, &j); =20 if (!ret) { - WRITE_ONCE(*(ulong *)kp->arg, (j > HZ) ? HZ : (j ?: 1)); + WRITE_ONCE(*(ulong *)kp->arg, clamp_val(j, 1, HZ)); adjust_jiffies_till_sched_qs(); } return ret; --=20 2.40.1 From nobody Sat Jun 13 07:51:40 2026 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 17D6D41325B; Fri, 8 May 2026 17:43:57 +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=1778262237; cv=none; b=Q9qOCzwofmUrJ8CCdoWK35hZK9ZpWNs25jNtbK2w+81rjKslHkCY/hqu4aAo9DXEDf2yfMTcz6m9q4ed2zYzGS+u2egiW3paLL7mqXKvlbb1s1doX3HNDb15Uxja7Q04o9Ec6zNwEHGFvqCQLSGLqDrjsIA4LAj+rjRBr1OvGv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778262237; c=relaxed/simple; bh=wFT/i1ySNxXzoubSoSgzPm8HS2drPU39EeIV8Pogu1k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VDLHiCRJGxakqlE5M2xgNBarZV1SV817zOkP6dCEzdb0P7qg93pJ4zAu8rHZsJ7BNqd6fhB1C6a+maE1Kc/+e3D0BysvvZIiP2KSr3IzjAUW6m4ZcQ5ffqbvDr6tVFbvWAxMOkeKq6fNtNKYfSTT2vekMnU9+ocCMdGUiGc8geQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ToZd2sJK; 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="ToZd2sJK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1473C2BCF7; Fri, 8 May 2026 17:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778262237; bh=wFT/i1ySNxXzoubSoSgzPm8HS2drPU39EeIV8Pogu1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToZd2sJKDnT440LoB4BH6H/AehKkL9XjxFstWQY6MrIbbKjnY1KHIzTriZw2fFW7x MUViRX3C1sM8Xy6si62d0Pvrlky4+DWsD+jo/xvGX7VjoGn97YDMfIfplNj+bYWkyo qYJFcxlDMennGwZBmI3AcAFigdli3DXbzRm+KaS3VrK2FxI0P/l1pc+BCeL4DrstZc pgefC3B/dUjoEV+xUJvc8v8r05mWTd4ZbRku541I/lovgIMAf+/HScFzkFJEE8k6FZ yc+mYhQ4+nnqeRnwZ8SYTfHlZk1VDsF8+VLt3sFfLVTiv7I+mcUqSl0sP77wXpTDLp mxu/PkVRFkL9w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 48445CE0D3B; Fri, 8 May 2026 10:43:56 -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" , Maxim Mikityanskiy Subject: [PATCH v2 6/6] rcu: Document rcu_access_pointer() feeding into cmpxchg() Date: Fri, 8 May 2026 10:43:53 -0700 Message-Id: <20260508174353.905746-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> References: <40ed4910-e20b-40a6-9598-7aa6abf006c5@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This commit documents the rcu_access_pointer() use case for fetching the old value of an RCU-protected pointer within a lockless updater for use by an atomic cmpxchg() operation. Reported-by: Maxim Mikityanskiy Signed-off-by: Paul E. McKenney --- include/linux/rcupdate.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index bfa765132de858..5e95acc33989b6 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -592,11 +592,13 @@ context_unsafe( \ * lockdep checks for being in an RCU read-side critical section. This is * useful when the value of this pointer is accessed, but the pointer is * not dereferenced, for example, when testing an RCU-protected pointer - * against NULL. Although rcu_access_pointer() may also be used in cases - * where update-side locks prevent the value of the pointer from changing, - * you should instead use rcu_dereference_protected() for this use case. - * Within an RCU read-side critical section, there is little reason to - * use rcu_access_pointer(). + * against NULL. Within an RCU read-side critical section, there is little + * reason to use rcu_access_pointer(). Although rcu_access_pointer() may + * also be used in cases where update-side locks prevent the value of the + * pointer from changing, you should instead use rcu_dereference_protected= () + * for this use case. It is also permissible to use rcu_access_pointer() + * within lockless updaters to obtain the old value for an atomic operatio= n, + * for example, for cmpxchg(). * * It is usually best to test the rcu_access_pointer() return value * directly in order to avoid accidental dereferences being introduced --=20 2.40.1