Hi Christian,

On 3/8/2025 9:11 AM, Christian Franke via Cygwin wrote:
Testcase:

$ grep processor /proc/cpuinfo | tail -1 # i7-14700K
processor       : 27

$ sleep 60 & taskset 0x1 sleep 60 &
[1] 62094
[2] 62095

$ taskset -p 62094
pid 62094's current affinity mask: fffffff

$ taskset -p 62095
pid 62095's current affinity mask: fffffff


Another test shows that the affinity mask is correctly set to 0x1 by sched_setaffinity().

In sched.cc:__sched_getaffinity_sys(), GetProcessAffinityMask() is called, but its 'procmask' result is never used. The returned cpu_set is build using groupmask(__get_cpus_per_group ()) which is constant, here 0xfffffff. The original commit 641ecb07 likely worked (until 687c4bad^) on older Windows versions which did not support cpu groups.

I don't know how to fix this for systems with more than one cpu group, so no patch provided.

It might be needed to handle interesting corner cases: "If the process had explicitly set the affinity of one or more of its threads outside of the process' primary group, the function returns zero for both affinity masks." https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase- getprocessaffinitymask

Thanks very much for the report and diagnosis.  I will investigate shortly.

..mark

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to