WSL2-Linux-Kernel/arch
Zhang Rui c09a7b6190 x86/topology: Fix erroneous smp_num_siblings on Intel Hybrid platforms
commit edc0a2b595 upstream.

Traditionally, all CPUs in a system have identical numbers of SMT
siblings.  That changes with hybrid processors where some logical CPUs
have a sibling and others have none.

Today, the CPU boot code sets the global variable smp_num_siblings when
every CPU thread is brought up. The last thread to boot will overwrite
it with the number of siblings of *that* thread. That last thread to
boot will "win". If the thread is a Pcore, smp_num_siblings == 2.  If it
is an Ecore, smp_num_siblings == 1.

smp_num_siblings describes if the *system* supports SMT.  It should
specify the maximum number of SMT threads among all cores.

Ensure that smp_num_siblings represents the system-wide maximum number
of siblings by always increasing its value. Never allow it to decrease.

On MeteorLake-P platform, this fixes a problem that the Ecore CPUs are
not updated in any cpu sibling map because the system is treated as an
UP system when probing Ecore CPUs.

Below shows part of the CPU topology information before and after the
fix, for both Pcore and Ecore CPU (cpu0 is Pcore, cpu 12 is Ecore).
...
-/sys/devices/system/cpu/cpu0/topology/package_cpus:000fff
-/sys/devices/system/cpu/cpu0/topology/package_cpus_list:0-11
+/sys/devices/system/cpu/cpu0/topology/package_cpus:3fffff
+/sys/devices/system/cpu/cpu0/topology/package_cpus_list:0-21
...
-/sys/devices/system/cpu/cpu12/topology/package_cpus:001000
-/sys/devices/system/cpu/cpu12/topology/package_cpus_list:12
+/sys/devices/system/cpu/cpu12/topology/package_cpus:3fffff
+/sys/devices/system/cpu/cpu12/topology/package_cpus_list:0-21

Notice that the "before" 'package_cpus_list' has only one CPU.  This
means that userspace tools like lscpu will see a little laptop like
an 11-socket system:

-Core(s) per socket:  1
-Socket(s):           11
+Core(s) per socket:  16
+Socket(s):           1

This is also expected to make the scheduler do rather wonky things
too.

[ dhansen: remove CPUID detail from changelog, add end user effects ]

CC: stable@kernel.org
Fixes: bbb65d2d36 ("x86: use cpuid vector 0xb when available for detecting cpu topology")
Fixes: 95f3d39ccf ("x86/cpu/topology: Provide detect_extended_topology_early()")
Suggested-by: Len Brown <len.brown@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20230323015640.27906-1-rui.zhang%40intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-30 13:55:31 +01:00
..
alpha alpha: fix R_ALPHA_LITERAL reloc for large modules 2023-03-17 08:49:01 +01:00
arc
arm ARM: dts: stm32: fix AV96 board SAI2 pin muxing on stm32mp15 2023-05-30 13:55:29 +01:00
arm64 arm64: Also reset KASAN tag if page is not PG_mte_tagged 2023-05-30 13:55:29 +01:00
csky
h8300
hexagon
ia64 ia64: fix an addr to taddr in huge_pte_offset() 2023-05-11 23:00:39 +09:00
m68k m68k: Move signal frame following exception on 68020/030 2023-05-30 13:55:30 +01:00
microblaze
mips MIPS: fw: Allow firmware to pass a empty env 2023-05-11 23:00:17 +09:00
nds32
nios2
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-11 23:00:37 +09:00
parisc parisc: Fix flush_dcache_page() for usage from irq context 2023-05-30 13:55:30 +01:00
powerpc powerpc/64s/radix: Fix soft dirty tracking 2023-05-24 17:36:55 +01:00
riscv RISC-V: Fix up a cherry-pick warning in setup_vm_final() 2023-05-17 11:50:31 +02:00
s390 s390/ptrace: fix PTRACE_GET_LAST_BREAK error handling 2023-04-26 13:51:50 +02:00
sh sh: nmi_debug: fix return value of __setup handler 2023-05-17 11:50:23 +02:00
sparc sparc: allow PM configs for sparc32 COMPILE_TEST 2023-03-10 09:39:33 +01:00
um UML: define RUNTIME_DISCARD_EXIT 2023-03-17 08:49:04 +01:00
x86 x86/topology: Fix erroneous smp_num_siblings on Intel Hybrid platforms 2023-05-30 13:55:31 +01:00
xtensa xtensa: fix KASAN report for show_stack 2023-04-05 11:25:00 +02:00
.gitignore
Kconfig