http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58642
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, looking at kernel sources, it seems it returns EINVAL: if ((len * BITS_PER_BYTE) < nr_cpu_ids) return -EINVAL; so the question is how to find what your nr_cpu_ids is and how to (cheaply) query it from userland. I was using sysconf (_SC_NPROCESSORS_CONF) for that, which is what I saw when googling around for what upper bound to pass to pthread_getaffinity_np when I want to dynamically support more than 1024 CPUs, but thought it would work fine to pass just CPU_ALLOC_SIZE of the sysconf return value. What do you get from getconf -a | grep _NPROCESSORS ? What is the minimum cpusetsize that pthread_getaffinity_np doesn't fail with? ls -l /sys/devices/system/cpu/ ? I'd strongly prefer not to use say minimum of CPU_ALLOC_SIZE (sysconf (_SC_NPROCESSORS_CONF)) and CPUSETSIZE, I need cpusetsize sized bitmap for every place in the OMP_PLACES list (or every thread, core resp. socket), so having to allocate 128 bytes per each rather than say 8 on <= 64 CPU box sounds overkill to me.