Skip to content

Commit

Permalink
kernel/sched/psi.c: simplify cgroup_move_task()
Browse files Browse the repository at this point in the history
The existing code triggered an invalid warning about 'rq' possibly being
used uninitialized.  Instead of doing the silly warning suppression by
initializa it to NULL, refactor the code to bail out early instead.

Warning was:

  kernel/sched/psi.c: In function `cgroup_move_task':
  kernel/sched/psi.c:639:13: warning: `rq' may be used uninitialized in this function [-Wmaybe-uninitialized]

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 2ce7135 ("psi: cgroup support")
Signed-off-by: Olof Johansson <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
olofj authored and torvalds committed Nov 18, 2018
1 parent ca0246b commit 8fcb231
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions kernel/sched/psi.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,38 +633,39 @@ void psi_cgroup_free(struct cgroup *cgroup)
*/
void cgroup_move_task(struct task_struct *task, struct css_set *to)
{
bool move_psi = !psi_disabled;
unsigned int task_flags = 0;
struct rq_flags rf;
struct rq *rq;

if (move_psi) {
rq = task_rq_lock(task, &rf);
if (psi_disabled) {
/*
* Lame to do this here, but the scheduler cannot be locked
* from the outside, so we move cgroups from inside sched/.
*/
rcu_assign_pointer(task->cgroups, to);
return;
}

if (task_on_rq_queued(task))
task_flags = TSK_RUNNING;
else if (task->in_iowait)
task_flags = TSK_IOWAIT;
rq = task_rq_lock(task, &rf);

if (task->flags & PF_MEMSTALL)
task_flags |= TSK_MEMSTALL;
if (task_on_rq_queued(task))
task_flags = TSK_RUNNING;
else if (task->in_iowait)
task_flags = TSK_IOWAIT;

if (task_flags)
psi_task_change(task, task_flags, 0);
}
if (task->flags & PF_MEMSTALL)
task_flags |= TSK_MEMSTALL;

/*
* Lame to do this here, but the scheduler cannot be locked
* from the outside, so we move cgroups from inside sched/.
*/
if (task_flags)
psi_task_change(task, task_flags, 0);

/* See comment above */
rcu_assign_pointer(task->cgroups, to);

if (move_psi) {
if (task_flags)
psi_task_change(task, 0, task_flags);
if (task_flags)
psi_task_change(task, 0, task_flags);

task_rq_unlock(rq, task, &rf);
}
task_rq_unlock(rq, task, &rf);
}
#endif /* CONFIG_CGROUPS */

Expand Down

0 comments on commit 8fcb231

Please sign in to comment.