Hi! As reported by Vincenzo, the testcase didn't try to verify affinity behavior if _SC_NPROCESSORS_CONF returned value was smaller than kernel's internal mask size (e.g. because of CPU hotplug support). Fixed thusly:
2013-10-08 Jakub Jelinek <ja...@redhat.com> * testsuite/libgomp.c/affinity-1.c (min_cpusetsize): New variable. (pthread_getaffinity_np): Set it when setting contig_cpucount. (print_affinity): Use it for size, only use sysconf value if that is not set and if it is smaller than sizeof (cpu_set_t), use sizeof (cpu_set_t). --- libgomp/testsuite/libgomp.c/affinity-1.c.jj 2013-10-07 14:09:52.000000000 +0200 +++ libgomp/testsuite/libgomp.c/affinity-1.c 2013-10-08 09:10:26.439380189 +0200 @@ -65,6 +65,7 @@ struct places }; unsigned long contig_cpucount; +unsigned long min_cpusetsize; #if defined (HAVE_PTHREAD_AFFINITY_NP) && defined (_SC_NPROCESSORS_CONF) \ && defined (CPU_ALLOC_SIZE) @@ -94,6 +95,7 @@ pthread_getaffinity_np (pthread_t thread if (!CPU_ISSET_S (i, cpusetsize, cpuset)) break; contig_cpucount = i; + min_cpusetsize = cpusetsize; } return ret; } @@ -105,8 +107,15 @@ print_affinity (struct place p) static unsigned long size; if (size == 0) { - size = sysconf (_SC_NPROCESSORS_CONF); - size = CPU_ALLOC_SIZE (size); + if (min_cpusetsize) + size = min_cpusetsize; + else + { + size = sysconf (_SC_NPROCESSORS_CONF); + size = CPU_ALLOC_SIZE (size); + if (size < sizeof (cpu_set_t)) + size = sizeof (cpu_set_t); + } } cpu_set_t *cpusetp = (cpu_set_t *) alloca (size); if (pthread_getaffinity_np (pthread_self (), size, cpusetp) == 0) Jakub