Commit 8fcb2312 authored by Olof Johansson's avatar Olof Johansson Committed by Linus Torvalds

kernel/sched/psi.c: simplify cgroup_move_task()

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/20181103183339.8669-1-olof@lixom.net
Fixes: 2ce7135a ("psi: cgroup support")
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ca0246bb
...@@ -633,38 +633,39 @@ void psi_cgroup_free(struct cgroup *cgroup) ...@@ -633,38 +633,39 @@ void psi_cgroup_free(struct cgroup *cgroup)
*/ */
void cgroup_move_task(struct task_struct *task, struct css_set *to) void cgroup_move_task(struct task_struct *task, struct css_set *to)
{ {
bool move_psi = !psi_disabled;
unsigned int task_flags = 0; unsigned int task_flags = 0;
struct rq_flags rf; struct rq_flags rf;
struct rq *rq; struct rq *rq;
if (move_psi) { if (psi_disabled) {
rq = task_rq_lock(task, &rf); /*
* 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)) rq = task_rq_lock(task, &rf);
task_flags = TSK_RUNNING;
else if (task->in_iowait)
task_flags = TSK_IOWAIT;
if (task->flags & PF_MEMSTALL) if (task_on_rq_queued(task))
task_flags |= TSK_MEMSTALL; task_flags = TSK_RUNNING;
else if (task->in_iowait)
task_flags = TSK_IOWAIT;
if (task_flags) if (task->flags & PF_MEMSTALL)
psi_task_change(task, task_flags, 0); task_flags |= TSK_MEMSTALL;
}
/* if (task_flags)
* Lame to do this here, but the scheduler cannot be locked psi_task_change(task, task_flags, 0);
* from the outside, so we move cgroups from inside sched/.
*/ /* See comment above */
rcu_assign_pointer(task->cgroups, to); rcu_assign_pointer(task->cgroups, to);
if (move_psi) { if (task_flags)
if (task_flags) psi_task_change(task, 0, task_flags);
psi_task_change(task, 0, task_flags);
task_rq_unlock(rq, task, &rf); task_rq_unlock(rq, task, &rf);
}
} }
#endif /* CONFIG_CGROUPS */ #endif /* CONFIG_CGROUPS */
......
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