forked from luck/tmp_suning_uos_patched
sched: convert sys_sched_getaffinity() to cpumask_var_t.
Impact: stack usage reduction Dynamically allocating cpumasks (when CONFIG_CPUMASK_OFFSTACK) saves space in the stack. cpumask_var_t is just a struct cpumask for !CONFIG_CPUMASK_OFFSTACK. Some jiggling here to make sure we always exit at the bottom (so we hit the free_cpumask_var there). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
a0e902452d
commit
f17c860760
|
@ -5499,19 +5499,24 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
|
|||
unsigned long __user *user_mask_ptr)
|
||||
{
|
||||
int ret;
|
||||
cpumask_t mask;
|
||||
cpumask_var_t mask;
|
||||
|
||||
if (len < sizeof(cpumask_t))
|
||||
if (len < cpumask_size())
|
||||
return -EINVAL;
|
||||
|
||||
ret = sched_getaffinity(pid, &mask);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!alloc_cpumask_var(&mask, GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_to_user(user_mask_ptr, &mask, sizeof(cpumask_t)))
|
||||
return -EFAULT;
|
||||
ret = sched_getaffinity(pid, mask);
|
||||
if (ret == 0) {
|
||||
if (copy_to_user(user_mask_ptr, mask, cpumask_size()))
|
||||
ret = -EFAULT;
|
||||
else
|
||||
ret = cpumask_size();
|
||||
}
|
||||
free_cpumask_var(mask);
|
||||
|
||||
return sizeof(cpumask_t);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user