linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] sched/nohz: disallow non-existent cores from nohz-full
@ 2022-02-21 18:20 Paul Gortmaker
  2022-02-21 18:20 ` [PATCH 1/2] sched/isolation: really align nohz_full with rcu_nocbs Paul Gortmaker
  2022-02-21 18:20 ` [PATCH 2/2] tick/nohz: WARN_ON --> WARN_ON_ONCE to prevent console saturation Paul Gortmaker
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Gortmaker @ 2022-02-21 18:20 UTC (permalink / raw)
  To: linux-kernel, Frederic Weisbecker, Peter Zijlstra
  Cc: Paul Gortmaker, Ingo Molnar, Nicholas Piggin, Paul E . McKenney,
	Thomas Gleixner

This is a rebase and retest of two fixes I'd sent earlier[1].

The rebase is required due to conflicts in my patch #1 and where Frederic updated
the unwind code in housekeeping_setup in his series[2] and that series is now
in sched/core of tip[3].

So this update is against a baseline of ed3b362d54f0 found in sched/core as
"sched/isolation: Split housekeeping cpumask per isolation features" in tip.

Changes amount to "return 0" ---> "goto out_free" and adding a nod to PaulM's
observation that nohz_full w/o a cpuset is coming someday into the commit log.

[1] https://lore.kernel.org/all/20211206145950.10927-1-paul.gortmaker@windriver.com/
[2] https://lore.kernel.org/all/20220207155910.527133-1-frederic@kernel.org/
[3] git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git

 ----- Original v1 text follows ----- 

A couple months back I sent a fix to reconcile rcu_nocbs= input
restrictions with nohz_full= input restrictions; with the latter being
more restrictive than the former.

However, in relaxing the nohz_full restrictions, I made it possible to
boot with a nohz_full= parameter that contains nothing but nonexistent
and not-possible cores - which will trigger a WARN.

This fixes the original reconcile commit by explicitly coding our
allowed values just like RCU does, and changes the WARN_ON to a
WARN_ON_ONCE, since it needlessly rendered the machine unusable.

---

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>

Paul Gortmaker (2):
  sched/isolation: really align nohz_full with rcu_nocbs
  tick/nohz: WARN_ON --> WARN_ON_ONCE to prevent console saturation

 kernel/sched/isolation.c | 11 +++++++++++
 kernel/time/tick-sched.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] sched/isolation: really align nohz_full with rcu_nocbs
  2022-02-21 18:20 [PATCH v2 0/2] sched/nohz: disallow non-existent cores from nohz-full Paul Gortmaker
@ 2022-02-21 18:20 ` Paul Gortmaker
  2022-02-21 18:20 ` [PATCH 2/2] tick/nohz: WARN_ON --> WARN_ON_ONCE to prevent console saturation Paul Gortmaker
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Gortmaker @ 2022-02-21 18:20 UTC (permalink / raw)
  To: linux-kernel, Frederic Weisbecker, Peter Zijlstra
  Cc: Paul Gortmaker, Thomas Gleixner, Paul E . McKenney, Ingo Molnar

At the moment it is currently possible to sneak a core into nohz_full
that lies between nr_possible and NR_CPUS - but you won't "see" it
because cpumask_pr_args() implicitly hides anything above nr_cpu_ids.

This becomes a problem when the nohz_full CPU set doesn't contain at
least one other valid nohz CPU - in which case we end up with the
tick_nohz_full_running set and no tick core specified, which trips an
endless sequence of WARN() and renders the machine unusable.

I inadvertently opened the door for this when fixing an overly
restrictive nohz_full conditional in the below Fixes: commit - and then
courtesy of my optimistic ACPI reporting nr_possible of 64 (the default
Kconfig for NR_CPUS) and the not-so helpful implict filtering done by
cpumask_pr_args, I unfortunately did not spot it during my testing.

So here, I don't rely on what was printed anymore, but code exactly what
our restrictions should be in order to be aligned with rcu_nocbs - which
was the original goal.  Since the checks lie in "__init" code it is largely
free for us to do this anyway.

Building with NOHZ_FULL and NR_CPUS=128 on an otherwise defconfig, and
booting with "rcu_nocbs=8-127 nohz_full=96-127" on the same 16 core T5500
Dell machine now results in the following (only relevant lines shown):

 smpboot: Allowing 64 CPUs, 48 hotplug CPUs
 setup_percpu: NR_CPUS:128 nr_cpumask_bits:128 nr_cpu_ids:64 nr_node_ids:2
 housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' contains nonexistent CPUs.
 housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' has no valid CPUs.
 rcu:     RCU restricting CPUs from NR_CPUS=128 to nr_cpu_ids=64.
 rcu:     Note: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs.
 rcu:     Offload RCU callbacks from CPUs: 8-63.

One can see both new housekeeping checks are triggered in the above.
The same invalid boot arg combination would have previously resulted in
an infinitely scrolling mix of WARN from all cores per tick on this box.

We may need to revisit these sanity checks when nohz_full is accepted as
a stand alone keyword "enable" w/o a cpuset (see rcu/nohz d2cf0854d728).

Fixes: 915a2bc3c6b7 ("sched/isolation: Reconcile rcu_nocbs= and nohz_full=")
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 kernel/sched/isolation.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index b4d10815c45a..f7d2406c1f1d 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -126,6 +126,17 @@ static int __init housekeeping_setup(char *str, unsigned long flags)
 		goto free_non_housekeeping_mask;
 	}
 
+	if (!cpumask_subset(non_housekeeping_mask, cpu_possible_mask)) {
+		pr_info("housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' contains nonexistent CPUs.\n");
+		cpumask_and(non_housekeeping_mask, cpu_possible_mask,
+			    non_housekeeping_mask);
+	}
+
+	if (cpumask_empty(non_housekeeping_mask)) {
+		pr_info("housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' has no valid CPUs.\n");
+		goto free_non_housekeeping_mask;
+	}
+
 	alloc_bootmem_cpumask_var(&housekeeping_staging);
 	cpumask_andnot(housekeeping_staging,
 		       cpu_possible_mask, non_housekeeping_mask);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tick/nohz: WARN_ON --> WARN_ON_ONCE to prevent console saturation
  2022-02-21 18:20 [PATCH v2 0/2] sched/nohz: disallow non-existent cores from nohz-full Paul Gortmaker
  2022-02-21 18:20 ` [PATCH 1/2] sched/isolation: really align nohz_full with rcu_nocbs Paul Gortmaker
@ 2022-02-21 18:20 ` Paul Gortmaker
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Gortmaker @ 2022-02-21 18:20 UTC (permalink / raw)
  To: linux-kernel, Frederic Weisbecker, Peter Zijlstra
  Cc: Paul Gortmaker, Nicholas Piggin, Thomas Gleixner, Ingo Molnar

While running some testing on code that happened to allow the variable
tick_nohz_full_running to get set but with no "possible" NOHZ cores to
back up that setting, I tripped this WARN:

        if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE))
                WARN_ON(tick_nohz_full_running);

The console was overwhemled with an endless stream of one WARN per tick
per core and there was no way to even see what was going on w/o using a
serial console to capture it and then trace it back to this guy.

Changing it to ONCE reveals that we get the message we need in a
civilized fashion, and the system can limp along until rebooted.

Fixes: 08ae95f4fd3b ("nohz_full: Allow the boot CPU to be nohz_full")
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 kernel/time/tick-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 17a283ce2b20..5e80ee44c32a 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -186,7 +186,7 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
 	 */
 	if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) {
 #ifdef CONFIG_NO_HZ_FULL
-		WARN_ON(tick_nohz_full_running);
+		WARN_ON_ONCE(tick_nohz_full_running);
 #endif
 		tick_do_timer_cpu = cpu;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-21 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 18:20 [PATCH v2 0/2] sched/nohz: disallow non-existent cores from nohz-full Paul Gortmaker
2022-02-21 18:20 ` [PATCH 1/2] sched/isolation: really align nohz_full with rcu_nocbs Paul Gortmaker
2022-02-21 18:20 ` [PATCH 2/2] tick/nohz: WARN_ON --> WARN_ON_ONCE to prevent console saturation Paul Gortmaker

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).