* [PATCH v2 0/1] show 'last online CPU' error in dlpar_cpu_offline()
@ 2021-03-23 20:50 Daniel Henrique Barboza
2021-03-23 20:50 ` [PATCH v2 1/1] hotplug-cpu.c: " Daniel Henrique Barboza
2021-03-31 1:09 ` [PATCH v2 0/1] " Michael Ellerman
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Henrique Barboza @ 2021-03-23 20:50 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Daniel Henrique Barboza
changes in v2 after Michael Ellerman review:
- moved the verification code from dlpar_cpu_remove() to
dlpar_cpu_offline(), while holding cpu_add_remove_lock
- reworded the commit message and code comment
v1 link:
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210305173845.451158-1-danielhb413@gmail.com/
Daniel Henrique Barboza (1):
hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_offline()
arch/powerpc/platforms/pseries/hotplug-cpu.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_offline()
2021-03-23 20:50 [PATCH v2 0/1] show 'last online CPU' error in dlpar_cpu_offline() Daniel Henrique Barboza
@ 2021-03-23 20:50 ` Daniel Henrique Barboza
2021-03-26 5:24 ` Daniel Axtens
2021-03-31 1:09 ` [PATCH v2 0/1] " Michael Ellerman
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Henrique Barboza @ 2021-03-23 20:50 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Daniel Henrique Barboza
One of the reasons that dlpar_cpu_offline can fail is when attempting to
offline the last online CPU of the kernel. This can be observed in a
pseries QEMU guest that has hotplugged CPUs. If the user offlines all
other CPUs of the guest, and a hotplugged CPU is now the last online
CPU, trying to reclaim it will fail. See [1] for an example.
The current error message in this situation returns rc with -EBUSY and a
generic explanation, e.g.:
pseries-hotplug-cpu: Failed to offline CPU PowerPC,POWER9, rc: -16
EBUSY can be caused by other conditions, such as cpu_hotplug_disable
being true. Throwing a more specific error message for this case,
instead of just "Failed to offline CPU", makes it clearer that the error
is in fact a known error situation instead of other generic/unknown
cause.
This patch adds a 'last online' check in dlpar_cpu_offline() to catch
the 'last online CPU' offline error, eturning a more informative error
message:
pseries-hotplug-cpu: Unable to remove last online CPU PowerPC,POWER9
[1] https://bugzilla.redhat.com/1911414
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
arch/powerpc/platforms/pseries/hotplug-cpu.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 12cbffd3c2e3..3ac7e904385c 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -271,6 +271,18 @@ static int dlpar_offline_cpu(struct device_node *dn)
if (!cpu_online(cpu))
break;
+ /* device_offline() will return -EBUSY (via cpu_down())
+ * if there is only one CPU left. Check it here to fail
+ * earlier and with a more informative error message,
+ * while also retaining the cpu_add_remove_lock to be sure
+ * that no CPUs are being online/offlined during this
+ * check. */
+ if (num_online_cpus() == 1) {
+ pr_warn("Unable to remove last online CPU %pOFn\n", dn);
+ rc = -EBUSY;
+ goto out_unlock;
+ }
+
cpu_maps_update_done();
rc = device_offline(get_cpu_device(cpu));
if (rc)
@@ -283,6 +295,7 @@ static int dlpar_offline_cpu(struct device_node *dn)
thread);
}
}
+out_unlock:
cpu_maps_update_done();
out:
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_offline()
2021-03-23 20:50 ` [PATCH v2 1/1] hotplug-cpu.c: " Daniel Henrique Barboza
@ 2021-03-26 5:24 ` Daniel Axtens
2021-03-26 14:08 ` Daniel Henrique Barboza
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Axtens @ 2021-03-26 5:24 UTC (permalink / raw)
To: Daniel Henrique Barboza, linuxppc-dev; +Cc: Daniel Henrique Barboza
Hi Daniel,
Two small nitpicks:
> This patch adds a 'last online' check in dlpar_cpu_offline() to catch
> the 'last online CPU' offline error, eturning a more informative error
^--- s/eturning/returning/;
> + /* device_offline() will return -EBUSY (via cpu_down())
> + * if there is only one CPU left. Check it here to fail
> + * earlier and with a more informative error message,
> + * while also retaining the cpu_add_remove_lock to be sure
> + * that no CPUs are being online/offlined during this
> + * check. */
Checkpatch has a small issue with this comment:
WARNING: Block comments use a trailing */ on a separate line
#50: FILE: arch/powerpc/platforms/pseries/hotplug-cpu.c:279:
+ * check. */
Apart from that, this patch seems sane to me, but I haven't been able to
test it.
Kind regards,
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_offline()
2021-03-26 5:24 ` Daniel Axtens
@ 2021-03-26 14:08 ` Daniel Henrique Barboza
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Henrique Barboza @ 2021-03-26 14:08 UTC (permalink / raw)
To: Daniel Axtens, linuxppc-dev
Hey Daniel,
On 3/26/21 2:24 AM, Daniel Axtens wrote:
> Hi Daniel,
>
> Two small nitpicks:
>
>> This patch adds a 'last online' check in dlpar_cpu_offline() to catch
>> the 'last online CPU' offline error, eturning a more informative error
> ^--- s/eturning/returning/;
>
>
>> + /* device_offline() will return -EBUSY (via cpu_down())
>> + * if there is only one CPU left. Check it here to fail
>> + * earlier and with a more informative error message,
>> + * while also retaining the cpu_add_remove_lock to be sure
>> + * that no CPUs are being online/offlined during this
>> + * check. */
>
> Checkpatch has a small issue with this comment:
>
> WARNING: Block comments use a trailing */ on a separate line
> #50: FILE: arch/powerpc/platforms/pseries/hotplug-cpu.c:279:
> + * check. */
>
> Apart from that, this patch seems sane to me, but I haven't been able to
> test it.
Thanks for the review, and for letting me know of the existence of
'scripts/checkpatch.pl' to verify the patches before posting. I'll
send a v3.
Thanks,
DHB
>
> Kind regards,
> Daniel
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/1] show 'last online CPU' error in dlpar_cpu_offline()
2021-03-23 20:50 [PATCH v2 0/1] show 'last online CPU' error in dlpar_cpu_offline() Daniel Henrique Barboza
2021-03-23 20:50 ` [PATCH v2 1/1] hotplug-cpu.c: " Daniel Henrique Barboza
@ 2021-03-31 1:09 ` Michael Ellerman
1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2021-03-31 1:09 UTC (permalink / raw)
To: linuxppc-dev, Daniel Henrique Barboza
On Tue, 23 Mar 2021 17:50:55 -0300, Daniel Henrique Barboza wrote:
> changes in v2 after Michael Ellerman review:
> - moved the verification code from dlpar_cpu_remove() to
> dlpar_cpu_offline(), while holding cpu_add_remove_lock
> - reworded the commit message and code comment
> v1 link:
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210305173845.451158-1-danielhb413@gmail.com/
>
> [...]
Applied to powerpc/next.
[1/1] hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_offline()
https://git.kernel.org/powerpc/c/d19b3ad02c2d1a9a697b7059e32fa2d97a420b15
cheers
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-31 1:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 20:50 [PATCH v2 0/1] show 'last online CPU' error in dlpar_cpu_offline() Daniel Henrique Barboza
2021-03-23 20:50 ` [PATCH v2 1/1] hotplug-cpu.c: " Daniel Henrique Barboza
2021-03-26 5:24 ` Daniel Axtens
2021-03-26 14:08 ` Daniel Henrique Barboza
2021-03-31 1:09 ` [PATCH v2 0/1] " Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.