From: Nicholas Piggin <npiggin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
Frederic Weisbecker <frederic@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH] kernel/isolation: Asset that a housekeeping CPU comes up at boot time
Date: Sat, 1 Jun 2019 21:39:19 +1000 [thread overview]
Message-ID: <20190601113919.2678-1-npiggin@gmail.com> (raw)
With the change to allow the boot CPU0 to be isolated, it is possible
to specify command line options that result in no housekeeping CPU
online at boot.
An 8 CPU system booted with "nohz_full=0-6 maxcpus=4", for example.
It is not easily possible at housekeeping init time to know all the
various SMP options that will result in an invalid configuration, so
this patch adds a sanity check after SMP init, to ensure that a
housekeeping CPU has been onlined.
The panic is undesirable, but it's better than the alternative of an
obscure non deterministic failure. The panic will reliably happen
when advanced parameters are used incorrectly.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
kernel/sched/isolation.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 123ea07a3f3b..7b9e1e0d4ec3 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -63,6 +63,29 @@ void __init housekeeping_init(void)
WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
}
+static int __init housekeeping_verify_smp(void)
+{
+ int cpu;
+
+ /*
+ * Early housekeeping setup is done before CPUs come up, and there are
+ * a range of options scattered around that can restrict which CPUs
+ * come up. It is possible to pass in a combination of housekeeping
+ * and SMP arguments that result in housekeeping assigned to an
+ * offline CPU.
+ *
+ * Check that condition here after SMP comes up, and give a useful
+ * error message rather than an obscure non deterministic crash or
+ * hang later.
+ */
+ for_each_online_cpu(cpu) {
+ if (cpumask_test_cpu(cpu, housekeeping_mask))
+ return 0;
+ }
+ panic("Housekeeping: nohz_full= or isolcpus= resulted in no online CPUs for housekeeping.\n");
+}
+core_initcall(housekeeping_verify_smp);
+
static int __init housekeeping_setup(char *str, enum hk_flags flags)
{
cpumask_var_t non_housekeeping_mask;
--
2.20.1
next reply other threads:[~2019-06-01 11:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-01 11:39 Nicholas Piggin [this message]
2019-06-10 7:24 ` [PATCH] kernel/isolation: Asset that a housekeeping CPU comes up at boot time Nicholas Piggin
2019-06-17 15:59 ` Peter Zijlstra
2019-06-17 19:05 ` Frederic Weisbecker
2019-06-19 2:40 ` Nicholas Piggin
2019-06-24 10:57 ` Qais Yousef
2019-06-25 0:05 ` Nicholas Piggin
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=20190601113919.2678-1-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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