Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3392254ybd; Tue, 25 Jun 2019 01:37:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlgx4iEXUwzdeu7wVLr3ypLA8sNhRrShs2nepdxU9JbtdjcYr1OzaLWhMyEc6CpJSMcJEM X-Received: by 2002:a65:454c:: with SMTP id x12mr37788086pgr.354.1561451878582; Tue, 25 Jun 2019 01:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561451878; cv=none; d=google.com; s=arc-20160816; b=uj2mZaQOPqyFl2v6bTRQHacXDcgg+OZsicsXBuXob721vyWmiGXWRNnH2Zr4fli6yw eL30S+KEMawvnSGW3HkzvAyFaQsGHy4jmvHilaCvRwaBacWibcU/XV9DHTQ5WzsxZSWq QImJS6ttOR6XbJLWtaAPCKzeZDhMtV1vhcB7iGW47yGlpWJxAVMD+7x+7Pwj2GBlMtJA 4dXirXCKfIq9X0Uv48f2pzDcvRpYxXp9KOHepRb/OdyLxesVZ7yEi0hWbfDgg+Z9lQVX Jy70s4Qyqwa92TvwajnU4eaH88ljC9ow0h74phFyr7UtiOURp0i6TDpwtT+1GQLNThHL dWFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=rmFBswgpno9iHjZKzzTqaubK1JLgiNCqDsNJ3THSVfM=; b=RZpyfNbPItHgos2UeaLU0sGe9eVqLg5dp8G5Zg8ms/Cj92ruacZWYyIdIaNzIO9430 z1GTxRAhbri4SrMbSUFeQhB4AArPUBrF3dkd82hL0xqDYf7B4LD9dovi5vV7i0sOC3ls 36Sf+5kPrzDy2UjcvBUuuwx40ZXdp4wNujvogvBtdsXNCp+e2R8QcQaQKTJxGuzLnbHt pqx/i4wTxVKoG5zoseMTz2ofWYwcHc2wyQoSeO/nipVqt/a0mfIQNpQmnez/QRgbtKMa 3FzgMMxoAa3nRSZhH3KYybQWNJJSTzomxTRAmZ+smV1CXmZyKZJ5v+tsaVBZDDNs8pqb lq7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=YhKEr7US; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si13746233pgn.369.2019.06.25.01.37.43; Tue, 25 Jun 2019 01:37:58 -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; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=YhKEr7US; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730657AbfFYIhB (ORCPT + 99 others); Tue, 25 Jun 2019 04:37:01 -0400 Received: from terminus.zytor.com ([198.137.202.136]:40523 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728473AbfFYIhA (ORCPT ); Tue, 25 Jun 2019 04:37:00 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5P8aRrc3532095 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 25 Jun 2019 01:36:27 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5P8aRrc3532095 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561451788; bh=rmFBswgpno9iHjZKzzTqaubK1JLgiNCqDsNJ3THSVfM=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=YhKEr7USQeaIG64giBF3XkXnHfZ4/AOY7Qpke5q7ceOcIwp+pVureK32+2lEVIoa2 jFAsonRxWm+HffxymA7R7pjJ/KRlesXeHVyQQ8HEd4RNKSv1tf4T3LQEHuNKTEhNMi p6c1V6770CA+P0UWoAwtCSHKqyfLY5y5zekTHolufWKVWqZUkwljxgbGEUAWUERoTV IG83IgtTG0ZzXjqKXlNySFnJ6t+NdI1GgkHf5iuFDLUGtTbGhLXbNm3JOGBck4f6TB LMSHwA6U+kX+SKMUKoF9qoo10F3C99c5A6oYP1uo3XU/XRV8ZX3hk1Rh+/hKvHSqzw X5EpWFEsD2ujg== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5P8aQQl3532092; Tue, 25 Jun 2019 01:36:26 -0700 Date: Tue, 25 Jun 2019 01:36:26 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Patrick Bellasi Message-ID: Cc: dietmar.eggemann@arm.com, balsini@android.com, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org, viresh.kumar@linaro.org, mingo@kernel.org, peterz@infradead.org, tkjos@google.com, hpa@zytor.com, smuckle@google.com, vincent.guittot@linaro.org, juri.lelli@redhat.com, surenb@google.com, patrick.bellasi@arm.com, tglx@linutronix.de, quentin.perret@arm.com, torvalds@linux-foundation.org, tj@kernel.org, pjt@google.com, morten.rasmussen@arm.com, joelaf@google.com Reply-To: smuckle@google.com, vincent.guittot@linaro.org, mingo@kernel.org, peterz@infradead.org, hpa@zytor.com, tkjos@google.com, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org, viresh.kumar@linaro.org, dietmar.eggemann@arm.com, balsini@android.com, juri.lelli@redhat.com, tglx@linutronix.de, surenb@google.com, patrick.bellasi@arm.com, morten.rasmussen@arm.com, joelaf@google.com, pjt@google.com, torvalds@linux-foundation.org, tj@kernel.org, quentin.perret@arm.com In-Reply-To: <20190621084217.8167-11-patrick.bellasi@arm.com> References: <20190621084217.8167-11-patrick.bellasi@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/uclamp: Add uclamp_util_with() Git-Commit-ID: 9d20ad7dfc9a5cc64e33d725902d3863d350a66a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 9d20ad7dfc9a5cc64e33d725902d3863d350a66a Gitweb: https://git.kernel.org/tip/9d20ad7dfc9a5cc64e33d725902d3863d350a66a Author: Patrick Bellasi AuthorDate: Fri, 21 Jun 2019 09:42:11 +0100 Committer: Ingo Molnar CommitDate: Mon, 24 Jun 2019 19:23:48 +0200 sched/uclamp: Add uclamp_util_with() So far uclamp_util() allows to clamp a specified utilization considering the clamp values requested by RUNNABLE tasks in a CPU. For the Energy Aware Scheduler (EAS) it is interesting to test how clamp values will change when a task is becoming RUNNABLE on a given CPU. For example, EAS is interested in comparing the energy impact of different scheduling decisions and the clamp values can play a role on that. Add uclamp_util_with() which allows to clamp a given utilization by considering the possible impact on CPU clamp values of a specified task. Signed-off-by: Patrick Bellasi Signed-off-by: Peter Zijlstra (Intel) 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: Tejun Heo Cc: Thomas Gleixner Cc: Todd Kjos Cc: Vincent Guittot Cc: Viresh Kumar Link: https://lkml.kernel.org/r/20190621084217.8167-11-patrick.bellasi@arm.com Signed-off-by: Ingo Molnar --- kernel/sched/core.c | 13 +++++++++++++ kernel/sched/sched.h | 21 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6cd5133f0c2a..fa43ce3962e7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -880,6 +880,19 @@ uclamp_eff_get(struct task_struct *p, unsigned int clamp_id) return uc_req; } +unsigned int uclamp_eff_value(struct task_struct *p, unsigned int clamp_id) +{ + struct uclamp_se uc_eff; + + /* Task currently refcounted: use back-annotated (effective) value */ + if (p->uclamp[clamp_id].active) + return p->uclamp[clamp_id].value; + + uc_eff = uclamp_eff_get(p, clamp_id); + + return uc_eff.value; +} + /* * When a task is enqueued on a rq, the clamp bucket currently defined by the * task's uclamp::bucket_id is refcounted on that rq. This also immediately diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9b0c77a99346..1783f6b4c2e0 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2266,11 +2266,20 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {} #endif /* CONFIG_CPU_FREQ */ #ifdef CONFIG_UCLAMP_TASK -static inline unsigned int uclamp_util(struct rq *rq, unsigned int util) +unsigned int uclamp_eff_value(struct task_struct *p, unsigned int clamp_id); + +static __always_inline +unsigned int uclamp_util_with(struct rq *rq, unsigned int util, + struct task_struct *p) { unsigned int min_util = READ_ONCE(rq->uclamp[UCLAMP_MIN].value); unsigned int max_util = READ_ONCE(rq->uclamp[UCLAMP_MAX].value); + if (p) { + min_util = max(min_util, uclamp_eff_value(p, UCLAMP_MIN)); + max_util = max(max_util, uclamp_eff_value(p, UCLAMP_MAX)); + } + /* * Since CPU's {min,max}_util clamps are MAX aggregated considering * RUNNABLE tasks with _different_ clamps, we can end up with an @@ -2281,7 +2290,17 @@ static inline unsigned int uclamp_util(struct rq *rq, unsigned int util) return clamp(util, min_util, max_util); } + +static inline unsigned int uclamp_util(struct rq *rq, unsigned int util) +{ + return uclamp_util_with(rq, util, NULL); +} #else /* CONFIG_UCLAMP_TASK */ +static inline unsigned int uclamp_util_with(struct rq *rq, unsigned int util, + struct task_struct *p) +{ + return util; +} static inline unsigned int uclamp_util(struct rq *rq, unsigned int util) { return util;