mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: paulmck@kernel.org, Joel Fernandes <joel@joelfernandes.org>
Cc: linux-kernel@vger.kernel.org,
	Frederic Weisbecker <frederic@kernel.org>,
	Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang@linux.dev>,
	Uladzislau Rezki <urezki@gmail.com>,
	rcu@vger.kernel.org
Subject: Re: [PATCH RFC 00/14] rcu: Reduce rnp->lock contention with per-CPU blocked task lists
Date: Tue, 6 Jan 2026 16:24:07 -0500	[thread overview]
Message-ID: <fa4d2f13-2fc1-4f2a-983d-66414b8ebb2d@nvidia.com> (raw)
In-Reply-To: <a40f5831-ae62-4d16-8a7b-b6adb2a59aa8@paulmck-laptop>



On 1/6/2026 2:24 PM, Paul E. McKenney wrote:
> On Tue, Jan 06, 2026 at 10:08:51AM -0500, Joel Fernandes wrote:
>>
>>
>> On 1/5/2026 7:55 PM, Joel Fernandes wrote:
>>>> Also if so, would the following rather simpler patch do the same trick,
>>>> if accompanied by CONFIG_RCU_FANOUT_LEAF=1?
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
>>>> index 6a319e2926589..04dbee983b37d 100644
>>>> --- a/kernel/rcu/Kconfig
>>>> +++ b/kernel/rcu/Kconfig
>>>> @@ -198,9 +198,9 @@ config RCU_FANOUT
>>>>  
>>>>  config RCU_FANOUT_LEAF
>>>>  	int "Tree-based hierarchical RCU leaf-level fanout value"
>>>> -	range 2 64 if 64BIT && !RCU_STRICT_GRACE_PERIOD
>>>> -	range 2 32 if !64BIT && !RCU_STRICT_GRACE_PERIOD
>>>> -	range 2 3 if RCU_STRICT_GRACE_PERIOD
>>>> +	range 1 64 if 64BIT && !RCU_STRICT_GRACE_PERIOD
>>>> +	range 1 32 if !64BIT && !RCU_STRICT_GRACE_PERIOD
>>>> +	range 1 3 if RCU_STRICT_GRACE_PERIOD
>>>>  	depends on TREE_RCU && RCU_EXPERT>  	default 16 if !RCU_STRICT_GRACE_PERIOD
>>>>  	default 2 if RCU_STRICT_GRACE_PERIOD
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> This passes a quick 20-minute rcutorture smoke test.  Does it provide
>>>> similar performance benefits?
>>>
>>> I tried this out, and it also brings down the contention and solves the problem
>>> I saw (in testing so far).
>>>
>>> Would this work also if the test had grace periods init/cleanup racing with
>>> preempted RCU read-side critical sections? I'm doing longer tests now to see how
>>> this performs under GP-stress, versus my solution. I am also seeing that with
>>> just the node lists, not per-cpu list, I see a dramatic throughput drop after
>>> some amount of time, but I can't explain it. And I do not see this with the
>>> per-cpu list solution (I'm currently testing if I see the same throughput drop
>>> with the fan-out solution you proposed).
>>>
>>> I'm also wondering whether relying on the user to set FANOUT_LEAF to 1 is
>>> reasonable, considering this is not a default. Are you suggesting defaulting to
>>> this for small systems? If not, then I guess the optimization will not be
>>> enabled by default. Eventually, with this patch set, if we are moving forward
>>> with this approach, I will remove the config option for per-CPU block list
>>> altogether so that it is enabled by default. That's kind of my plan if we agreed
>>> on this, but it is just an RFC stage 🙂.
>>
>> So the fanout solution works great when there are grace periods in progress. I
>> see no throughput drop, and consistent performance with read site critical
>> sections. However, if we switch to having no grace periods continuously
>> happening in progress, I can see the throughput dropping quite a bit here
>> (-30%). I can't explain that, but I do not see that issue with per-CPU lists.
> 
> Might this be due to the change in number of tasks?  Not having the
> thread that continuously runs grace periods might be affecting scheduling
> decisions, and with CPU overcommit, those scheduling decisions can cause
> large changes in throughput.  Plus there are other spinlocks that might
> be subject to vCPU preemption, including the various scheduler spinlocks.

Yeah these are all possible, currently studying it more :)
>> With the per-cpu list scheme, blocking does not involve the node at all, as long
>> as there is no grace period in progress. So, in that sense, per-CPU blocked list
>> is completely detached from RCU - it is a bit like lazy RCU in the sense instead
>> of a callback, it is the blocking task in a per-cpu list, relieving RCU of the
>> burden.
> 
> Unless I am seriously misreading your patch, the grace-period kthread still
> acquires your per-CPU locks.

Yes, but I am not triggering grace periods (in the tests where I am expecting an
improvement). It is in those tests that I am seeing the throughput drop with
FANOUT, but let me confirm that again. I did run it 200 times and notice this.
I'm not sure what else a fanout of one for leaves does, but this is my chance to
learn about it :).

I am saying when there is no GPs active (that is when the optimization in these
patches is active). In one of the patches, if grace period is in progress or
already started, I do not trigger the optimization. The optimization is only
when grace periods are not active. This is similar to lazy RCU, where, if we
have active grace periods in progress, we don't really make new RCU callbacks
lazy since it is pointless.

> Also, reducing the number of grace periods> should *reduce* contention on the
rcu_node ->lock.
> 
>> Maybe the extra layer of the node tree (with fanout == 1) somehow adds
>> unnecessary overhead that does not exist with Per CPU lists? Even though there
>> is this throughput drop, it still does better than baseline with a common RCU node.
>>
>> Based on this, I would say per-cpu blocked list is still worth doing. Thoughts?
> 
> I think that we need to understand the differences before jumping
> to conclusions.  There are a lot of possible reasons for changes in
> throughput, especially given the CPU overload.  After all, queuing
> theory suggests high variance in that case, possibly even on exactly
> the same setup.

Sure, that's why I'm doing hundreds of runs to get repetitive results and cut
back on the outliers. But it is quite challenging to study all possibilities
given the time constraints. I'm trying to collect traces as much as I can and
study them. The synchronize RCU latency that I just improved, for instance, came
from one of such exercises.

Thanks.


  reply	other threads:[~2026-01-06 21:24 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-03  0:23 Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 01/14] rcu: Add WARN_ON_ONCE for blocked flag invariant in exit_rcu() Joel Fernandes
2026-01-05 15:31   ` Steven Rostedt
2026-01-05 15:44     ` Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 02/14] rcu: Add per-CPU blocked task lists for PREEMPT_RCU Joel Fernandes
2026-01-05 15:48   ` Steven Rostedt
2026-01-03  0:23 ` [PATCH RFC 03/14] rcu: Early return during unlock for tasks only on per-CPU blocked list Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 04/14] rcu: Promote blocked tasks from per-CPU to rnp lists Joel Fernandes
2026-01-05 15:59   ` Steven Rostedt
2026-01-09  3:52     ` Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 05/14] rcu: Promote blocked tasks for expedited GPs Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 06/14] rcu: Promote per-CPU blocked tasks before checking for blocked readers Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 07/14] rcu: Promote late-arriving blocked tasks before reporting QS Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 08/14] rcu: Promote blocked tasks before QS report in force_qs_rnp() Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 09/14] rcu: Promote blocked tasks before QS report in rcutree_report_cpu_dead() Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 10/14] rcu: Promote blocked tasks before QS report in rcu_gp_init() Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 11/14] rcu: Add per-CPU blocked list check in exit_rcu() Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 12/14] rcu: Skip per-CPU list addition when GP already started Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 13/14] rcu: Skip rnp addition when no grace period waiting Joel Fernandes
2026-01-03  0:23 ` [PATCH RFC 14/14] rcu: Remove checking of per-cpu blocked list against the node list Joel Fernandes
2026-01-05 16:46 ` [PATCH RFC 00/14] rcu: Reduce rnp->lock contention with per-CPU blocked task lists Paul E. McKenney
2026-01-06  0:55   ` Joel Fernandes
2026-01-06 15:08     ` Joel Fernandes
2026-01-06 19:24       ` Paul E. McKenney
2026-01-06 21:24         ` Joel Fernandes [this message]
2026-01-09  2:00           ` Paul E. McKenney
2026-01-06 19:17     ` Paul E. McKenney
2026-01-06 20:19       ` Steven Rostedt
2026-01-06 20:35         ` Paul E. McKenney
2026-01-06 20:49           ` Joel Fernandes
2026-01-09  1:55             ` Paul E. McKenney
2026-01-06 20:40       ` Joel Fernandes
2026-01-09  1:52         ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa4d2f13-2fc1-4f2a-983d-66414b8ebb2d@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=boqun.feng@gmail.com \
    --cc=frederic@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang@linux.dev \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®