Hi Bert!
.TP
.B ENOMEM
.RB ( pthread_attr_setaffinity_np ())
Could not allocate memory.
Correct. However, the glibc looks somewhat suspicious to me: I had expected
the memory allocated by iattr->cpuset to be bounded (by the size of the
underlying kernel structure).
But this kernel structure is not bounded, it depends on the compile
time constant CONFIG_NR_CPUS (or in the future on the kernel runtime
variable nr_cpus_id), therefore glibc can't know this a-priori. (but I
haven't looked into the code)
AFAICS, the kernel structure size is determined at runtime by glibc on
the first call of pthread_setaffinity_np() or
pthread_attr_setaffinity_np(). Please refer to the function
__determine_cpumask_size() in
nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c
Once you know this structure size, there is no reason to allocate a
bigger room for the attribute cpuset iattr->cpuset. As of glibc-2.7, the
memory size allocated is based on the cupsetsize argument passed to
pthread_attr_setaffinity_np() without respect to the underlying kernel
structure.
Of course the Linux & Glibc folks might have some future plans that may
not be easily inferred from the actual source.
Loïc.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html