提交 2e5b5b3a 编写于 作者: H Hiroshi Shimamoto 提交者: Ingo Molnar

sched: Clean up parameter passing of proc_sched_autogroup_set_nice()

Pass nice as a value to proc_sched_autogroup_set_nice().

No side effect is expected, and the variable err will be overwritten with
the return value.
Signed-off-by: NHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/4F45FBB7.5090607@ct.jp.nec.comSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 367456c7
...@@ -1310,8 +1310,7 @@ sched_autogroup_write(struct file *file, const char __user *buf, ...@@ -1310,8 +1310,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
if (!p) if (!p)
return -ESRCH; return -ESRCH;
err = nice; err = proc_sched_autogroup_set_nice(p, nice);
err = proc_sched_autogroup_set_nice(p, &err);
if (err) if (err)
count = err; count = err;
......
...@@ -2065,7 +2065,7 @@ extern void sched_autogroup_fork(struct signal_struct *sig); ...@@ -2065,7 +2065,7 @@ extern void sched_autogroup_fork(struct signal_struct *sig);
extern void sched_autogroup_exit(struct signal_struct *sig); extern void sched_autogroup_exit(struct signal_struct *sig);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m); extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice); extern int proc_sched_autogroup_set_nice(struct task_struct *p, int nice);
#endif #endif
#else #else
static inline void sched_autogroup_create_attach(struct task_struct *p) { } static inline void sched_autogroup_create_attach(struct task_struct *p) { }
......
...@@ -195,20 +195,20 @@ __setup("noautogroup", setup_autogroup); ...@@ -195,20 +195,20 @@ __setup("noautogroup", setup_autogroup);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice) int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
{ {
static unsigned long next = INITIAL_JIFFIES; static unsigned long next = INITIAL_JIFFIES;
struct autogroup *ag; struct autogroup *ag;
int err; int err;
if (*nice < -20 || *nice > 19) if (nice < -20 || nice > 19)
return -EINVAL; return -EINVAL;
err = security_task_setnice(current, *nice); err = security_task_setnice(current, nice);
if (err) if (err)
return err; return err;
if (*nice < 0 && !can_nice(current, *nice)) if (nice < 0 && !can_nice(current, nice))
return -EPERM; return -EPERM;
/* this is a heavy operation taking global locks.. */ /* this is a heavy operation taking global locks.. */
...@@ -219,9 +219,9 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice) ...@@ -219,9 +219,9 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
ag = autogroup_task_get(p); ag = autogroup_task_get(p);
down_write(&ag->lock); down_write(&ag->lock);
err = sched_group_set_shares(ag->tg, prio_to_weight[*nice + 20]); err = sched_group_set_shares(ag->tg, prio_to_weight[nice + 20]);
if (!err) if (!err)
ag->nice = *nice; ag->nice = nice;
up_write(&ag->lock); up_write(&ag->lock);
autogroup_kref_put(ag); autogroup_kref_put(ag);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册