From: Hiroki Awata <castaneai@castaneai.net> get_system_affinity_mask() computes the affinity mask from peb->NumberOfProcessors. When NumberOfProcessors is reduced by cgroup CPU limits, this produces a mask that does not reflect the actual CPUs available to the process. Use system_cpu_mask from the logical processor info instead, which represents the real hardware topology. Fall back to NumberOfProcessors when system_cpu_mask is not yet initialized. Signed-off-by: Hiroki Awata <castaneai@castaneai.net> --- dlls/ntdll/unix/system.c | 2 +- dlls/ntdll/unix/unix_private.h | 1 + dlls/ntdll/unix/virtual.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index a864454159a..4edf04c9842 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -259,7 +259,7 @@ static SYSTEM_LOGICAL_PROCESSOR_INFORMATION *logical_proc_info; static unsigned int logical_proc_info_len, logical_proc_info_alloc_len; static SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *logical_proc_info_ex; static unsigned int logical_proc_info_ex_size, logical_proc_info_ex_alloc_size; -static ULONG_PTR system_cpu_mask; +ULONG_PTR system_cpu_mask; static pthread_mutex_t timezone_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index a9e8f522892..ebb44a9f63d 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -277,6 +277,7 @@ extern NTSTATUS system_time_precise( void *args ); extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ); extern void *anon_mmap_alloc( size_t size, int prot ); extern void virtual_init(void); +extern ULONG_PTR system_cpu_mask; extern ULONG_PTR get_system_affinity_mask(void); extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info, BOOL wow64 ); extern NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size, diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index e3fe3311928..a400744f6e6 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -3722,7 +3722,10 @@ void virtual_init(void) */ ULONG_PTR get_system_affinity_mask(void) { - ULONG num_cpus = peb->NumberOfProcessors; + ULONG num_cpus; + + if (system_cpu_mask) return system_cpu_mask; + num_cpus = peb->NumberOfProcessors; if (num_cpus >= sizeof(ULONG_PTR) * 8) return ~(ULONG_PTR)0; return ((ULONG_PTR)1 << num_cpus) - 1; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10466