possible_cpus broken in linux-next
Subsystems (2)
If I boot with: maxcpus=2 possible_cpus=4, I get
# grep . /sys/devices/system/cpu/cpu[0-9]*/online' /sys/devices/system/cpu/cpu1/online:1 /sys/devices/system/cpu/cpu2/online:1 /sys/devices/system/cpu/cpu3/online:1
on bad kernels, and this on working ones:
/sys/devices/system/cpu/cpu1/online:1
/sys/devices/system/cpu/cpu2/online:0
/sys/devices/system/cpu/cpu3/online:0
I also get -EINVAL if I try to re-offline them in this state. 2 and 3 don't show up in /proc/cpuinfo, so sysfs just looks broken here. This happens in a KVM guest, so it should be dirt-simple for anyone to reproduce.
I bisected it down to:
Quoted 22 lines
commit
0902a9044fa5b7a0456ea4daacec2c2b3189ba8cAuthor: Rafael J. Wysocki <[email protected]> Date: Fri May 3 00:25:49 2013 +0200Driver core: Use generic offline/online for CPU offline/online
Rework the CPU hotplug code in
drivers/base/cpu.cto use the generic offline/online support introduced previously instead of its own CPU-specific code.For this purpose, modify
cpu_subsysto provide offline and online callbacks forCONFIG_HOTPLUG_CPUset and remove the code handling the CPU-specific 'online' sysfs attribute.This modification is not supposed to change the user-observable behavior of the kernel (i.e. the 'online' attribute will be present in exactly the same place in sysfs and should trigger exactly the same actions as before).
Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Toshi Kani <[email protected]>
Quoted 14 lines · Dave Hansen
If I boot with: maxcpus=2 possible_cpus=4, I get
# grep . /sys/devices/system/cpu/cpu[0-9]*/online' /sys/devices/system/cpu/cpu1/online:1 /sys/devices/system/cpu/cpu2/online:1 /sys/devices/system/cpu/cpu3/online:1on bad kernels, and this on working ones:
/sys/devices/system/cpu/cpu1/online:1
/sys/devices/system/cpu/cpu2/online:0
/sys/devices/system/cpu/cpu3/online:0
Quoted 28 lines
I also get
-EINVALif I try to re-offline them in this state. 2 and 3 don't show up in/proc/cpuinfo, so sysfs just looks broken here. This happens in a KVM guest, so it should be dirt-simple for anyone to reproduce.I bisected it down to:
Quoted 22 lines
commit
0902a9044fa5b7a0456ea4daacec2c2b3189ba8cAuthor: Rafael J. Wysocki <[email protected]> Date: Fri May 3 00:25:49 2013 +0200Driver core: Use generic offline/online for CPU offline/online
Rework the CPU hotplug code in
drivers/base/cpu.cto use the generic offline/online support introduced previously instead of its own CPU-specific code.For this purpose, modify
cpu_subsysto provide offline and online callbacks forCONFIG_HOTPLUG_CPUset and remove the code handling the CPU-specific 'online' sysfs attribute.This modification is not supposed to change the user-observable behavior of the kernel (i.e. the 'online' attribute will be present in exactly the same place in sysfs and should trigger exactly the same actions as before).
Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Toshi Kani <[email protected]>
Thanks for the report. The following patch fixes the problem. -Toshi
====
From: Toshi Kani <[email protected]>
Subject: [PATCH] ACPI: Fix sysfs cpu/online of offlined cpus
As reported by Dave Hansen, sysfs cpu/online shows 1 for offlined cpus at boot.
https://lkml.org/lkml/2013/5/29/403
Fix this problem by initializing dev.offline with cpu_online() when registering a cpu.
--- drivers/base/cpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/cpu.c +1 -0
@@ -281,6 +281,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.bus = &cpu_subsys; cpu->dev.release = cpu_device_release; cpu->dev.offline_disabled = !cpu->hotpluggable; + cpu->dev.offline = !cpu_online (num);#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE cpu->dev.bus->uevent = arch_cpu_uevent;#endif
Signature · 1 line
1.8.1.4
Quoted 1 line · Toshi Kani
On Wed, 2013-05-29 at 10:10 -0700, Dave Hansen wrote:
:
Quoted 6 lines
Thanks for the report. The following patch fixes the problem. -Toshi
====
From: Toshi Kani <[email protected]>
Subject: [PATCH] ACPI: Fix sysfs cpu/online of offlined cpus
Typo. The subject needs to be:
Subject: [PATCH] cpu: Fix sysfs cpu/online of offlined cpus
-Toshi
Quoted 25 lines
As reported by Dave Hansen, sysfs cpu/online shows 1 for offlined cpus at boot.
https://lkml.org/lkml/2013/5/29/403Fix this problem by initializing dev.offline with
cpu_online()when registering a cpu.Reported-by Dave Hansen <[email protected]>Signed-off-by Toshi Kani <[email protected]>--- drivers/base/cpu.c | 1 + 1 file changed, 1 insertion(+)drivers/base/cpu.c +1
-0@@ -281,6 +281,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.bus = &cpu_subsys; cpu->dev.release = cpu_device_release; cpu->dev.offline_disabled = !cpu->hotpluggable; + cpu->dev.offline = !cpu_online (num);#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE cpu->dev.bus->uevent = arch_cpu_uevent;#endif
Quoted 7 lines · Toshi Kani
Quoted 1 line · Toshi Kani
On Wed, 2013-05-29 at 10:10 -0700, Dave Hansen wrote:
:
Quoted 3 lines
Thanks for the report. The following patch fixes the problem. -Toshi
Quoted 18 lines
Quoted 3 lines
====
From: Toshi Kani <[email protected]>
Subject: [PATCH] ACPI: Fix sysfs cpu/online of offlined cpusTypo. The subject needs to be:
Subject: [PATCH] cpu: Fix sysfs cpu/online of offlined cpus
-Toshi
Quoted 9 lines
As reported by Dave Hansen, sysfs cpu/online shows 1 for offlined cpus at boot.
https://lkml.org/lkml/2013/5/29/403Fix this problem by initializing dev.offline with
cpu_online()when registering a cpu.Reported-by Dave Hansen <[email protected]>Signed-off-by Toshi Kani <[email protected]>
Thanks Toshi!
Dave, can you please confirm that the problem is fixed by this patch?
Rafael
Quoted 4 lines
Quoted 4 lines
--- drivers/base/cpu.c | 1 + 1 file changed, 1 insertion(+)
Quoted 13 lines
drivers/base/cpu.c int __cpuinit register_cpu(struct cpu *cpu, int num) · line 287
Quoted 12 lines
drivers/base/cpu.c +1
-0@@ -281,6 +281,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.bus = &cpu_subsys; cpu->dev.release = cpu_device_release; cpu->dev.offline_disabled = !cpu->hotpluggable; + cpu->dev.offline = !cpu_online (num);#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE cpu->dev.bus->uevent = arch_cpu_uevent;#endif
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
z siedziba w Gdansku
ul. Slowackiego 173
80-298 Gdansk
Sad Rejonowy Gdansk Polnoc w Gdansku, VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, numer KRS 101882
NIP 957-07-52-316
Kapital zakladowy 200.000 zl
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Dave Hansen
Tested-byQuoted 4 lines · Rafael J. Wysocki
Quoted 4 lines
Quoted 4 lines
drivers/base/cpu.c +0
-0
Quoted 8 lines
Quoted 8 lines
drivers/base/cpu.c int __cpuinit register_cpu(struct cpu *cpu, int num) · line 287
Quoted 8 lines
drivers/base/cpu.c +1
-0@@ -281,6 +281,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.bus = &cpu_subsys; cpu->dev.release = cpu_device_release; cpu->dev.offline_disabled = !cpu->hotpluggable; + cpu->dev.offline = !cpu_online (num);#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE cpu->dev.bus->uevent = arch_cpu_uevent;#endif
This gets things working for me again. Thanks for the quick response!
Rafael J. Wysocki
AppliedQuoted 16 lines · Dave Hansen
Quoted 4 lines · Rafael J. Wysocki
Quoted 4 lines
Quoted 4 lines
drivers/base/cpu.c +0
-0Quoted 8 lines
Quoted 8 lines
drivers/base/cpu.c int __cpuinit register_cpu(struct cpu *cpu, int num) · line 287
Quoted 8 lines
drivers/base/cpu.c +1
-0@@ -281,6 +281,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.bus = &cpu_subsys; cpu->dev.release = cpu_device_release; cpu->dev.offline_disabled = !cpu->hotpluggable; + cpu->dev.offline = !cpu_online (num);#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE cpu->dev.bus->uevent = arch_cpu_uevent;#endif This gets things working for me again. Thanks for the quick response!
Quoted 1 line
Tested-by Dave Hansen <[email protected]>
Applied.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.