linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_remove()
@ 2021-03-05 17:38 Daniel Henrique Barboza
  2021-03-18  9:59 ` Daniel Henrique Barboza
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Henrique Barboza @ 2021-03-05 17:38 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Daniel Henrique Barboza

Of all the reasons that dlpar_cpu_remove() can fail, the 'last online
CPU' is one that can be caused directly by the user offlining CPUs
in a partition/virtual machine that has hotplugged CPUs. Trying to
reclaim a hotplugged CPU can fail if the CPU is now the last online in
the system. This is easily reproduced using QEMU [1].

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.

[1] https://bugzilla.redhat.com/1911414

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 12cbffd3c2e3..134f393f09e1 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -514,7 +514,17 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index)
 
 	rc = dlpar_offline_cpu(dn);
 	if (rc) {
-		pr_warn("Failed to offline CPU %pOFn, rc: %d\n", dn, rc);
+		/* dlpar_offline_cpu will return -EBUSY from cpu_down() (via
+		 * device_offline()) in 2 cases: cpu_hotplug_disable is true or
+		 * there is only one CPU left. Warn the user about the second
+		 * since this can happen with user offlining CPUs and then
+		 * attempting hotunplugs.
+		 */
+		if (rc == -EBUSY && num_online_cpus() == 1)
+			pr_warn("Unable to remove last online CPU %pOFn\n", dn);
+		else
+			pr_warn("Failed to offline CPU %pOFn, rc: %d\n", dn, rc);
+
 		return -EINVAL;
 	}
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-22 23:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-05 17:38 [PATCH 1/1] hotplug-cpu.c: show 'last online CPU' error in dlpar_cpu_remove() Daniel Henrique Barboza
2021-03-18  9:59 ` Daniel Henrique Barboza
2021-03-19 11:26   ` Michael Ellerman
2021-03-22 23:30     ` Daniel Henrique Barboza

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).