Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp914103ybi; Fri, 2 Aug 2019 06:24:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyRXWgD8uOheSG3mDkJ9PlxZhP5IamMoEUnF7ySAKM4Vk1vYiP+zvHlyT3mUq8iigP0rvh X-Received: by 2002:a62:14c4:: with SMTP id 187mr58182413pfu.241.1564752250180; Fri, 02 Aug 2019 06:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564752250; cv=none; d=google.com; s=arc-20160816; b=K1tiYrO6VrstV5fdfr5gOLTf2Q62Fk+pl8tzxO3xNh8hifC+0ndj/Ud2QZMmQT46eS 45r7BzHo5H6Sq5nKGSAk3i+j6GL2ni5TAyEFFwgQ8I6dQbgyvEXmkHE29TrvyF+qNvNi PXEa3Z7+cb5VWSDr1iQu0xNReIV1jmcCEwFtjfFY0bvJqqggBg8q7hRpFRlCQnCy5Q3H YZ/KrFUfc87ALMbgEpTHIRoY2+nL4l7LWzk6kjdtRZHBkH4RnjaOBXqQQ3PSCxkaLEGr rPnDnS3dC+Ajr9OF5/Swj9+VdSDYf5F0edNYs4q4JlmiMhs4/e4eCP9gi/nwpv6alTcV KgYQ== 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=cp2sp52PbnX6z+jUhJkHTFz2k/3P19J6pBMRUW5f/is=; b=XCSg5C3iGc6Yw/ldpp5roI5o7EVYDbUR/vGnYP4Rzz/f8foJzYDMUcrHCq9aZSl+fm Pc/ZS3vZTe/sKWU3RX9AQGh4RgCuICrHnDod3RTWOHLEnMoYs1envdwkHZNdpDHVjwDe ojuhAJj0rRLSOk5Aw8GEAZEfZ2g5AqVoM2G8OmKgIVy/hYWYWYQTmDkKGyGTZi/ftoCF WDwUEKAsn4XGmMoLmFSl7pV/HDeoYTClOtyxn4Ujtz3EjSkiIvtYw6oYKMTV8b7swJPJ pDwySFUQQ60tPY879kYqNof3w1rDdieu6dWXw0vCwRQ7DQnkEslvTl+VM5ON+39aO2It n5+g== 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 c4si39157242pfn.71.2019.08.02.06.23.55; Fri, 02 Aug 2019 06:24:10 -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 S2387722AbfHBJJT (ORCPT + 99 others); Fri, 2 Aug 2019 05:09:19 -0400 Received: from foss.arm.com ([217.140.110.172]:47094 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390876AbfHBJJQ (ORCPT ); Fri, 2 Aug 2019 05:09:16 -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 CD64F1596; Fri, 2 Aug 2019 02:09:15 -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 2987A3F575; Fri, 2 Aug 2019 02:09:13 -0700 (PDT) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, cgroups@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Michal Koutny , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan , Alessio Balsini Subject: [PATCH v13 3/6] sched/core: uclamp: Propagate system defaults to root group Date: Fri, 2 Aug 2019 10:08:50 +0100 Message-Id: <20190802090853.4810-4-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802090853.4810-1-patrick.bellasi@arm.com> References: <20190802090853.4810-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. 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 Acked-by: Tejun Heo Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Tejun Heo --- Changes in v13: Message-ID: <20190725114126.GA4130@blackbody.suse.cz> - comment rewording: update all RUNNABLE tasks on system default changes only when cgroups are in use. --- 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 de8886ce0f65..5683c8639b4a 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: -- 2.22.0