Re: [PATCH 2/3] powerpc/cpuhp: BUG -> WARN conversion in offline path

From
Christophe Leroy <hidden>
Date
2021-09-20 14:27:05
Reply to
Nathan Lynch, 2021-09-20

Le 20/09/2021 à 15:55, Nathan Lynch a écrit :
If, due to bugs elsewhere, we get into unregister_cpu_online() with a CPU
that isn't marked hotpluggable, we can emit a warning and return an
appropriate error instead of crashing.
Is it only a bug situation, or is it something that can happen in real life ?

If it can happen in real life, kernels with panic_on_warn will still be impacted.
quoted hunk ↗ jump to hunk
Signed-off-by: Nathan Lynch <redacted>
---
  arch/powerpc/kernel/sysfs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index defecb3b1b15..08d8072d6e7a 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -928,7 +928,8 @@ static int unregister_cpu_online(unsigned int cpu)
  	struct device_attribute *attrs, *pmc_attrs;
  	int i, nattrs;
  
-	BUG_ON(!c->hotpluggable);
+	if (WARN_RATELIMIT(!c->hotpluggable, "cpu %d can't be offlined\n", cpu))
+		return -EBUSY;
  
  #ifdef CONFIG_PPC64
  	if (cpu_has_feature(CPU_FTR_SMT))
Thread (11 messages) 11 messages, 4 authors, last reply 2021-09-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help