From: Joel Savitz <jsavitz@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Joel Savitz <jsavitz@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Valentin Schneider <valentin.schneider@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <frederic@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Yuan ZhaoXiong <yuanzhaoxiong@baidu.com>,
Baokun Li <libaokun1@huawei.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
YueHaibing <yuehaibing@huawei.com>,
Randy Dunlap <rdunlap@infradead.org>,
David Hildenbrand <dhildenb@redhat.com>
Subject: [RFC PATCH] kernel/cpu: restart cpu_up when hotplug is disabled
Date: Mon, 18 Apr 2022 15:54:02 -0400 [thread overview]
Message-ID: <20220418195402.2986573-1-jsavitz@redhat.com> (raw)
The cpu hotplug path may be utilized while hotplug is disabled for a
brief moment leading to failures. As an example, attempts to perform
cpu hotplug by userspace soon after boot may race with pci_device_probe
leading to inconsistent results.
Proposed idea:
Call restart_syscall instead of returning -EBUSY since
cpu_hotplug_disabled seems to only have a positive value
for short, temporary amounts of time.
Does anyone see any serious problems with this?
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
kernel/cpu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 5797c2a7a93f..2992c7d1d24e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -35,6 +35,7 @@
#include <linux/percpu-rwsem.h>
#include <linux/cpuset.h>
#include <linux/random.h>
+#include <linux/delay.h>
#include <trace/events/power.h>
#define CREATE_TRACE_POINTS
@@ -1401,7 +1402,9 @@ static int cpu_up(unsigned int cpu, enum cpuhp_state target)
cpu_maps_update_begin();
if (cpu_hotplug_disabled) {
- err = -EBUSY;
+ /* avoid busy looping (5ms of sleep should be enough) */
+ msleep(5);
+ err = restart_syscall();
goto out;
}
if (!cpu_smt_allowed(cpu)) {
--
2.27.0
next reply other threads:[~2022-04-18 19:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-18 19:54 Joel Savitz [this message]
2022-04-19 12:34 ` David Hildenbrand
2022-04-21 14:23 ` Thomas Gleixner
2022-04-21 14:31 ` David Hildenbrand
2022-04-21 14:34 ` David Hildenbrand
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=20220418195402.2986573-1-jsavitz@redhat.com \
--to=jsavitz@redhat.com \
--cc=Jason@zx2c4.com \
--cc=dhildenb@redhat.com \
--cc=frederic@kernel.org \
--cc=libaokun1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=tglx@linutronix.de \
--cc=valentin.schneider@arm.com \
--cc=yuanzhaoxiong@baidu.com \
--cc=yuehaibing@huawei.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
all inboxes | Powered by JetHome®