Skip to content

Commit 2e5b5b3

Browse files
h-shimamotoIngo Molnar
authored andcommitted
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: Hiroshi Shimamoto <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 367456c commit 2e5b5b3

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

fs/proc/base.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,8 +1310,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
13101310
if (!p)
13111311
return -ESRCH;
13121312

1313-
err = nice;
1314-
err = proc_sched_autogroup_set_nice(p, &err);
1313+
err = proc_sched_autogroup_set_nice(p, nice);
13151314
if (err)
13161315
count = err;
13171316

include/linux/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ extern void sched_autogroup_fork(struct signal_struct *sig);
20652065
extern void sched_autogroup_exit(struct signal_struct *sig);
20662066
#ifdef CONFIG_PROC_FS
20672067
extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
2068-
extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice);
2068+
extern int proc_sched_autogroup_set_nice(struct task_struct *p, int nice);
20692069
#endif
20702070
#else
20712071
static inline void sched_autogroup_create_attach(struct task_struct *p) { }

kernel/sched/auto_group.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,20 @@ __setup("noautogroup", setup_autogroup);
195195

196196
#ifdef CONFIG_PROC_FS
197197

198-
int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
198+
int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
199199
{
200200
static unsigned long next = INITIAL_JIFFIES;
201201
struct autogroup *ag;
202202
int err;
203203

204-
if (*nice < -20 || *nice > 19)
204+
if (nice < -20 || nice > 19)
205205
return -EINVAL;
206206

207-
err = security_task_setnice(current, *nice);
207+
err = security_task_setnice(current, nice);
208208
if (err)
209209
return err;
210210

211-
if (*nice < 0 && !can_nice(current, *nice))
211+
if (nice < 0 && !can_nice(current, nice))
212212
return -EPERM;
213213

214214
/* this is a heavy operation taking global locks.. */
@@ -219,9 +219,9 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
219219
ag = autogroup_task_get(p);
220220

221221
down_write(&ag->lock);
222-
err = sched_group_set_shares(ag->tg, prio_to_weight[*nice + 20]);
222+
err = sched_group_set_shares(ag->tg, prio_to_weight[nice + 20]);
223223
if (!err)
224-
ag->nice = *nice;
224+
ag->nice = nice;
225225
up_write(&ag->lock);
226226

227227
autogroup_kref_put(ag);

0 commit comments

Comments
 (0)