KOSAKI Motohiro fa9dc265ac cpumask: fix compat getaffinity
Commit a45185d2d "cpumask: convert kernel/compat.c" broke libnuma, which
abuses sched_getaffinity to find out NR_CPUS in order to parse
/sys/devices/system/node/node*/cpumap.

On NUMA systems with less than 32 possibly CPUs, the current
compat_sys_sched_getaffinity now returns '4' instead of the actual
NR_CPUS/8, which makes libnuma bail out when parsing the cpumap.

The libnuma call sched_getaffinity(0, bitmap, 4096) at first.  It mean
the libnuma expect the return value of sched_getaffinity() is either len
argument or NR_CPUS.  But it doesn't expect to return nr_cpu_ids.

Strictly speaking, userland requirement are

1) Glibc assume the return value mean the lengh of initialized
   of mask argument. E.g. if sched_getaffinity(1024) return 128,
   glibc make zero fill rest 896 byte.
2) Libnuma assume the return value can be used to guess NR_CPUS
   in kernel. It assume len-arg<NR_CPUS makes -EINVAL. But
   it try len=4096 at first and 4096 is always bigger than
   NR_CPUS. Then, if we remove strange min_length normalization,
   we never hit -EINVAL case.

sched_getaffinity() already solved this issue.  This patch adapts
compat_sys_sched_getaffinity() to match the non-compat case.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Ken Werner <ken.werner@web.de>
Cc: stable@kernel.org
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-19 11:48:18 -07:00
..
2009-09-21 14:29:21 +02:00
2009-06-24 00:02:38 -04:00
2010-05-19 11:48:18 -07:00
2010-05-06 18:49:20 +02:00
2009-09-18 09:48:52 -07:00
2010-04-15 09:36:16 +02:00
2009-06-16 19:47:48 -07:00
2009-12-14 23:55:34 +01:00
2010-05-11 17:33:42 -07:00
2010-05-11 17:08:24 +02:00
2010-05-14 19:45:06 -07:00
2010-02-10 17:47:17 -08:00
2010-03-06 11:26:32 -08:00
2010-04-02 20:12:05 +02:00
2010-03-06 11:26:33 -08:00
2010-03-12 15:52:32 -08:00
2010-04-24 11:31:24 -07:00
2010-03-06 11:26:23 -08:00
2009-09-23 18:13:10 -07:00
2010-05-10 08:48:39 +02:00
2009-06-18 13:03:55 -07:00