Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp850403imd; Sat, 3 Nov 2018 11:34:25 -0700 (PDT) X-Google-Smtp-Source: AJdET5foSRxmkatkpkSFTHYQ9mQtLwjjJz5VPtH7R47sSW2Y5tMsQ/q4KoDku5mjz6tR8AagtYVn X-Received: by 2002:a17:902:2ac3:: with SMTP id j61-v6mr16006563plb.139.1541270065012; Sat, 03 Nov 2018 11:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541270064; cv=none; d=google.com; s=arc-20160816; b=OgSZZ3bEmVYEV+nC+1y2BcdRg4SeokMJn4TFTJZ8T6dcj/506vW1nj8Gs4hAHfR9k0 w4eHmEU+wWwlsQkt3poXh8poE6uFbUjYfg7Mg14u5ZMXtSSqRIFX60aDrIVhbwjtcoFT mBgHrRSXwJNQBye7KGqnFsPPYzSHx8n6qo5yD25NY5JlogLNweMOIwa8EX22S48vqeO2 /SosrXkWLjayg2si+JX2GGU67EXcUoNrLRNDABz+81R1jA9LE4GE2DJ8qJM3ORFbNFie 0uhkeF17KZ/+MjfSEIy91lD11SzaD8bl2xaLwuTeuRCAz4CsmnLkDjR02iPDvw76i+vx uNNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=iXPhjBGuHMxMaRXdVtVi5S1b/4/EEj7dXXmpSpcVTv4=; b=dUr+vkt+Jm0MYmwMpmFCh1+ZcddxYgHoPIZeEkxQwQdeCv9quZ8/in98rY5dYqDHVy X+hcVRm7qSk9Cb3aK1AQSlRvs6/738cgALXy6sYW8NwlVCHF+nbbJAUiXaBejmM5fYie iHyDO5CSXpuuw1cG1U53TJVL+aHLrzUcbXxdQYKTHK/VrLrMTU4SdBeVuURhitbvXiZs ddQ3hHyEW1/JWvGN2hM4Axwt1twyQnndhPVk9LsK2kUqonLy9cWPfXHlmYPPbbbnNRTx i6u/wlmLCSG/KoZYilcVE1cHe3PRahVYfEUOamtIg1Vp8IzuahS56JBuCGnjgYvHSO0V UcYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=SINdvEcZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d32-v6si24967757pla.405.2018.11.03.11.34.09; Sat, 03 Nov 2018 11:34:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=SINdvEcZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728809AbeKDDpw (ORCPT + 99 others); Sat, 3 Nov 2018 23:45:52 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38815 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727615AbeKDDpw (ORCPT ); Sat, 3 Nov 2018 23:45:52 -0400 Received: by mail-pl1-f193.google.com with SMTP id p4-v6so89304plo.5 for ; Sat, 03 Nov 2018 11:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iXPhjBGuHMxMaRXdVtVi5S1b/4/EEj7dXXmpSpcVTv4=; b=SINdvEcZP/3EJG2D3sTVeYNHt1wYcMhNoPJ1OdYRxcnz8ixFmbFUFajUs47oIkXPI0 q2i8sot0xjQbemfKAWFd8CRNN9z3H2QY8kXSWgSjcX3ggQLuAN3C/QCdzvp1BU8+qTXj Qg9e6h2iwF1mrvOBavYRFgXROdzu2H+lUUGOScG8uZLIuLGZn9EzCPv3BD+YvlHgZ5vi i4Cb0KGxAKl0XyNdhwTrUPKyIWa0Jk2cOgNm3ohYGE8ar+qyyYpwonZwrkn6tTpq97rC ZtrVEz7DlbplV3/ch3bJtqN7zi+jnzc2mwuwfCUW+knGb5dPDVIm0rBrSBIcwyAwt6Qi ueJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iXPhjBGuHMxMaRXdVtVi5S1b/4/EEj7dXXmpSpcVTv4=; b=NZWO2itcyqTP5UngSAkLHcf+Wu6zSvl2qSGoFzaR6zEcPYZ/wE3i7Rq6K7mdQgyMZx FCMIYaaE40A+6LLTyEYozzz257b2rRUCXm+FDRmGVj4kXDeiOgd557QvkjbLsR2cchim k3TaB78JDjphcwf0WHCuGGzU5GgywtG0dRbRPx1YmiKsSC/L7NlLCasbqBAfz2sHrUjp IEVcLCr7x/AeS6Oq7fr4Vbxkk4wNxVROVRGVelcDtFUBft1jYT/jtB3U99uLgks2jYz0 SIFziYIWNng7qF6lXcoAMv4vXKySvzWefroe/9R2vjfaix/2cRLQh+rjgYQ/F4oAUMZQ qK8w== X-Gm-Message-State: AGRZ1gIr7U9856nUj1R9HggFq7bk9J6+mmEiM2mr655tBwQDTa+XX9h5 YhKAjiQlrfXaV9IAV91FUjtuFQ== X-Received: by 2002:a17:902:7108:: with SMTP id a8-v6mr16004927pll.290.1541270029125; Sat, 03 Nov 2018 11:33:49 -0700 (PDT) Received: from localhost.localdomain (99-152-116-91.lightspeed.sntcca.sbcglobal.net. [99.152.116.91]) by smtp.gmail.com with ESMTPSA id w2-v6sm3958669pfn.89.2018.11.03.11.33.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Nov 2018 11:33:46 -0700 (PDT) From: Olof Johansson To: Andrew Morton Cc: Johannes Weiner , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, kernel-team@fb.com, Olof Johansson Subject: [PATCH] psi: simplify cgroup_move_task Date: Sat, 3 Nov 2018 11:33:39 -0700 Message-Id: <20181103183339.8669-1-olof@lixom.net> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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] Fixes: 2ce7135adc9ad ("psi: cgroup support") Cc: Johannes Weiner Signed-off-by: Olof Johansson --- 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.11.0