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

Stefan Liebler stli@linux.ibm.com
Fri Jan 10 13:01:38 GMT 2025


On 09.01.25 15:17, Adhemerval Zanella Netto wrote:
> 
> 
> On 09/01/25 00:15, Siddhesh Poyarekar wrote:
>> 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
> 
> Fair enough, I now notice the decrement is done only positive.  LGTM then.


Hi,
I observe testfails on s390x/s390 with both of the new tests:
FAIL: misc/tst-sched-affinity-inheritance
FAIL: nptl/tst-pthread-affinity-inheritance
(See attached files for more full output)

To be honest, so far I have not looked into details, but I wanted to
report to see if others also observe errors.

As information, my system reports this
$ nproc
16
$ nproc --all
200

Bye,
Stefan
-------------- next part --------------
2489536:2489536 Start test run
2489536:2489536 do_one_test: fork
error: tst-pthread-affinity-inheritance.c:47: pthread_getaffinity_np returned 22 (Invalid argument)
error: tst-pthread-affinity-inheritance.c:55: Affinity mask not inherited, following 37 CPUs mismatched in the expected and actual sets: 

2489537:2489537    do_one_test: fork
2489538:2489538        child
error: tst-pthread-affinity-inheritance.c:47: pthread_getaffinity_np returned 22 (Invalid argument)
error: tst-pthread-affinity-inheritance.c:55: Affinity mask not inherited, following 19 CPUs mismatched in the expected and actual sets: 

2489537:2489537    do_one_test: thread
2489537:2489539        child
error: tst-pthread-affinity-inheritance.c:47: pthread_getaffinity_np returned 22 (Invalid argument)
error: tst-pthread-affinity-inheritance.c:55: Affinity mask not inherited, following 36 CPUs mismatched in the expected and actual sets: 

2489536:2489536 do_one_test: thread
error: tst-pthread-affinity-inheritance.c:47: pthread_getaffinity_np returned 22 (Invalid argument)
error: tst-pthread-affinity-inheritance.c:55: Affinity mask not inherited, following 37 CPUs mismatched in the expected and actual sets: 

2489536:2489540    do_one_test: fork
2489541:2489541        child
error: tst-pthread-affinity-inheritance.c:47: pthread_getaffinity_np returned 22 (Invalid argument)
error: tst-pthread-affinity-inheritance.c:55: Affinity mask not inherited, following 34 CPUs mismatched in the expected and actual sets: 

2489536:2489540    do_one_test: thread
2489536:2489542        child
error: tst-pthread-affinity-inheritance.c:47: pthread_getaffinity_np returned 22 (Invalid argument)
error: tst-pthread-affinity-inheritance.c:55: Affinity mask not inherited, following 36 CPUs mismatched in the expected and actual sets: 

error: 12 test failures
-------------- next part --------------
3468274:3468274 Start test run
3468274:3468274 do_one_test: fork
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:47: sched_getaffinity returned -1 (Unknown error -1)
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:55: Affinity mask not inherited, following 37 CPUs mismatched in the expected and actual sets:


3468276:3468276    do_one_test: fork
3468278:3468278        child
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:47: sched_getaffinity returned -1 (Unknown error -1)
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:55: Affinity mask not inherited, following 19 CPUs mismatched in the expected and actual sets:


3468276:3468276    do_one_test: thread
3468276:3468279        child
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:47: sched_getaffinity returned -1 (Unknown error -1)
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:55: Affinity mask not inherited, following 36 CPUs mismatched in the expected and actual sets:


3468274:3468274 do_one_test: thread
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:47: sched_getaffinity returned -1 (Unknown error -1)
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:55: Affinity mask not inherited, following 37 CPUs mismatched in the expected and actual sets:


3468274:3468281    do_one_test: fork
3468282:3468282        child
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:47: sched_getaffinity returned -1 (Unknown error -1)
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:55: Affinity mask not inherited, following 34 CPUs mismatched in the expected and actual sets:


3468274:3468281    do_one_test: thread
3468274:3468283        child
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:47: sched_getaffinity returned -1 (Unknown error -1)
error: ../sysdeps/unix/sysv/linux/tst-sched-affinity-inheritance.c:55: Affinity mask not inherited, following 36 CPUs mismatched in the expected and actual sets:


error: 12 test failures


More information about the Libc-alpha mailing list