smpboot: correctly update number of booted cores
PATCH 1/1 smpboot: correctly update number of booted cores
Without this fix, /proc/cpuinfo will display an incorrect amount of CPU cores, after bringing them offline and online again, as exemplified below:
$ cat /proc/cpuinfo | grep cores cpu cores : 4 cpu cores : 8 cpu cores : 8 cpu cores : 20 cpu cores : 4 cpu cores : 3 cpu cores : 2 cpu cores : 2
This patch fixes this by always zeroing the booted_cores variable upon turning off a logical CPU.
--- arch/x86/kernel/smpboot.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/smpboot.c +1 -0
@@ -1437,6 +1437,7 @@ static void remove_siblinginfo(int cpu)cpumask_clear (topology_sibling_cpumask (cpu));cpumask_clear (topology_core_cpumask (cpu)); c->cpu_core_id =0 ; + c->booted_cores =0 ;cpumask_clear_cpu (cpu, cpu_sibling_setup_mask);recompute_smt_state (); }
Signature · 1 line
2.14.3
Quoted 14 lines · Samuel Neves
Without this fix,
/proc/cpuinfowill display an incorrect amount of CPU cores, after bringing them offline and online again, as exemplified below:$ cat /proc/cpuinfo | grep cores cpu cores : 4 cpu cores : 8 cpu cores : 8 cpu cores : 20 cpu cores : 4 cpu cores : 3 cpu cores : 2 cpu cores : 2
Quoted 4 lines
This patch fixes this by always zeroing the
booted_coresvariable upon turning off a logical CPU.Signed-off-by Samuel Neves <[email protected]>
Yes, tested it in Qemu with 15 hot-pluggable CPUs, like below
...
-smp 1,maxcpus=16,sockets=2,cores=4,threads=2
...
When a new CPU bringups a new core, for each core in package, Linux increments the booted_cores for this new cpu in set_cpu_sibling_map(). Due to the uncleared booted_cores, this incorrect number of CPU cores
will be shown.
Quoted 17 lines
--- arch/x86/kernel/smpboot.c | 1 + 1 file changed, 1 insertion(+)arch/x86/kernel/smpboot.c +1
-0@@ -1437,6 +1437,7 @@ static void remove_siblinginfo(int cpu)cpumask_clear (topology_sibling_cpumask (cpu));cpumask_clear (topology_core_cpumask (cpu)); c->cpu_core_id =0 ; + c->booted_cores =0 ;cpumask_clear_cpu (cpu, cpu_sibling_setup_mask);recompute_smt_state (); }
tip-bot for Samuel Neves
merge bot[tip:x86/urgent] x86/topology: Update the 'cpu cores' field in /proc/cpuinfo correctly across CPU hotplug operations
In reply to Samuel Nevesx86/topology: Update the 'cpu cores' field in /proc/cpuinfo correctly across CPU hotplug operations
Commit-ID: 4596749339e06dc7a424fc08a15eded850ed78b7 Gitweb: https://git.kernel.org/tip/4596749339e06dc7a424fc08a15eded850ed78b7 Author: Samuel Neves <[email protected]> AuthorDate: Wed, 21 Feb 2018 20:50:36 +0000 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 23 Feb 2018 08:47:47 +0100
x86/topology: Update the 'cpu cores' field in /proc/cpuinfo correctly across CPU hotplug operations
Without this fix, /proc/cpuinfo will display an incorrect amount of CPU cores, after bringing them offline and online again, as exemplified below:
$ cat /proc/cpuinfo | grep cores cpu cores : 4 cpu cores : 8 cpu cores : 8 cpu cores : 20 cpu cores : 4 cpu cores : 3 cpu cores : 2 cpu cores : 2
This patch fixes this by always zeroing the booted_cores variable upon turning off a logical CPU.
--- arch/x86/kernel/smpboot.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/smpboot.c +1 -0
@@ -1437,6 +1437,7 @@ static void remove_siblinginfo(int cpu)cpumask_clear (topology_sibling_cpumask (cpu));cpumask_clear (topology_core_cpumask (cpu)); c->cpu_core_id =0 ; + c->booted_cores =0 ;cpumask_clear_cpu (cpu, cpu_sibling_setup_mask);recompute_smt_state (); }