Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1016412ybl; Thu, 22 Aug 2019 08:11:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOcaxwEiQu1BJvlmhzqaPyBZ+fNKrug5OCr7OMKGqMa6UsMkfk5BEteSo2WN2bdtZa9kDa X-Received: by 2002:a65:5a44:: with SMTP id z4mr34451237pgs.41.1566486695102; Thu, 22 Aug 2019 08:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566486695; cv=none; d=google.com; s=arc-20160816; b=tZUwqoNdNAgrnXG6wDNqEfQeE6DN7XMo1CVwcIKOFgZBp7vzv87j4eCuFO9Kwzk8k5 vr6jbzyhhFCXPdJA9IeX/unfL5FwEn+Gl1LLZvL8a7jlnAIvc+dHKABDlLfpWJXV27Jm PgDfFZzVwXPXFQ9VJxT/AbzUqlCBvZ8D2JA0YY2Qiy/M7eWlIcnxAPym8UVIRHsppI8D LH1a4uSXwxeXzqB0dROtBJZQOqO4+/od1gpMbHmBVCNlkX2BKdVtOZQnXFzV50NbtZKF S+dRueMv9CN8N3XyjWkGV4f7Jhu9feYI17uqJEMkDyvrniZmf+XNU/mP6z/FVO41r312 UiOA== 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=FgdpdyfHSvNgSe6bdvrG2STBw9CALGs19vxnBhWr9fI=; b=e8MkW0QC+zQ0IaShwDYgbnDkIanC2HSiIJLVq9+HJjbynk/Nc6AINyHKY0s+iUsyRt hae3cTEdbjIx33hTwzNA6kbKZFwiTPdDeGgFLzf4Gtk+L/Wik+xPnxpAKqx+tkSYtBRb xDCY0HJYVywoAw0c2VYidKtmts3AUdRitM6EtO1A+XGca3jArc+YDTFwRK3j6dTzzxhQ PMft8m8Q5yRVkxP47uPVQi/YIccMKJdzEftS49Nd6DIUv4jg6TXDQoJEBEDDg+jf60QW Rhbt/lcBeFngDEgQpPNZPSE0wj8JWT7vDQjEB/6xIVZb+ed/ua8rVdGoMWzEhXaswR3d Z6zg== 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 y34si17984545plb.423.2019.08.22.08.11.17; Thu, 22 Aug 2019 08:11:35 -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 S1729708AbfHVN2s (ORCPT + 99 others); Thu, 22 Aug 2019 09:28:48 -0400 Received: from foss.arm.com ([217.140.110.172]:45842 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388497AbfHVN2e (ORCPT ); Thu, 22 Aug 2019 09:28:34 -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 AE61C1570; Thu, 22 Aug 2019 06:28:32 -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 034023F706; Thu, 22 Aug 2019 06:28:29 -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 v14 3/6] sched/core: uclamp: Propagate system defaults to root group Date: Thu, 22 Aug 2019 14:28:08 +0100 Message-Id: <20190822132811.31294-4-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190822132811.31294-1-patrick.bellasi@arm.com> References: <20190822132811.31294-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 Reviewed-by: Michal Koutny Acked-by: Tejun Heo Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Tejun Heo --- 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 8dab64247597..3ca054ad3f3e 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