[PATCH] affinity-inheritance: Overallocate CPU sets

Siddhesh Poyarekar siddhesh@sourceware.org
Fri Jan 10 18:01:50 GMT 2025


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,
     };
 
-- 
2.47.1



More information about the Libc-alpha mailing list