[PATCH v3] tst-{pthread|sched}-affinity-inheritance: Only use in-mask CPUs in affinity mask.

Florian Weimer fweimer@redhat.com
Thu Feb 5 17:54:38 GMT 2026


* Stefan Liebler:

> On s390x, the two tests are failing on a lpar with linux 6.18 booted with nosmt:
> FAIL:  misc/tst-sched-affinity-inheritance
> FAIL:  nptl/tst-pthread-affinity-inheritance
>
> Both tests were failing because they are claiming that the CPU affinity mask was
> not correctly inherited in the forked process/thread.
> The error already happened before forking, as the mask was set up to use
> CPUs 0-14 in set_cpu_mask().  But according to e.g. lscpu or the line
> "Cpus_allowed_list" in /proc/self/status, only the following CPUs were in mask at startup:
> 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
> while 1, 3, 5, ... were configured, but not online.
>
> Now the test first gets the current CPU mask at startup in do_test() and
> set_cpu_mask() only selects those available CPUs.  The test is now just
> counting the available CPUs instead of relying on get_nprocs().  This allows
> to run the test even if it was already limited via taskset.
>
> Therefore both concrete tests now have the get_my_affinity() function.  This
> also allows to implement verify_my_affinity() in the common skeleton.
>
> In order to ensure that the affinity mask is really set as expected,
> verify_my_affinity() is now also called before forking a new process or
> creating a new thread.
>
> For also printing the list of mismatched CPU IDs in xor_set in
> verify_my_affinity(), the argument order of CPU_ISSET_S is now fixed.
> Furthermore we now keep iterating over all configured CPUs to print
> the list of cpucount IDs instead of iterating over the first nproc CPUs.
> ---
>  nptl/tst-pthread-affinity-inheritance.c       | 41 ++--------
>  nptl/tst-skeleton-affinity-inheritance.c      | 77 +++++++++++++++----
>  .../linux/tst-sched-affinity-inheritance.c    | 40 ++--------
>  3 files changed, 76 insertions(+), 82 deletions(-)

This version looks okay to me.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian



More information about the Libc-alpha mailing list