summaryrefslogtreecommitdiffstats
path: root/kernel/sched/sched.h
diff options
context:
space:
mode:
authorPatrick Bellasi <patrick.bellasi@arm.com>2019-06-21 04:42:11 -0400
committerIngo Molnar <mingo@kernel.org>2019-06-24 13:23:48 -0400
commit9d20ad7dfc9a5cc64e33d725902d3863d350a66a (patch)
treebe71558cdd1e5ea3c13d5555eb2f5de71419e783 /kernel/sched/sched.h
parent982d9cdc22c9f6df5ad790caa229ff74fb1d95e7 (diff)
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 <patrick.bellasi@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Alessio Balsini <balsini@android.com> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> Cc: Joel Fernandes <joelaf@google.com> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Morten Rasmussen <morten.rasmussen@arm.com> Cc: Paul Turner <pjt@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quentin Perret <quentin.perret@arm.com> Cc: Rafael J . Wysocki <rafael.j.wysocki@intel.com> Cc: Steve Muckle <smuckle@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Todd Kjos <tkjos@google.com> Cc: Vincent Guittot <vincent.guittot@linaro.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lkml.kernel.org/r/20190621084217.8167-11-patrick.bellasi@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/sched.h')
-rw-r--r--kernel/sched/sched.h21
1 files changed, 20 insertions, 1 deletions
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) {}
2266#endif /* CONFIG_CPU_FREQ */ 2266#endif /* CONFIG_CPU_FREQ */
2267 2267
2268#ifdef CONFIG_UCLAMP_TASK 2268#ifdef CONFIG_UCLAMP_TASK
2269static inline unsigned int uclamp_util(struct rq *rq, unsigned int util) 2269unsigned int uclamp_eff_value(struct task_struct *p, unsigned int clamp_id);
2270
2271static __always_inline
2272unsigned int uclamp_util_with(struct rq *rq, unsigned int util,
2273 struct task_struct *p)
2270{ 2274{
2271 unsigned int min_util = READ_ONCE(rq->uclamp[UCLAMP_MIN].value); 2275 unsigned int min_util = READ_ONCE(rq->uclamp[UCLAMP_MIN].value);
2272 unsigned int max_util = READ_ONCE(rq->uclamp[UCLAMP_MAX].value); 2276 unsigned int max_util = READ_ONCE(rq->uclamp[UCLAMP_MAX].value);
2273 2277
2278 if (p) {
2279 min_util = max(min_util, uclamp_eff_value(p, UCLAMP_MIN));
2280 max_util = max(max_util, uclamp_eff_value(p, UCLAMP_MAX));
2281 }
2282
2274 /* 2283 /*
2275 * Since CPU's {min,max}_util clamps are MAX aggregated considering 2284 * Since CPU's {min,max}_util clamps are MAX aggregated considering
2276 * RUNNABLE tasks with _different_ clamps, we can end up with an 2285 * 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)
2281 2290
2282 return clamp(util, min_util, max_util); 2291 return clamp(util, min_util, max_util);
2283} 2292}
2293
2294static inline unsigned int uclamp_util(struct rq *rq, unsigned int util)
2295{
2296 return uclamp_util_with(rq, util, NULL);
2297}
2284#else /* CONFIG_UCLAMP_TASK */ 2298#else /* CONFIG_UCLAMP_TASK */
2299static inline unsigned int uclamp_util_with(struct rq *rq, unsigned int util,
2300 struct task_struct *p)
2301{
2302 return util;
2303}
2285static inline unsigned int uclamp_util(struct rq *rq, unsigned int util) 2304static inline unsigned int uclamp_util(struct rq *rq, unsigned int util)
2286{ 2305{
2287 return util; 2306 return util;