Hi all,
Recently I was helping a user troubleshoot some Ryzen performance issues. As part of that still unresolved bug (Bugzilla 43277), I found out or CPU core reporting code on Linux is not correct.
The summary is that we report all logical cores as if they were physical CPU cores. Applications also can't determine whether they are dealing with SMT / HyperThreaded cores. Essentially applications think there are twice the number of physical cores.
The issue can easily be observed through various sample applications: - Sysinternals core info application uses GetLogicalProcessorInformationEx: https://docs.microsoft.com/en-us/sysinternals/downloads/coreinfo - Example application on GetLogicalProcessorInformation: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683194(v=vs.85).a...
The root cause of the issue is in how we enumerated CPU cores. We do so by walking all logical cores in sysfs (/sys/devices/system/cpuX). Each core we report as a physical core. We are not parsing the 'thread_siblings' file, which tells us the mask of logical cores sharing a physical core. This causes us to count cores twice. This happens both on AMD and Intel.
The patch series adjusts how we enumerate logical cores on Linux by parsing 'thread_siblings' and making sure we don't add a new physical core if a sibling earlier added a physical core for the same mask and package. The cache parsing logic does something similar by parsing 'shared_cpu_map' and logical_proc_add_cache_info ignores already reported caches as well.
In addition, we are now also reporting SMT capabilities to Flags of GetLogicalProcessorInformation(Ex).
Thanks, Roderick
Roderick Colenbrander (4): ntdll: Derive number of logical CPU cores from core mask. ntdll: Report logical cores per physical core through mask. ntdll: GetLogicalProcessorInformationEx report LTP_PC_SMT for SMT cores. ntdll: GetLogicalProcessorInformation report LPT_PC_SMT for SMT cores.
dlls/ntdll/nt.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- include/winnt.h | 2 ++ 2 files changed, 42 insertions(+), 10 deletions(-)