[ping][PATCH v1.1] tests: Verify inheritance of cpu affinity
Samuel Thibault
samuel.thibault@aquilenet.fr
Fri Jan 10 16:35:26 GMT 2025
Siddhesh Poyarekar, le ven. 10 janv. 2025 11:27:35 -0500, a ecrit:
> On 2025-01-10 10:53, Samuel Thibault wrote:
> > 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.
> >
>
> The Linux man page says this (emphasis mine):
>
> CPU_ALLOC_SIZE()
> Return the size in bytes of the CPU set that would be needed
> to hold CPUs in the range 0 to num_cpus-1. **This macro provides the value
> that can be used for the setsize argument in the CPU_*_S() macros described
> below**.
Ah, right, sorry, the "setsize" denomination is confusing.
Samuel
More information about the Libc-alpha
mailing list