[PATCH v2] tst-{pthread|sched}-affinity-inheritance: Only use in-mask CPUs in affinity mask.
Stefan Liebler
stli@linux.ibm.com
Thu Feb 5 12:06:52 GMT 2026
On 2/4/26 10:56, Stefan Liebler wrote:
> On 2/2/26 10:53, Florian Weimer wrote:
>> * Stefan Liebler:
>>
>>> + /* Only use CPUs which were in mask at start of the test process. */
>>> CPU_ZERO_S (param->size, param->set);
>>> - while (cpus > 0)
>>> - CPU_SET_S (--cpus, param->size, param->set);
>>> + for (int cur = 0; cpus > 0; cur++)
>>> + {
>>> + if (CPU_ISSET_S (cur, param->size, param->set_at_startup))
>>> + {
>>> + CPU_SET_S (cur, param->size, param->set);
>>> + cpus--;
>>> + }
>>> + }
>>
>> Sorry, my advice there was wrong. This is now an endless loop when
>> running something like:
>>
>> taskset -c 5 make t=nptl/tst-pthread-affinity-inheritance test
>>
>> Florian
>>
> Makes sense, you are right.
> But with the "extra check" in the loop-condition (cur <
> param->nproc_configured), the test just fails with ...
> $ taskset -c 5 make t=nptl/tst-pthread-affinity-inheritance test
> error: tst-skeleton-affinity-inheritance.c:74: Failed to add all
> requested CPUs to the affinity set
> ... as it tries to add nproc CPUs to the set.
>
> But we can also get rid of test_param->nproc at all. Instead in
> set_cpu_mask(), the number of CPUs will be based on
> CPU_COUNT_S(set_at_startup). Then the test works also with taskset'ing
> to one CPU. Then the "extra check" is also not needed. I'll send a V3
> with this change shortly (if you won't have opposed in between).
>
> Thanks,
> Stefan
Sorry, I didn't make it yesterday.
Now v3 is posted:
"[PATCH v3] tst-{pthread|sched}-affinity-inheritance: Only use in-mask
CPUs in affinity mask."
https://inbox.sourceware.org/libc-alpha/20260205120308.1831024-1-stli@linux.ibm.com/T/#u
Thanks,
Stefan
More information about the Libc-alpha
mailing list