Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1230644imu; Mon, 5 Nov 2018 16:31:47 -0800 (PST) X-Google-Smtp-Source: AJdET5e2zczAj4t/09ZxE/DIsZTyedT1APTYGMuksp/8hyXTXBROJtrtrgAZ3KqbTTMjmozfypnH X-Received: by 2002:a17:902:8302:: with SMTP id bd2-v6mr16772199plb.100.1541464307687; Mon, 05 Nov 2018 16:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541464307; cv=none; d=google.com; s=arc-20160816; b=MCYCZNsoK6/kgDgG0Hmtf3AZ7nH17NfI6j4PF0PTj5b+ySJWcs0rQLWTktEoA4xvwx AW8HtJHhAb6dCrYvj2mdhEix0tgTE11bljuKA3i95R03GvNJ+f6enWZ/meQRK2ejoIQl ro/RbKatbnrkd8VEXUJDuA0Jd9EUSk/pySZieSdx76H4FcJXKPhueAGYsOov62/Mq6tr WDs7EaXHMRy1sRoiLp8B0N0GrM8yFei8MqclOI8y6VAgmzhbP0J/wrl4dsXPX42PD29J Ji4/eReFvwHvW7uNuMdJ7i3DYEEAS/MHD4HpNAEPrVrD3CFsktSSj8Ic4F3LNwa2PL9g L5SQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=8khyZssZKtyy1nN/17p1jv/i4r+Sz2nb6ltnmh2VPEU=; b=mP9g3UILh3UYqgPQWjM0020mFnWiXNVqEGWs2+Nk539ONc2Qaz8E31fWybMQ1UelCX sFEd79JlkUKmlkSGx6lEJ75Ih75lGEROn5L+L+0NefuyLw8wh7uBhAlX+72Ma8wIS7uf xXFY74fDXX1NlkRxfkeKyy3987XJ4/JRwZkVk0SD4mEw78tpDZnNXKOT1GDSji2BHrn1 T5dPlutTEFfuaAgQ/H0m/NfphZIGC3gGJzRrCibzUYUu7ptBm0lkt+yiHGBSXOlePwA+ 9mP1zWxiZb9mXbUvJwNuI888xVXqEOjwbEVUNeySodI7wEjk9ZtV55KgzE7sprL/kMtv ETIg== ARC-Authentication-Results: i=1; mx.google.com; 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 x23si13591030pgk.272.2018.11.05.16.31.31; Mon, 05 Nov 2018 16:31:47 -0800 (PST) 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; 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 S1729241AbeKFJv6 (ORCPT + 99 others); Tue, 6 Nov 2018 04:51:58 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48424 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbeKFJv5 (ORCPT ); Tue, 6 Nov 2018 04:51:57 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 55E1A86E; Tue, 6 Nov 2018 00:29:33 +0000 (UTC) Date: Mon, 5 Nov 2018 16:29:30 -0800 From: Andrew Morton To: Olof Johansson Cc: Johannes Weiner , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] psi: simplify cgroup_move_task Message-Id: <20181105162930.c381c0c8550f0334817ca419@linux-foundation.org> In-Reply-To: <20181103183339.8669-1-olof@lixom.net> References: <20181103183339.8669-1-olof@lixom.net> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) 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 On Sat, 3 Nov 2018 11:33:39 -0700 Olof Johansson wrote: > 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] > > --- 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; > + } Fair enough. Surprisingly this doesn't increase psi.o text size.