All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jack Wang <jinpuwang@gmail.com>
To: gregkh@linuxfoundation.org, stable@vger.kernel.org
Cc: Olof Johansson <olof@lixom.net>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jack Wang <jinpu.wang@cloud.ionos.com>
Subject: [stable-4.14 10/11] kernel/sched/psi.c: simplify cgroup_move_task()
Date: Tue, 12 Mar 2019 11:20:01 +0100	[thread overview]
Message-ID: <20190312102002.31737-11-jinpuwang@gmail.com> (raw)
In-Reply-To: <20190312102002.31737-1-jinpuwang@gmail.com>

From: Olof Johansson <olof@lixom.net>

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: 2ce7135adc9ad ("psi: cgroup support")
Signed-off-by: Olof Johansson <olof@lixom.net>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit c904648b96279bd44e1f08f474274cd1ee52675d)
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
---
 kernel/sched/psi.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 7cdecfc010af..3d7355d7c3e3 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -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 */
 
-- 
2.17.1


  parent reply	other threads:[~2019-03-12 10:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-12 10:19 [RFC stable-4.14 00/11] PSI feature for 4.14 Jack Wang
2019-03-12 10:19 ` [stable-4.14 01/11] mm: workingset: don't drop refault information prematurely Jack Wang
2019-03-12 16:37   ` Linus Torvalds
2019-03-13 10:05     ` Jinpu Wang
2019-03-12 10:19 ` [stable-4.14 02/11] mm: workingset: tell cache transitions from workingset thrashing Jack Wang
2019-03-12 10:19 ` [stable-4.14 03/11] delayacct: track delays from thrashing cache pages Jack Wang
2019-03-12 10:19 ` [stable-4.14 04/11] sched: loadavg: consolidate LOAD_INT, LOAD_FRAC, CALC_LOAD Jack Wang
2019-03-12 10:19 ` [stable-4.14 05/11] sched: loadavg: make calc_load_n() public Jack Wang
2019-03-12 10:19 ` [stable-4.14 06/11] sched: sched.h: make rq locking and clock functions available in stats.h Jack Wang
2019-03-12 10:19 ` [stable-4.14 07/11] sched: introduce this_rq_lock_irq() Jack Wang
2019-03-12 10:19 ` [stable-4.14 08/11] psi: pressure stall information for CPU, memory, and IO Jack Wang
2019-03-12 10:20 ` [stable-4.14 09/11] psi: cgroup support Jack Wang
2019-03-12 10:20 ` Jack Wang [this message]
2019-03-12 10:20 ` [stable-4.14 11/11] psi: make disabling/enabling easier for vendor kernels Jack Wang
2019-03-12 11:43 ` [RFC stable-4.14 00/11] PSI feature for 4.14 Greg KH
2019-03-13 10:15   ` Jinpu Wang
2019-03-14 17:29     ` Greg KH
2019-03-15 10:48       ` Jinpu Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190312102002.31737-11-jinpuwang@gmail.com \
    --to=jinpuwang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=mingo@redhat.com \
    --cc=olof@lixom.net \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.