Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1481291imj; Fri, 8 Feb 2019 02:08:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IbW+tDT8QX/D0nTfUGn/1wocLA8S7r2cVECWK0u7gFgho9JrmxynsajxGi13Ssb7Dilsjeu X-Received: by 2002:a17:902:1105:: with SMTP id d5mr21190119pla.47.1549620492742; Fri, 08 Feb 2019 02:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549620492; cv=none; d=google.com; s=arc-20160816; b=BNLnmxbQ2Nr+Jjy7VzY9tLBwQpoYeZBP7DzvA0H7Dea3CKbrk9nahWZxIj+kYu50Hh QBV80zevBJfbwA+uC2PLr4tGb4E4MBTvAEA7K590a4SdlKddAqSmaA8ObymtuE/AISWi cWzdzQaK7lOtUXiZv6IUfQciZowtwFxZvRB/PrmYzIXhZ1E26qVl/jAp1Jj+xMmEd+d6 CdyNMu7kEWkOR+Lr/a6hZlt+BIMQf1rvxqVMQ+z0UswRDHPv5aGC1tBr5nT/PSzZhsXt WJXILKLBCEr81HgvdvwN7dETNFMGRhsAEAjxIj0qLhRL9T/Q3wGibU4VsaY56MlHqQqL Vz4A== 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=MuB0nehNZPhCDcjXEJoMCzcN3HGrvHu1fam4haDuvPM=; b=simL4h+nT5WrV+DeA0xQZjWYf6kjHeumv5ofR9nrFkRfoUS5ybQsqzGP92vNaiax+w +9rCrTK96zDO5klwryPNN8lPZVFALWWoE4eP6bn1XbCc9eRAEEmTT17Aivn1f1xQe9E1 mxoaCJcrr4o29vvj4Bf7+hURsmyOTp7kHpwJet6yToaFimsYovexb33vJyr3H33Bwg3b Ru9RmTlExBwBoV/YQGFhx88AuNEW2gCmBY/MoYDIOqXtgokUB7jawLR4S4eDcO2Q4g0R 91hIHzTZHbC1Eyjas/aUCb3/ZB+wRqfiLjsjfq+BB0UuBkSnJpedQXBYwRM2ajIlXhlq QK3Q== 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 j21si1882735pll.150.2019.02.08.02.07.56; Fri, 08 Feb 2019 02:08:12 -0800 (PST) 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 S1727784AbfBHKGu (ORCPT + 99 others); Fri, 8 Feb 2019 05:06:50 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47604 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbfBHKGn (ORCPT ); Fri, 8 Feb 2019 05:06:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5CC7AA78; Fri, 8 Feb 2019 02:06:43 -0800 (PST) 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 460043F557; Fri, 8 Feb 2019 02:06:40 -0800 (PST) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@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 Subject: [PATCH v7 09/15] sched/core: uclamp: Add uclamp_util_with() Date: Fri, 8 Feb 2019 10:05:48 +0000 Message-Id: <20190208100554.32196-10-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190208100554.32196-1-patrick.bellasi@arm.com> References: <20190208100554.32196-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 Currently uclamp_util() allows to clamp a specified utilization considering the clamp values requested by RUNNABLE tasks in a CPU. Sometimes however, it could be interesting to verify how clamp values will change when a task is going to be running on a given CPU. For example, the Energy Aware Scheduler (EAS) is interested in evaluating and comparing the energy impact of different scheduling decisions. 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 Cc: Ingo Molnar Cc: Peter Zijlstra --- kernel/sched/sched.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index f07048a0e845..de181b8a3a2a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2278,11 +2278,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_effective_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_effective_value(p, UCLAMP_MIN)); + max_util = max(max_util, uclamp_effective_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 @@ -2293,7 +2302,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; -- 2.20.1