[PATCH v1.1] tests: Verify inheritance of cpu affinity

Siddhesh Poyarekar siddhesh@sourceware.org
Thu Jan 9 03:15:24 GMT 2025


On 2025-01-07 17:54, Adhemerval Zanella Netto wrote:
> 
> 
> On 07/01/25 19:01, Siddhesh Poyarekar wrote:
>> On 2025-01-07 15:51, Adhemerval Zanella Netto wrote:
>>>> +  /* Less CPUS for the first level, if that's possible.  */
>>>> +  if (entry && cpus > 1)
>>>> +    cpus--;
>>>
>>> I think this will always fail on CPUs with one core (there are still
>>> some for non-usual architectures).
>>>
>>
>> For single CPU systems this should end up having the same mask for the first and second level tests, which shouldn't actually cause a failure. I admittedly haven't tested this though; I'll try and get a box to confirm.
> 
> I meant that with only cpu, cnpus will be zero and the test
> 
>    if (CPU_COUNT_S (param->size, param->set) == 0)
>      FAIL_EXIT1 ("Failed to add any CPUs to the affinity set\n");
> 
> will fail because no cpu will be added.
> 

OK I just tested this on a single core box and it worked correctly. 
nproc returns 1 for a single cpu, which results in the single CPU0 being 
set in both the cpusets in the test:

$ nproc
1
$ cat misc/tst-sched-affinity-inheritance.test-result
PASS: misc/tst-sched-affinity-inheritance
original exit status 0
$ cat misc/tst-sched-affinity-inheritance.out
86756:86756 Start test run
86756:86756 do_one_test: fork
86757:86757    do_one_test: fork
86758:86758        child
86757:86757    do_one_test: thread
86757:86759        child
86756:86756 do_one_test: thread
86756:86760    do_one_test: fork
86761:86761        child
86756:86760    do_one_test: thread
86756:86762        child
$ cat nptl/tst-pthread-affinity-inheritance.test-result
PASS: nptl/tst-pthread-affinity-inheritance
original exit status 0
$ cat nptl/tst-pthread-affinity-inheritance.out
142993:142993 Start test run
142993:142993 do_one_test: fork
142994:142994    do_one_test: fork
142995:142995        child
142994:142994    do_one_test: thread
142994:142996        child
142993:142993 do_one_test: thread
142993:142997    do_one_test: fork
142998:142998        child
142993:142997    do_one_test: thread
142993:142999        child

Thanks,
Sid


More information about the Libc-alpha mailing list