Skip to contentSkip to conversation

MIPS: CPU#0 is not hotpluggable

PATCH Applied Huacai Chen 5 participants 11 messages Jul 16, 2020 – Jul 26, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 MIPS: CPU#0 is not hotpluggable

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

---
 arch/mips/kernel/topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/topology.c +1 -1
index cd3e1f8..08ad637 100644
@@ -20,7 +20,7 @@ static int __init topology_init(void)
 	for_each_present_cpu(i) {
 		struct cpu *c = &per_cpu(cpu_devices, i);
 
-		c->hotpluggable = 1;
+		c->hotpluggable = !!i;
 		ret = register_cpu(c, i);
 		if (ret)
 			printk(KERN_WARNING "topology_init: register_cpu %d "
Signature · 1 line
2.7.0
#1 lore raw

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,

num).cpu.hotpluggable = 1;

Quoted 26 lines · Huacai Chen

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

---
 arch/mips/kernel/topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/topology.c +1 -2
index cd3e1f8..08ad637 100644
@@ -20,7 +20,7 @@ static int __init topology_init(void)
        for_each_present_cpu(i) {
                struct cpu *c = &per_cpu(cpu_devices, i);
 
-               c->hotpluggable = 1;
+               c->hotpluggable = !!i;
                ret = register_cpu(c, i);
                if (ret)
                        printk(KERN_WARNING "topology_init: register_cpu %d "
--

2.7.0

maintainer
#2 lore raw
Quoted 22 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,
Quoted 6 lines

num).cpu.hotpluggable = 1;

Quoted 3 lines · Huacai Chen

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

What userspace tools are confused by this? They should be able to handle a cpu not being able to be removed, right?

Quoted 15 lines
Quoted 15 lines
---
 arch/mips/kernel/topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/topology.c +0 -0
index cd3e1f8..08ad637 100644
@@ -20,7 +20,7 @@ static int __init topology_init(void)
        for_each_present_cpu(i) {
                struct cpu *c = &per_cpu(cpu_devices, i);
 
Quoted 2 lines

arch/mips/kernel/topology.c static int __init topology_init(void) · line 23

Quoted 2 lines
arch/mips/kernel/topology.c +1 -1
-               c->hotpluggable = 1;
+               c->hotpluggable = !!i;

Seems to be the same as what xtensa did, so it's probably not a big deal.

thanks,

greg k-h

#3 lore raw

Hi Greg,

Quoted 26 lines · Greg KH
Quoted 24 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,

num).cpu.hotpluggable = 1;

Quoted 7 lines
Quoted 4 lines · Huacai Chen
Quoted 3 lines

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

What userspace tools are confused by this? They should be able to handle a cpu not being able to be removed, right?

It causes ltp's "hotplug" test fails, and ltp considers CPUs with a "online" node be hotpluggable.

Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
---
 arch/mips/kernel/topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/topology.c +0 -0
index cd3e1f8..08ad637 100644
@@ -20,7 +20,7 @@ static int __init topology_init(void)
        for_each_present_cpu(i) {
                struct cpu *c = &per_cpu(cpu_devices, i);
 
Quoted 2 lines

arch/mips/kernel/topology.c static int __init topology_init(void) · line 23

Quoted 2 lines
arch/mips/kernel/topology.c +1 -1
-               c->hotpluggable = 1;
+               c->hotpluggable = !!i;

Seems to be the same as what xtensa did, so it's probably not a big deal.

thanks,

greg k-h

maintainer
#4 lore raw
Quoted 31 lines · Huacai Chen

Hi Greg,

Quoted 28 lines · Greg KH
Quoted 26 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,

num).cpu.hotpluggable = 1;

Quoted 1 line · Huacai Chen
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

What userspace tools are confused by this? They should be able to handle a cpu not being able to be removed, right?

It causes ltp's "hotplug" test fails, and ltp considers CPUs with a "online" node be hotpluggable.

Is that always true?

#5 lore raw

Hi, Greg,

Quoted 36 lines · Greg KH
Quoted 34 lines · Huacai Chen

Hi Greg,

Quoted 31 lines · Greg KH
Quoted 28 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,

num).cpu.hotpluggable = 1;

Quoted 3 lines · Huacai Chen

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

What userspace tools are confused by this? They should be able to handle a cpu not being able to be removed, right?

It causes ltp's "hotplug" test fails, and ltp considers CPUs with a "online" node be hotpluggable.

Is that always true?

Yes, someone who meet the same problem report a bug to LTP, and LTP maintainer said that this should be fixed in kernel.

Huacai

maintainer
#6 lore raw
Quoted 39 lines · Huacai Chen

Hi, Greg,

Quoted 36 lines · Greg KH
Quoted 34 lines · Huacai Chen

Hi Greg,

Quoted 31 lines · Greg KH
Quoted 28 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,

num).cpu.hotpluggable = 1;

Quoted 3 lines · Huacai Chen

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

What userspace tools are confused by this? They should be able to handle a cpu not being able to be removed, right?

It causes ltp's "hotplug" test fails, and ltp considers CPUs with a "online" node be hotpluggable.

Is that always true?

Yes, someone who meet the same problem report a bug to LTP, and LTP maintainer said that this should be fixed in kernel.

So the action _always_ has to succeed and can never return an error? That feels wrong even for normal systems.

thanks,

greg k-h

#7 lore raw
Quoted 38 lines · Greg KH
Quoted 37 lines · Huacai Chen

Hi, Greg,

Quoted 34 lines · Greg KH
Quoted 33 lines · Huacai Chen

Hi Greg,

Quoted 30 lines · Greg KH
Quoted 22 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

grep hotpluggable arch -rwI

arch/riscv/kernel/setup.c:        cpu->hotpluggable = cpu_has_hotplug(i);
arch/powerpc/kernel/sysfs.c:    BUG_ON(!c->hotpluggable);
arch/powerpc/kernel/sysfs.c:            c->hotpluggable = 1;
arch/powerpc/kernel/sysfs.c:        if (cpu_online(cpu) || c->hotpluggable) {
arch/arm/kernel/setup.c:        cpuinfo->cpu.hotpluggable =
platform_can_hotplug_cpu(cpu);
arch/sh/kernel/topology.c:        c->hotpluggable = 1;
arch/ia64/kernel/topology.c:     * CPEI target, then it is hotpluggable
arch/ia64/kernel/topology.c:        sysfs_cpus[num].cpu.hotpluggable = 1;
arch/xtensa/kernel/setup.c:        cpu->hotpluggable = !!i;
arch/s390/kernel/smp.c:    c->hotpluggable = 1;
arch/mips/kernel/topology.c:        c->hotpluggable = 1;
arch/arm64/kernel/cpuinfo.c: * In case the boot CPU is hotpluggable,
we record its initial state and
arch/arm64/kernel/setup.c:        cpu->hotpluggable = cpu_can_disable(i);
arch/x86/kernel/topology.c:        per_cpu(cpu_devices,
Quoted 5 lines

num).cpu.hotpluggable = 1;

Quoted 2 lines · Huacai Chen

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

What userspace tools are confused by this? They should be able to handle a cpu not being able to be removed, right?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

It causes ltp's "hotplug" test fails, and ltp considers CPUs with a "online" node be hotpluggable.

Is that always true?

Yes, someone who meet the same problem report a bug to LTP, and LTP maintainer said that this should be fixed in kernel.

So the action _always_ has to succeed and can never return an error? That feels wrong even for normal systems.

If that returns error then it means kernel's hotplug function is not working as expected. Thus, LTP as a testsuit will consider the error as a indicator of malfunction kernel.

Thanks

- Jiaxun

Quoted 4 lines

thanks,

greg k-h

#8 lore raw
In reply to Huacai Chen
Quoted 4 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

I'm ok with the patch, I'm just wondering if this is a hardware or software limitation. If it's the latter, what needs to be done to support it ?

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#9 lore raw
Quoted 8 lines · Thomas Bogendoerfer
Quoted 4 lines · Huacai Chen

Hi, Thomas,

What do you think about this patch? Other archs also do the same thing except those support hotplug CPU#0.

I'm ok with the patch, I'm just wondering if this is a hardware or software limitation. If it's the latter, what needs to be done to support it ?

It should be a software limitation, x86 have already deal with that [1].
But there is no reason to spend extra effort on CPU0 hotplug. I don't think any user is expecting this feature.

Thanks.

[1]: https://events.static.linuxfound.org/sites/events/files/lcjpcojp13_fenghua.pdf

- Jiaxun

Quoted 3 lines

Thomas.

maintainer Applied
#10 lore raw
In reply to Huacai Chen
Quoted 8 lines · Huacai Chen

Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices /system/cpu/cpu0/online which confuses some user-space tools.

---
 arch/mips/kernel/topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]