rcu.vger.kernel.org archive mirror
 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, dipankar@in.ibm.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,
	Frederic Weisbecker <frederic@kernel.org>,
	stable@kernel.org, "Paul E . McKenney" <paulmck@kernel.org>
Subject: [PATCH tip/core/rcu 13/26] tick/nohz: Narrow down noise while setting current task's tick dependency
Date: Mon, 22 Jun 2020 17:21:34 -0700	[thread overview]
Message-ID: <20200623002147.25750-13-paulmck@kernel.org> (raw)
In-Reply-To: <20200623002128.GA25456@paulmck-ThinkPad-P72>

From: Frederic Weisbecker <frederic@kernel.org>

Setting a tick dependency on any task, including the case where a task
sets that dependency on itself, triggers an IPI to all CPUs.  That is
of course suboptimal but it had previously not been an issue because it
was only used by POSIX CPU timers on nohz_full, which apparently never
occurs in latency-sensitive workloads in production.  (Or users of such
systems are suffering in silence on the one hand or venting their ire
on the wrong people on the other.)

But RCU now sets a task tick dependency on the current task in order
to fix stall issues that can occur during RCU callback processing.
Thus, RCU callback processing triggers frequent system-wide IPIs from
nohz_full CPUs.  This is quite counter-productive, after all, avoiding
IPIs is what nohz_full is supposed to be all about.

This commit therefore optimizes tasks' self-setting of a task tick
dependency by using tick_nohz_full_kick() to avoid the system-wide IPI.
Instead, only the execution of the one task is disturbed, which is
acceptable given that this disturbance is well down into the noise
compared to the degree to which the RCU callback processing itself
disturbs execution.

Fixes: 6a949b7af82d (rcu: Force on tick when invoking lots of callbacks)
Reported-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: stable@kernel.org
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/time/tick-sched.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3e2dc9b..f0199a4 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -351,16 +351,24 @@ void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit)
 EXPORT_SYMBOL_GPL(tick_nohz_dep_clear_cpu);
 
 /*
- * Set a per-task tick dependency. Posix CPU timers need this in order to elapse
- * per task timers.
+ * Set a per-task tick dependency. RCU need this. Also posix CPU timers
+ * in order to elapse per task timers.
  */
 void tick_nohz_dep_set_task(struct task_struct *tsk, enum tick_dep_bits bit)
 {
-	/*
-	 * We could optimize this with just kicking the target running the task
-	 * if that noise matters for nohz full users.
-	 */
-	tick_nohz_dep_set_all(&tsk->tick_dep_mask, bit);
+	if (!atomic_fetch_or(BIT(bit), &tsk->tick_dep_mask)) {
+		if (tsk == current) {
+			preempt_disable();
+			tick_nohz_full_kick();
+			preempt_enable();
+		} else {
+			/*
+			 * Some future tick_nohz_full_kick_task()
+			 * should optimize this.
+			 */
+			tick_nohz_full_kick_all();
+		}
+	}
 }
 EXPORT_SYMBOL_GPL(tick_nohz_dep_set_task);
 
-- 
2.9.5


  parent reply	other threads:[~2020-06-23  0:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  0:21 [PATCH tip/core/rcu 0/26] Miscellaneous fixes for v5.9 Paul E. McKenney
2020-06-23  0:21 ` [PATCH tip/core/rcu 01/26] rcu: Initialize and destroy rcu_synchronize only when necessary paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 02/26] mm/mmap.c: Add cond_resched() for exit_mmap() CPU stalls paulmck
2020-06-23  0:47   ` Shakeel Butt
2020-06-23  0:57     ` Paul E. McKenney
2020-06-23 19:34   ` Joel Fernandes
2020-06-23 20:55     ` Paul E. McKenney
2020-06-23 21:01       ` Joel Fernandes
2020-06-23  0:21 ` [PATCH tip/core/rcu 03/26] rcu: Simplify the calculation of rcu_state.ncpus paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 04/26] rcu: Add callbacks-invoked counters paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 05/26] rcu: Add comment documenting rcu_callback_map's purpose paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 06/26] trace: events: rcu: Change description of rcu_dyntick trace event paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 07/26] rcu: Grace-period-kthread related sleeps to idle priority paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 08/26] rcu: Priority-boost-related " paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 09/26] rcu: No-CBs-related " paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 10/26] rcu: Expedited grace-period " paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 11/26] fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 12/26] rcu: Update comment from rsp->rcu_gp_seq to rsp->gp_seq paulmck
2020-06-23  0:21 ` paulmck [this message]
2020-06-23  0:21 ` [PATCH tip/core/rcu 14/26] rcu: fix some kernel-doc warnings paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 15/26] rcu: Remove initialized but unused rnp from check_slow_task() paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 16/26] rcu: Mark rcu_nmi_enter() call to rcu_cleanup_after_idle() noinstr paulmck
2020-06-23 17:04   ` Peter Zijlstra
2020-06-23 17:50     ` Paul E. McKenney
2020-06-23  0:21 ` [PATCH tip/core/rcu 17/26] lockdep: Complain only once about RCU in extended quiescent state paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 18/26] rcu: Replace 1 with true paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 19/26] rcu: Stop shrinker loop paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 20/26] rcu: gp_max is protected by root rcu_node's lock paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 21/26] rcu: grplo/grphi just records CPU number paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 22/26] rcu: grpnum just records group number paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 23/26] kernel/rcu/tree.c: Fix kernel-doc warnings paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 24/26] rcu: fix some " paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 25/26] rcu: Remove KCSAN stubs paulmck
2020-06-23  0:21 ` [PATCH tip/core/rcu 26/26] rcu: Remove KCSAN stubs from update.c 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=20200623002147.25750-13-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=frederic@kernel.org \
    --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=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@kernel.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;
as well as URLs for NNTP newsgroup(s).