Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1668937ybe; Tue, 3 Sep 2019 01:34:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDKg24VnMWWujIqMms6/zzyP+/WbhnBK8/dgPmycEvczZF7AB/o1I3e7XKYbbmlhnDsQID X-Received: by 2002:a17:902:9f82:: with SMTP id g2mr34346658plq.63.1567499657597; Tue, 03 Sep 2019 01:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567499657; cv=none; d=google.com; s=arc-20160816; b=oLnMgzP7kOEaqv4wR2dgydQrgt2OGvv0U/GG51mAzq52W6ytmho0GJhyHi9Wum1oby 4yGsaGCdhWNYcO5u438OCtwcHWpUNY+rqvMozxSwKlUg73ATr5Wws+VNcVsy+Eu13i4n SQK0SkHMmOXFv+bhyM0Q6DkpPnVROe9pcyYmxOaijPRUB9Dmk31EVRqyb8R+Xi58Sj46 wBQcGi/VL1zFfk8R2EW+uSY2qp+r8oWSnc5WJFbF/cIZVAnLWBB59byygtxgLo9t6VX0 TDyYtyDp5ZWX02aB1jl0DK4XEygLHc0SPkFJ93mIovXP31czJkMjERv1zOBq/WEzD1/w vW7g== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=T3rSLYzNyKO/cL1I06Oet5jokGfF1Ynfu3MFQP6kE+4=; b=ekbjeD1xW8sU7/Hq20OOLRvUnlZJo5DdBH6K1BijFEQ8zCli1Ih79dyW610C+Z4yGl 6uqhHIOrwr7FancrzXSb7jEkiuHDpLFjcBmNYl5VeYsMuxjkduFeauIKzNiRZBYALVF9 PQczFMpeYH/vwHa4lg7YRy1emz5xdN293OXxpAIqunx3ZtuLPJTEAX4L6iZ1Fqcrmcqj /6FRGoQh4KbBaodKEaOLPDVyQHqn53Yo8lachq7YO/3STqBGP2gF+7+gXE2TEz0BaWfF suPr9m/Ze2eOfSa87Qd4SBBI8Ad3vtZDzNJbk3zYqWXddaLvsBT/8z8WA+6fXOo6tecN tP/A== 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 p13si14195818plo.267.2019.09.03.01.34.02; Tue, 03 Sep 2019 01:34:17 -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; 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 S1728250AbfICIbr (ORCPT + 99 others); Tue, 3 Sep 2019 04:31:47 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:59200 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728235AbfICIbq (ORCPT ); Tue, 3 Sep 2019 04:31:46 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i54Dn-0002gC-4r; Tue, 03 Sep 2019 10:31:27 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id A60BC1C0DDE; Tue, 3 Sep 2019 10:31:26 +0200 (CEST) Date: Tue, 03 Sep 2019 08:31:26 -0000 From: "tip-bot2 for Patrick Bellasi" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/uclamp: Propagate system defaults to the root group Cc: Patrick Bellasi , "Peter Zijlstra (Intel)" , Michal Koutny , Tejun Heo , Alessio Balsini , Dietmar Eggemann , Joel Fernandes , Juri Lelli , Linus Torvalds , Morten Rasmussen , Paul Turner , Quentin Perret , "Rafael J . Wysocki" , Steve Muckle , Suren Baghdasaryan , Thomas Gleixner , Todd Kjos , Vincent Guittot , Viresh Kumar , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20190822132811.31294-4-patrick.bellasi@arm.com> References: <20190822132811.31294-4-patrick.bellasi@arm.com> MIME-Version: 1.0 Message-ID: <156749948653.12884.4026456408630677258.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 7274a5c1bbec45f06f1fff4b8c8b5855b6cc189d Gitweb: https://git.kernel.org/tip/7274a5c1bbec45f06f1fff4b8c8b5855b6cc189d Author: Patrick Bellasi AuthorDate: Thu, 22 Aug 2019 14:28:08 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 03 Sep 2019 09:17:38 +02:00 sched/uclamp: Propagate system defaults to the root group The clamp values are not tunable at the level of the root task group. That's for two main reasons: - the root group represents "system resources" which are always entirely available from the cgroup standpoint. - when tuning/restricting "system resources" makes sense, tuning must be done using a system wide API which should also be available when control groups are not. When a system wide restriction is available, cgroups should be aware of its value in order to know exactly how much "system resources" are available for the subgroups. Utilization clamping supports already the concepts of: - system defaults: which define the maximum possible clamp values usable by tasks. - effective clamps: which allows a parent cgroup to constraint (maybe temporarily) its descendants without losing the information related to the values "requested" from them. Exploit these two concepts and bind them together in such a way that, whenever system default are tuned, the new values are propagated to (possibly) restrict or relax the "effective" value of nested cgroups. When cgroups are in use, force an update of all the RUNNABLE tasks. Otherwise, keep things simple and do just a lazy update next time each task will be enqueued. Do that since we assume a more strict resource control is required when cgroups are in use. This allows also to keep "effective" clamp values updated in case we need to expose them to user-space. Signed-off-by: Patrick Bellasi Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Michal Koutny Acked-by: Tejun Heo Cc: Alessio Balsini Cc: Dietmar Eggemann Cc: Joel Fernandes Cc: Juri Lelli Cc: Linus Torvalds Cc: Morten Rasmussen Cc: Paul Turner Cc: Peter Zijlstra Cc: Quentin Perret Cc: Rafael J . Wysocki Cc: Steve Muckle Cc: Suren Baghdasaryan Cc: Thomas Gleixner Cc: Todd Kjos Cc: Vincent Guittot Cc: Viresh Kumar Link: https://lkml.kernel.org/r/20190822132811.31294-4-patrick.bellasi@arm.com Signed-off-by: Ingo Molnar --- kernel/sched/core.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8855481..e6800fe 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1017,10 +1017,30 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) uclamp_rq_dec_id(rq, p, clamp_id); } +#ifdef CONFIG_UCLAMP_TASK_GROUP +static void cpu_util_update_eff(struct cgroup_subsys_state *css); +static void uclamp_update_root_tg(void) +{ + struct task_group *tg = &root_task_group; + + uclamp_se_set(&tg->uclamp_req[UCLAMP_MIN], + sysctl_sched_uclamp_util_min, false); + uclamp_se_set(&tg->uclamp_req[UCLAMP_MAX], + sysctl_sched_uclamp_util_max, false); + + rcu_read_lock(); + cpu_util_update_eff(&root_task_group.css); + rcu_read_unlock(); +} +#else +static void uclamp_update_root_tg(void) { } +#endif + int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { + bool update_root_tg = false; int old_min, old_max; int result; @@ -1043,16 +1063,23 @@ int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, if (old_min != sysctl_sched_uclamp_util_min) { uclamp_se_set(&uclamp_default[UCLAMP_MIN], sysctl_sched_uclamp_util_min, false); + update_root_tg = true; } if (old_max != sysctl_sched_uclamp_util_max) { uclamp_se_set(&uclamp_default[UCLAMP_MAX], sysctl_sched_uclamp_util_max, false); + update_root_tg = true; } + if (update_root_tg) + uclamp_update_root_tg(); + /* - * Updating all the RUNNABLE task is expensive, keep it simple and do - * just a lazy update at each next enqueue time. + * We update all RUNNABLE tasks only when task groups are in use. + * Otherwise, keep it simple and do just a lazy update at each next + * task enqueue time. */ + goto done; undo: