From: Pingfan Liu <kernelfans@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Pingfan Liu <kernelfans@gmail.com>,
Yury Norov <yury.norov@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Thomas Gleixner <tglx@linutronix.de>,
Steven Price <steven.price@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com>
Subject: [RFC 07/10] lib/cpumask: Introduce cpumask_not_dying_but()
Date: Mon, 22 Aug 2022 10:15:17 +0800 [thread overview]
Message-ID: <20220822021520.6996-8-kernelfans@gmail.com> (raw)
In-Reply-To: <20220822021520.6996-1-kernelfans@gmail.com>
During cpu hot-removing, the dying cpus are still in cpu_online_mask.
On the other hand, A subsystem will migrate its broker from the dying
cpu to a online cpu in its teardown cpuhp_step.
After enabling the teardown of cpus in parallel, cpu_online_mask can not
tell those dying from the real online.
Introducing a function cpumask_not_dying_but() to pick a real online
cpu.
Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Yury Norov <yury.norov@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Price <steven.price@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: linux-kernel@vger.kernel.org
---
include/linux/cpumask.h | 3 +++
kernel/cpu.c | 3 +++
lib/cpumask.c | 18 ++++++++++++++++++
3 files changed, 24 insertions(+)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 0d435d0edbcb..d2033a239a07 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -317,6 +317,9 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
return i;
}
+/* for parallel kexec reboot */
+int cpumask_not_dying_but(const struct cpumask *mask, unsigned int cpu);
+
#define CPU_BITS_NONE \
{ \
[0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 90debbe28e85..771e344f8ff9 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1282,6 +1282,9 @@ static void cpus_down_no_rollback(struct cpumask *cpus)
struct cpuhp_cpu_state *st;
unsigned int cpu;
+ for_each_cpu(cpu, cpus)
+ set_cpu_dying(cpu, true);
+
/* launch ap work one by one, but not wait for completion */
for_each_cpu(cpu, cpus) {
st = per_cpu_ptr(&cpuhp_state, cpu);
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 8baeb37e23d3..6474f07ed87a 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -7,6 +7,24 @@
#include <linux/memblock.h>
#include <linux/numa.h>
+/* Used in parallel kexec-reboot cpuhp callbacks */
+int cpumask_not_dying_but(const struct cpumask *mask,
+ unsigned int cpu)
+{
+ unsigned int i;
+
+ if (CONFIG_SHUTDOWN_NONBOOT_CPUS) {
+ cpumask_check(cpu);
+ for_each_cpu(i, mask)
+ if (i != cpu && !cpumask_test_cpu(i, cpu_dying_mask))
+ break;
+ return i;
+ } else {
+ return cpumask_any_but(mask, cpu);
+ }
+}
+EXPORT_SYMBOL(cpumask_not_dying_but);
+
/**
* cpumask_next_wrap - helper to implement for_each_cpu_wrap
* @n: the cpu prior to the place to search
--
2.31.1
next prev parent reply other threads:[~2022-08-22 2:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 2:15 [RFC 00/10] arm64/riscv: Introduce fast kexec reboot Pingfan Liu
2022-08-22 2:15 ` [RFC 01/10] cpu/hotplug: Make __cpuhp_kick_ap() ready for async Pingfan Liu
2022-08-22 2:15 ` [RFC 02/10] cpu/hotplug: Compile smp_shutdown_nonboot_cpus() conditioned on CONFIG_SHUTDOWN_NONBOOT_CPUS Pingfan Liu
2022-08-22 2:15 ` [RFC 03/10] cpu/hotplug: Introduce fast kexec reboot Pingfan Liu
2022-08-22 2:15 ` [RFC 04/10] cpu/hotplug: Check the capability of kexec quick reboot Pingfan Liu
2022-08-22 2:15 ` [RFC 05/10] perf/arm-dsu: Make dsu_pmu_cpu_teardown() parallel Pingfan Liu
2022-08-22 2:15 ` [RFC 06/10] rcu/hotplug: Make rcutree_dead_cpu() parallel Pingfan Liu
2022-08-22 2:45 ` Paul E. McKenney
2022-08-23 1:50 ` Pingfan Liu
2022-08-23 3:01 ` Paul E. McKenney
2022-08-24 13:53 ` Pingfan Liu
2022-08-24 16:20 ` Paul E. McKenney
2022-08-24 17:26 ` Joel Fernandes
2022-08-24 19:21 ` Paul E. McKenney
2022-08-24 22:54 ` Joel Fernandes
2022-08-24 23:01 ` Paul E. McKenney
2022-08-31 16:15 ` Paul E. McKenney
2022-09-05 3:53 ` Pingfan Liu
2022-09-06 18:45 ` Paul E. McKenney
2022-08-22 18:08 ` Joel Fernandes
2022-08-23 1:56 ` Pingfan Liu
2022-08-23 3:14 ` Joel Fernandes
2022-08-24 13:38 ` Pingfan Liu
2022-08-24 13:44 ` Jason A. Donenfeld
2022-08-22 2:15 ` Pingfan Liu [this message]
2022-08-22 14:15 ` [RFC 07/10] lib/cpumask: Introduce cpumask_not_dying_but() Yury Norov
2022-08-23 7:29 ` Pingfan Liu
2022-08-22 2:15 ` [RFC 08/10] cpuhp: Replace cpumask_any_but(cpu_online_mask, cpu) Pingfan Liu
2022-08-22 2:15 ` [RFC 09/10] genirq/cpuhotplug: Ask migrate_one_irq() to migrate to a real online cpu Pingfan Liu
2022-08-22 2:15 ` [RFC 10/10] arm64: smp: Make __cpu_disable() parallel Pingfan Liu
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=20220822021520.6996-8-kernelfans@gmail.com \
--to=kernelfans@gmail.com \
--cc=Jason@zx2c4.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mark.rutland@arm.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=steven.price@arm.com \
--cc=tglx@linutronix.de \
--cc=yury.norov@gmail.com \
/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).