Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6555301ybi; Mon, 8 Jul 2019 05:00:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhF4NqcihzxOPmUvDAs7keC50uTg8VJmngqcciwPp2uIOjSfU2Nl5KN2dssxwIIm7Xn89+ X-Received: by 2002:a17:90a:9301:: with SMTP id p1mr17691497pjo.22.1562587205027; Mon, 08 Jul 2019 05:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562587205; cv=none; d=google.com; s=arc-20160816; b=bl2B41QhD25bw1G7v2tAY1DdhDpJYGojvtF1kDJ71hf0z2UnRT5Yl2WpQjTbwCRRKA +0wQU+ZzknSafV5Lrm+uOJqRYcKzEs4CrM3eD26nvYGY0EfTxiM/oNW/lJvw3SDQpp+e qcfyfCgy5rM3RpXagW03db7lIXRTHrQY9kwPTUWF5rasURx12bqbk/EhX8nF7/H0hJbP +IeZe9ofEg02f4ZVeBB9icnXZliwfluUFkvULrow1IFIzNoETjucUVcg1grpc0Ld/emW d5bITDP2MBux2GbXh/T11zD0YOP308cHMMuueMzX5/3EhZUBu5JQJSYTU9t2KuU8/jml L1iQ== 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:date:subject:cc:to:from; bh=88MHejldbhXr1TO9mRGbXnCcnqof7ReEymlMtkgnTws=; b=m6Colvi8ilGVzcxNmbXPQUZwXu9iryi4m0MwQWFcqfyVXcofYCVBfdsNkeT9ym8muE j3KlwhBliNfauE0j9i8N59g9uae/U3P5QSFbr98KIJxkiN8Izs9bmXx5+O+KzNlTSEoH /xahFeYbIQLoFmbP+AZGA3VLpoqnu9S4piJ2NwtE9EADn/CrDysmtL82RSZfGxjDIdif P8W/vhcZqv11+Xnx6a/DVKJdq7o5Kskt4VmRIov3zB5B78CF6Zx69UyI7STjRevCSaks fWBQ3z6GCLvjlR1rtaB1vXTInziEtKZccaGmQllOvDe2mCmeLz2kpBX4IKAC2Ve55seC HqXw== 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 c13si19339797pgm.140.2019.07.08.04.59.49; Mon, 08 Jul 2019 05:00:05 -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 S1729611AbfGHIoV (ORCPT + 99 others); Mon, 8 Jul 2019 04:44:21 -0400 Received: from foss.arm.com ([217.140.110.172]:41980 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729602AbfGHIoT (ORCPT ); Mon, 8 Jul 2019 04:44:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A06D01516; Mon, 8 Jul 2019 01:44:18 -0700 (PDT) Received: from e110439-lin.cambridge.arm.com (e110439-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4CD6D3F246; Mon, 8 Jul 2019 01:44:16 -0700 (PDT) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan , Alessio Balsini Subject: [PATCH v11 3/5] sched/core: uclamp: Propagate system defaults to root group Date: Mon, 8 Jul 2019 09:43:55 +0100 Message-Id: <20190708084357.12944-4-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190708084357.12944-1-patrick.bellasi@arm.com> References: <20190708084357.12944-1-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Patrick Bellasi Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Tejun Heo --- kernel/sched/core.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ec91f4518752..276f9c2f6103 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1017,12 +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); + + cpu_util_update_eff(&root_task_group.css); +} +#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) { - int old_min, old_max; + bool update_root_tg = false; static DEFINE_MUTEX(mutex); + int old_min, old_max; int result; mutex_lock(&mutex); @@ -1044,12 +1062,17 @@ 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. -- 2.21.0