Skip to content

Commit dfa444d

Browse files
vingu-linaroIngo Molnar
authored andcommitted
sched/cpufreq: Remove sugov_aggregate_util()
There is no reason why sugov_get_util() and sugov_aggregate_util() were in fact separate functions. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> [ Rebased after adding irq tracking and fixed some compilation errors. ] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Morten.Rasmussen@arm.com Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: claudio@evidence.eu.com Cc: daniel.lezcano@linaro.org Cc: dietmar.eggemann@arm.com Cc: joel@joelfernandes.org Cc: juri.lelli@redhat.com Cc: luca.abeni@santannapisa.it Cc: patrick.bellasi@arm.com Cc: quentin.perret@arm.com Cc: rjw@rjwysocki.net Cc: valentin.schneider@arm.com Link: http://lkml.kernel.org/r/1530200714-4504-9-git-send-email-vincent.guittot@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 9033ea1 commit dfa444d

File tree

2 files changed

+16
-30
lines changed

2 files changed

+16
-30
lines changed

kernel/sched/cpufreq_schedutil.c

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ struct sugov_cpu {
5353
unsigned int iowait_boost_max;
5454
u64 last_update;
5555

56-
/* The fields below are only needed when sharing a policy: */
57-
unsigned long util_cfs;
58-
unsigned long util_dl;
5956
unsigned long bw_dl;
60-
unsigned long util_rt;
61-
unsigned long util_irq;
6257
unsigned long max;
6358

6459
/* The field below is for single-CPU policies only: */
@@ -182,38 +177,31 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
182177
return cpufreq_driver_resolve_freq(policy, freq);
183178
}
184179

185-
static void sugov_get_util(struct sugov_cpu *sg_cpu)
180+
static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu)
186181
{
187182
struct rq *rq = cpu_rq(sg_cpu->cpu);
183+
unsigned long util, irq, max;
188184

189-
sg_cpu->max = arch_scale_cpu_capacity(NULL, sg_cpu->cpu);
190-
sg_cpu->util_cfs = cpu_util_cfs(rq);
191-
sg_cpu->util_dl = cpu_util_dl(rq);
192-
sg_cpu->bw_dl = cpu_bw_dl(rq);
193-
sg_cpu->util_rt = cpu_util_rt(rq);
194-
sg_cpu->util_irq = cpu_util_irq(rq);
195-
}
196-
197-
static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu)
198-
{
199-
struct rq *rq = cpu_rq(sg_cpu->cpu);
200-
unsigned long util, max = sg_cpu->max;
185+
sg_cpu->max = max = arch_scale_cpu_capacity(NULL, sg_cpu->cpu);
186+
sg_cpu->bw_dl = cpu_bw_dl(rq);
201187

202188
if (rt_rq_is_runnable(&rq->rt))
203-
return sg_cpu->max;
189+
return max;
190+
191+
irq = cpu_util_irq(rq);
204192

205-
if (unlikely(sg_cpu->util_irq >= max))
193+
if (unlikely(irq >= max))
206194
return max;
207195

208196
/* Sum rq utilization */
209-
util = sg_cpu->util_cfs;
210-
util += sg_cpu->util_rt;
197+
util = cpu_util_cfs(rq);
198+
util += cpu_util_rt(rq);
211199

212200
/*
213201
* Interrupt time is not seen by RQS utilization so we can compare
214202
* them with the CPU capacity
215203
*/
216-
if ((util + sg_cpu->util_dl) >= max)
204+
if ((util + cpu_util_dl(rq)) >= max)
217205
return max;
218206

219207
/*
@@ -231,11 +219,11 @@ static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu)
231219
*/
232220

233221
/* Weight RQS utilization to normal context window */
234-
util *= (max - sg_cpu->util_irq);
222+
util *= (max - irq);
235223
util /= max;
236224

237225
/* Add interrupt utilization */
238-
util += sg_cpu->util_irq;
226+
util += irq;
239227

240228
/* Add DL bandwidth requirement */
241229
util += sg_cpu->bw_dl;
@@ -418,9 +406,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
418406

419407
busy = sugov_cpu_is_busy(sg_cpu);
420408

421-
sugov_get_util(sg_cpu);
409+
util = sugov_get_util(sg_cpu);
422410
max = sg_cpu->max;
423-
util = sugov_aggregate_util(sg_cpu);
424411
sugov_iowait_apply(sg_cpu, time, &util, &max);
425412
next_f = get_next_freq(sg_policy, util, max);
426413
/*
@@ -459,9 +446,8 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
459446
struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
460447
unsigned long j_util, j_max;
461448

462-
sugov_get_util(j_sg_cpu);
449+
j_util = sugov_get_util(j_sg_cpu);
463450
j_max = j_sg_cpu->max;
464-
j_util = sugov_aggregate_util(j_sg_cpu);
465451
sugov_iowait_apply(j_sg_cpu, time, &j_util, &j_max);
466452

467453
if (j_util * max > j_max * util) {

kernel/sched/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ static inline unsigned long cpu_util_cfs(struct rq *rq)
22262226

22272227
static inline unsigned long cpu_util_rt(struct rq *rq)
22282228
{
2229-
return rq->avg_rt.util_avg;
2229+
return READ_ONCE(rq->avg_rt.util_avg);
22302230
}
22312231

22322232
#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)

0 commit comments

Comments
 (0)