Commit 4de373a1 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

cpumask: make cpumask_size() return "unsigned int"

CPUmasks are never big enough to warrant 64-bit code.

Space savings:

	add/remove: 0/0 grow/shrink: 1/4 up/down: 3/-17 (-14)
	Function                                     old     new   delta
	sched_init_numa                             1530    1533      +3
	compat_sys_sched_setaffinity                 160     159      -1
	sys_sched_getaffinity                        197     195      -2
	sys_sched_setaffinity                        183     176      -7
	compat_sys_sched_getaffinity                 179     172      -7

Link: http://lkml.kernel.org/r/20171204165531.GA8221@avx2Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 667b6094
...@@ -640,7 +640,7 @@ static inline int cpulist_parse(const char *buf, struct cpumask *dstp) ...@@ -640,7 +640,7 @@ static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
/** /**
* cpumask_size - size to allocate for a 'struct cpumask' in bytes * cpumask_size - size to allocate for a 'struct cpumask' in bytes
*/ */
static inline size_t cpumask_size(void) static inline unsigned int cpumask_size(void)
{ {
return BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long); return BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long);
} }
......
...@@ -355,7 +355,7 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len, ...@@ -355,7 +355,7 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,
ret = sched_getaffinity(pid, mask); ret = sched_getaffinity(pid, mask);
if (ret == 0) { if (ret == 0) {
size_t retlen = min_t(size_t, len, cpumask_size()); unsigned int retlen = min(len, cpumask_size());
if (compat_put_bitmap(user_mask_ptr, cpumask_bits(mask), retlen * 8)) if (compat_put_bitmap(user_mask_ptr, cpumask_bits(mask), retlen * 8))
ret = -EFAULT; ret = -EFAULT;
......
...@@ -4853,7 +4853,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, ...@@ -4853,7 +4853,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
ret = sched_getaffinity(pid, mask); ret = sched_getaffinity(pid, mask);
if (ret == 0) { if (ret == 0) {
size_t retlen = min_t(size_t, len, cpumask_size()); unsigned int retlen = min(len, cpumask_size());
if (copy_to_user(user_mask_ptr, mask, retlen)) if (copy_to_user(user_mask_ptr, mask, retlen))
ret = -EFAULT; ret = -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment