[PATCH] affinity-inheritance: Overallocate CPU sets
Stefan Liebler
stli@linux.ibm.com
Mon Jan 13 13:09:04 GMT 2025
On 10.01.25 19:01, Siddhesh Poyarekar wrote:
> Some kernels on S390 appear to return a CPU affinity mask based on
> configured processors rather than the ones online. Overallocate the CPU
> set to match that, but operate only on the ones online.
>
> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
> ---
> nptl/tst-skeleton-affinity-inheritance.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/nptl/tst-skeleton-affinity-inheritance.c b/nptl/tst-skeleton-affinity-inheritance.c
> index 6de6d9c942..e6b778e5a7 100644
> --- a/nptl/tst-skeleton-affinity-inheritance.c
> +++ b/nptl/tst-skeleton-affinity-inheritance.c
> @@ -129,13 +129,16 @@ do_one_test (void *arg)
> static int
> do_test (void)
> {
> + /* Large enough in case the kernel decides to return the larger mask. This
> + seems to happen on some kernels for S390x. */
> + int num_configured_cpus = get_nprocs_conf ();
> int num_cpus = get_nprocs ();
>
> struct test_param param =
> {
> .nproc = num_cpus,
> - .set = CPU_ALLOC (num_cpus),
> - .size = CPU_ALLOC_SIZE (num_cpus),
> + .set = CPU_ALLOC (num_configured_cpus),
> + .size = CPU_ALLOC_SIZE (num_configured_cpus),
> .entry = true,
> };
>
Hi Siddhesh,
the online vs configured CPUs is the solution as sched_getaffinity
syscall otherwise fails with EINVAL.
But we also have to adjust the other CPU_ALLOCs in the
verify_my_affinity functions. Otherwise the getaffinity functions are
called with size for configured-CPUs but a set only suitable for the
online-CPUs.
With the attached diff on top of your patch, both tests are passing on
my s390x(64bit)/s390(31bit) machines.
Thanks,
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20250113_sid_affinity_fix.patch
Type: text/x-patch
Size: 3017 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250113/d5c82746/attachment-0001.bin>
More information about the Libc-alpha
mailing list