mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: paulmck@kernel.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@kernel.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang@linux.dev>,
	Davidlohr Bueso <dave@stgolabs.net>,
	rcu@vger.kernel.org
Subject: Re: [PATCH v4 5/8] rcu: clear defer_qs_pending at expedited IPI entry
Date: Tue, 21 Jul 2026 11:55:39 -0400	[thread overview]
Message-ID: <3dc26b07-ac80-467a-856b-0fe2c2000df6@nvidia.com> (raw)
In-Reply-To: <fc902af8-4e2f-4e23-834e-6d00fa85c06c@paulmck-laptop>

Hi Paul,

On 7/15/2026 5:01 PM, Paul E. McKenney wrote:
> On Thu, Jun 25, 2026 at 08:42:58PM -0400, Joel Fernandes wrote:
>> The per-CPU clear in __note_gp_changes() (from an earlier commit)
>> runs only when the local CPU notices a normal-GP advance.  When an
>> expedited GP arrives at a CPU whose defer_qs_pending is already
>> PENDING, rcu_read_unlock_special() may skip irq_work queuing due to the
>> pending gate.
>>
>> Clear defer_qs_pending on the IPI target right in rcu_exp_handler().
>> This makes it possible for any arming attempt that follows
>> the IPI within the current GP to be able to queue irq_work again,
>> allowing completion expedited GPs quickly than waiting for one scheduler
>> tick.
>>
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>> ---
>>  kernel/rcu/tree_exp.h | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
>> index a43469da3926..5be80d255d6a 100644
>> --- a/kernel/rcu/tree_exp.h
>> +++ b/kernel/rcu/tree_exp.h
>> @@ -763,6 +763,12 @@ static void rcu_exp_handler(void *unused)
>>  			 READ_ONCE(rdp->cpu_no_qs.b.exp)))
>>  		return;
>>  
>> +	/*
>> +	 * Clear defer_qs_pending so arming attempts following this IPI
>> +	 * within the current GP can queue irq_work again.
>> +	 */
>> +	rcu_defer_qs_clear(rdp);
> 
> Suppose that there is also a normal grace period pending.  Will clearing
> this cause extra unnecessary activity with respect to that normal
> grace period?  If so, why is that OK?  If not, what prevents it?

There is no unnecessary activity with respect to the normal GP: whatever
this clear allows to be re-armed funnels into
rcu_preempt_deferred_qs_irqrestore(), which reports the normal QS, the
expedited QS and any deboost together. So the enabled activity is shared
work that lets the normal GP end sooner, not work done at its expense.

But also the exp GP IPI could have arrived during an RCU reader and
subsequently needs to do the deferred work. The flag clearing becomes
important then (even if the normal GP previously resulted in the flag
getting set). Patch 4/8 ("rcu: drop redundant defer_qs_pending clear in
irqrestore handler") makes this clear necessary by design: PENDING now
intentionally persists until the next GP-boundary notice, so without
this patch an exp GP arriving mid-window could be reduced to tick
latency.

There is also prevention of pointless clearing from rcu_exp_handler():
we do this only after the "WARN_ON_ONCE(!(expmask & grpmask) ||
cpu_no_qs.b.exp)" early return, so the clear executes only when this CPU
still owes the expedited GP a quiescent state.

Does that answer your question?

thanks,
--
Joel Fernandes




  reply	other threads:[~2026-07-21 15:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  0:42 [PATCH v4 0/8] rcu: fix stuck defer_qs_pending state and add rescue timer Joel Fernandes
2026-06-26  0:42 ` [PATCH v4 1/8] rcu: introduce rcu_defer_qs_clear() helper Joel Fernandes
2026-07-15 20:43   ` Paul E. McKenney
2026-06-26  0:42 ` [PATCH v4 2/8] rcu: clear defer_qs_pending when notifying GP changes Joel Fernandes
2026-07-15 20:45   ` Paul E. McKenney
2026-07-20 20:09     ` Joel Fernandes
2026-06-26  0:42 ` [PATCH v4 3/8] rcu: clear defer_qs_pending in handler for compounded sections Joel Fernandes
2026-07-15 20:50   ` Paul E. McKenney
2026-07-20 20:32     ` Joel Fernandes
2026-06-26  0:42 ` [PATCH v4 4/8] rcu: drop redundant defer_qs_pending clear in irqrestore handler Joel Fernandes
2026-07-15 20:58   ` Paul E. McKenney
2026-07-20 21:06     ` Joel Fernandes
2026-06-26  0:42 ` [PATCH v4 5/8] rcu: clear defer_qs_pending at expedited IPI entry Joel Fernandes
2026-07-15 21:01   ` Paul E. McKenney
2026-07-21 15:55     ` Joel Fernandes [this message]
2026-06-26  0:42 ` [PATCH v4 6/8] rcu: set need_resched on softirq deferred-QS arming path Joel Fernandes
2026-07-15 21:12   ` Paul E. McKenney
2026-07-21 16:18     ` Joel Fernandes
2026-06-26  0:43 ` [PATCH v4 7/8] rcu: clear defer_qs_pending in deferred-QS bail when nesting > 0 Joel Fernandes
2026-07-15 21:30   ` Paul E. McKenney
2026-07-21 16:58     ` Joel Fernandes
2026-06-26  0:43 ` [PATCH v4 8/8] rcu: add per-CPU rescue hrtimer for deferred-QS reporting Joel Fernandes
2026-07-15 21:35   ` Paul E. McKenney
2026-07-22 14:59     ` Joel Fernandes
2026-06-26  0:44 ` [PATCH v4 0/8] rcu: fix stuck defer_qs_pending state and add rescue timer Joel Fernandes
2026-06-26 14:56 ` Joel Fernandes

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=3dc26b07-ac80-467a-856b-0fe2c2000df6@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=boqun@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=frederic@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --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®