public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: paulmck@kernel.org
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	mingo@kernel.org, jiangshanlai@gmail.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
	fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
	Neeraj Upadhyay <neeraju@codeaurora.org>,
	"Paul E . McKenney" <paulmck@kernel.org>
Subject: [PATCH tip/core/rcu 11/16] rcu/tree: nocb: Avoid raising softirq for offloaded ready-to-execute CBs
Date: Thu,  5 Nov 2020 15:09:16 -0800	[thread overview]
Message-ID: <20201105230921.19017-11-paulmck@kernel.org> (raw)
In-Reply-To: <20201105230856.GA18904@paulmck-ThinkPad-P72>

From: "Joel Fernandes (Google)" <joel@joelfernandes.org>

Testing showed that rcu_pending() can return 1 when offloaded callbacks
are ready to execute.  This invokes RCU core processing, for example,
by raising RCU_SOFTIRQ, eventually resulting in a call to rcu_core().
However, rcu_core() explicitly avoids in any way manipulating offloaded
callbacks, which are instead handled by the rcuog and rcuoc kthreads,
which work independently of rcu_core().

One exception to this independence is that rcu_core() invokes
do_nocb_deferred_wakeup(), however, rcu_pending() also checks
rcu_nocb_need_deferred_wakeup() in order to correctly handle this case,
invoking rcu_core() when needed.

This commit therefore avoids needlessly invoking RCU core processing
by checking rcu_segcblist_ready_cbs() only on non-offloaded CPUs.
This reduces overhead, for example, by reducing softirq activity.

This change passed 30 minute tests of TREE01 through TREE09 each.

On TREE08, there is at most 150us from the time that rcu_pending() chose
not to invoke RCU core processing to the time when the ready callbacks
were invoked by the rcuoc kthread.  This provides further evidence that
there is no need to invoke rcu_core() for offloaded callbacks that are
ready to invoke.

Cc: Neeraj Upadhyay <neeraju@codeaurora.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Neeraj Upadhyay <neeraju@codeaurora.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index aaed35e..fe569db 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3718,7 +3718,8 @@ static int rcu_pending(int user)
 		return 1;
 
 	/* Does this CPU have callbacks ready to invoke? */
-	if (rcu_segcblist_ready_cbs(&rdp->cblist))
+	if (!rcu_segcblist_is_offloaded(&rdp->cblist) &&
+	    rcu_segcblist_ready_cbs(&rdp->cblist))
 		return 1;
 
 	/* Has RCU gone idle with this CPU needing another grace period? */
-- 
2.9.5


  parent reply	other threads:[~2020-11-05 23:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 23:08 [PATCH tip/core/rcu 0/16] Miscellaneous fixes for v5.11 Paul E. McKenney
2020-11-05 23:09 ` [PATCH tip/core/rcu 01/16] rcu: Don't invoke try_invoke_on_locked_down_task() with irqs disabled paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 02/16] x86/smpboot: Move rcu_cpu_starting() earlier paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 03/16] rcu: Panic after fixed number of stalls paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 04/16] list.h: Update comment to explicitly note circular lists paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 05/16] rcu: Implement rcu_segcblist_is_offloaded() config dependent paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 06/16] rcu: Fix single-CPU check in rcu_blocking_is_gp() paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 07/16] rcu: Clarify nocb kthreads naming in RCU_NOCB_CPU config paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 08/16] rcu/tree: Add a warning if CPU being onlined did not report QS already paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 09/16] rcu/tree: Make struct kernel_param_ops definitions const paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 10/16] rcu,ftrace: Fix ftrace recursion paulmck
2020-11-05 23:09 ` paulmck [this message]
2020-11-05 23:09 ` [PATCH tip/core/rcu 12/16] rcu: Prevent lockdep-RCU splats on lock acquisition/release paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 13/16] rcu: Fix a typo in rcu_blocking_is_gp() header comment paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 14/16] rcu: Do not report strict GPs for outgoing CPUs paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 15/16] rcu/tree: Defer kvfree_rcu() allocation to a clean context paulmck
2020-11-05 23:09 ` [PATCH tip/core/rcu 16/16] srcu: Take early exit on memory-allocation failure paulmck

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=20201105230921.19017-11-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=neeraju@codeaurora.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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