From: geoff@infradead.org (Geoff Levand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v20 02/14] arm64: smp: Add function to determine if cpus are stuck in the kernel
Date: Thu, 23 Jun 2016 17:54:48 +0000 [thread overview]
Message-ID: <938f5ec9deff917f8e4ad276c01b5c753b7ee83a.1466702804.git.geoff@infradead.org> (raw)
In-Reply-To: <cover.1466702804.git.geoff@infradead.org>
From: James Morse <james.morse@arm.com>
kernel/smp.c has a fancy counter that keeps track of the number of CPUs
it marked as not-present and left in cpu_park_loop(). If there are any
CPUs spinning in here, features like kexec or hibernate may release them
by overwriting this memory.
This problem also occurs on machines using spin-tables to release
secondary cores.
After commit 44dbcc93ab67 ("arm64: Fix behavior of maxcpus=N")
we bring all known cpus into the secondary holding pen, meaning this
memory can't be re-used by kexec or hibernate.
Add a function cpus_are_stuck_in_kernel() to determine if either of these
cases have occurred.
Signed-off-by: James Morse <james.morse@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
arch/arm64/include/asm/smp.h | 12 ++++++++++++
arch/arm64/kernel/smp.c | 18 ++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
index 433e504..0226447 100644
--- a/arch/arm64/include/asm/smp.h
+++ b/arch/arm64/include/asm/smp.h
@@ -124,6 +124,18 @@ static inline void cpu_panic_kernel(void)
cpu_park_loop();
}
+/*
+ * If a secondary CPU enters the kernel but fails to come online,
+ * (e.g. due to mismatched features), and cannot exit the kernel,
+ * we increment cpus_stuck_in_kernel and leave the CPU in a
+ * quiesecent loop within the kernel text. The memory containing
+ * this loop must not be re-used for anything else as the 'stuck'
+ * core is executing it.
+ *
+ * This function is used to inhibit features like kexec and hibernate.
+ */
+bool cpus_are_stuck_in_kernel(void);
+
#endif /* ifndef __ASSEMBLY__ */
#endif /* ifndef __ASM_SMP_H */
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 678e084..62ff3c0 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -909,3 +909,21 @@ int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}
+
+static bool have_cpu_die(void)
+{
+#ifdef CONFIG_HOTPLUG_CPU
+ int any_cpu = raw_smp_processor_id();
+
+ if (cpu_ops[any_cpu]->cpu_die)
+ return true;
+#endif
+ return false;
+}
+
+bool cpus_are_stuck_in_kernel(void)
+{
+ bool smp_spin_tables = (num_possible_cpus() > 1 && !have_cpu_die());
+
+ return !!cpus_stuck_in_kernel || smp_spin_tables;
+}
--
2.5.0
next prev parent reply other threads:[~2016-06-23 17:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 17:54 [PATCH v20 00/14] arm64 kexec kernel patches Geoff Levand
2016-06-23 17:54 ` [PATCH v20 06/14] arm64/kexec: Add pr_debug output Geoff Levand
2016-06-23 17:54 ` [PATCH v20 07/14] arm64: kdump: reserve memory for crash dump kernel Geoff Levand
2016-06-23 17:54 ` [PATCH v20 04/14] arm64/kexec: Add core kexec support Geoff Levand
2016-06-27 11:18 ` James Morse
2016-06-27 14:39 ` Catalin Marinas
2016-06-27 16:29 ` James Morse
2016-06-27 17:00 ` Geoff Levand
2016-06-23 17:54 ` Geoff Levand [this message]
2016-06-23 17:54 ` [PATCH v20 08/14] arm64: limit memory regions based on DT property, usable-memory Geoff Levand
2016-06-23 17:54 ` [PATCH v20 11/14] arm64: kdump: add VMCOREINFO's for user-space coredump tools Geoff Levand
2016-06-23 17:54 ` [PATCH v20 10/14] arm64: kdump: add kdump support Geoff Levand
2016-06-23 17:54 ` [PATCH v20 12/14] arm64: kdump: enable kdump in the arm64 defconfig Geoff Levand
2016-06-23 17:54 ` [PATCH v20 03/14] arm64: Add back cpu reset routines Geoff Levand
2016-06-23 17:54 ` [PATCH v20 01/14] arm64: hibernate: Don't hibernate on systems with stuck CPUs Geoff Levand
2016-06-27 11:04 ` James Morse
2016-06-27 16:44 ` Geoff Levand
2016-06-23 17:54 ` [PATCH v20 05/14] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2016-06-23 17:54 ` [PATCH v20 09/14] arm64: kdump: implement machine_crash_shutdown() Geoff Levand
2016-06-23 17:54 ` [PATCH v20 14/14] Documentation: dt: usable-memory and elfcorehdr nodes for arm64 kexec Geoff Levand
2016-06-23 17:54 ` [PATCH v20 13/14] arm64: kdump: update a kernel doc Geoff Levand
2016-06-30 9:00 ` Baoquan He
2016-07-01 7:37 ` AKASHI Takahiro
2016-07-01 7:45 ` Baoquan He
2016-07-04 3:04 ` AKASHI Takahiro
2016-06-30 13:00 ` Dave Young
2016-06-27 17:00 ` [PATCH v20 00/14] arm64 kexec kernel patches Catalin Marinas
2016-06-27 17:07 ` Geoff Levand
2016-06-29 0:54 ` AKASHI Takahiro
2016-06-29 9:20 ` Catalin Marinas
2016-06-30 1:46 ` AKASHI Takahiro
2016-07-01 2:39 ` Pratyush Anand
2016-07-04 7:14 ` AKASHI Takahiro
2016-07-04 10:15 ` Pratyush Anand
2016-07-15 4:17 ` Simon Horman
2016-07-15 16:18 ` Geoff Levand
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=938f5ec9deff917f8e4ad276c01b5c753b7ee83a.1466702804.git.geoff@infradead.org \
--to=geoff@infradead.org \
--cc=linux-arm-kernel@lists.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;
as well as URLs for NNTP newsgroup(s).