Skip to content

Commit

Permalink
x86/topology: Use total_cpus not nr_cpu_ids for logical packages
Browse files Browse the repository at this point in the history
nr_cpu_ids can be limited on the command line via nr_cpus=. That can break the
logical package management because it results in a smaller number of packages,
but the cpus to online are occupying the full package space as the hyper
threads are enumerated after the physical cores typically.

total_cpus is the real possible cpu space not limited by nr_cpus command line
and gives us the proper number of packages.

Reported-by: Mike Galbraith <[email protected]>
Fixes: 1f12e32 ("x86/topology: Create logical package id")
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Xiong Zhou <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Andreas Herrmann <[email protected]>
Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1603181254330.3978@nanos
  • Loading branch information
KAGA-KOKO committed Mar 19, 2016
1 parent 63d1e99 commit 3e8db22
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,14 @@ static void __init smp_init_package_map(void)
* By not including this we'll sometimes over-estimate the number of
* logical packages by the amount of !present siblings, but this is
* still better than MAX_LOCAL_APIC.
*
* We use total_cpus not nr_cpu_ids because nr_cpu_ids can be limited
* on the command line leading to a similar issue as the HT disable
* problem because the hyperthreads are usually enumerated after the
* primary cores.
*/
ncpus = boot_cpu_data.x86_max_cores;
__max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus);
__max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);

/*
* Possibly larger than what we need as the number of apic ids per
Expand Down

0 comments on commit 3e8db22

Please sign in to comment.