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

Samuel Thibault samuel.thibault@aquilenet.fr
Fri Jan 10 15:53:00 GMT 2025


Hello,

Siddhesh Poyarekar, le lun. 06 janv. 2025 12:08:10 -0500, a ecrit:
> > +static void
> > +verify_my_affinity (int nproc, size_t size, const cpu_set_t *expected_set)
> > +{
> > +  cpu_set_t *set = CPU_ALLOC (nproc);
> > +  cpu_set_t *xor_set = CPU_ALLOC (nproc);
> > +
> > +  if (set == NULL || xor_set== NULL)
> > +    FAIL_EXIT1 ("verify_my_affinity: Failed to allocate cpuset: %m\n");
> > +
> > +  int ret = pthread_getaffinity_np (pthread_self (), size, set);
> > +  if (ret != 0)
> > +    FAIL ("pthread_getaffinity_np returned %d (%s)", ret, strerror (ret));
> > +
> > +  CPU_XOR_S (size, xor_set, expected_set, set);

Instead of size, it should be nproc? AFAIK CPU_XOR_S takes the set size,
not the number of bytes.

> > +  int cpucount = CPU_COUNT_S (size, xor_set);
> > +
> > +  if (cpucount > 0)
> > +    {
> > +      FAIL ("Affinity mask not inherited, "
> > +	    "following %d CPUs mismatched in the expected and actual sets: ",
> > +	    cpucount);
> > +      for (int cur = 0; cur < nproc && cpucount >= 0; cur++)
> > +	if (CPU_ISSET_S (size, cur, xor_set))

And same here and the other CPU_FOO_S places.

Samuel


More information about the Libc-alpha mailing list