Skip to content

Commit 523e979

Browse files
vingu-linaroIngo Molnar
authored andcommitted
sched/core: Use PELT for scale_rt_capacity()
The utilization of the CPU by RT, DL and IRQs are now tracked with PELT so we can use these metrics instead of rt_avg to evaluate the remaining capacity available for CFS class. scale_rt_capacity() behavior has been changed and now returns the remaining capacity available for CFS instead of a scaling factor because RT, DL and IRQ provide now absolute utilization value. The same formula as schedutil is used: IRQ util_avg + (1 - IRQ util_avg / max capacity ) * /Sum rq util_avg but the implementation is different because it doesn't return the same value and doesn't benefit of the same optimization. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.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 Cc: viresh.kumar@linaro.org Link: http://lkml.kernel.org/r/1530200714-4504-10-git-send-email-vincent.guittot@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent dfa444d commit 523e979

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

kernel/sched/deadline.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,6 @@ static void update_curr_dl(struct rq *rq)
11801180
curr->se.exec_start = now;
11811181
cgroup_account_cputime(curr, delta_exec);
11821182

1183-
sched_rt_avg_update(rq, delta_exec);
1184-
11851183
if (dl_entity_is_special(dl_se))
11861184
return;
11871185

kernel/sched/fair.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7551,39 +7551,39 @@ static inline int get_sd_load_idx(struct sched_domain *sd,
75517551
static unsigned long scale_rt_capacity(int cpu)
75527552
{
75537553
struct rq *rq = cpu_rq(cpu);
7554-
u64 total, used, age_stamp, avg;
7555-
s64 delta;
7556-
7557-
/*
7558-
* Since we're reading these variables without serialization make sure
7559-
* we read them once before doing sanity checks on them.
7560-
*/
7561-
age_stamp = READ_ONCE(rq->age_stamp);
7562-
avg = READ_ONCE(rq->rt_avg);
7563-
delta = __rq_clock_broken(rq) - age_stamp;
7554+
unsigned long max = arch_scale_cpu_capacity(NULL, cpu);
7555+
unsigned long used, free;
7556+
#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
7557+
unsigned long irq;
7558+
#endif
75647559

7565-
if (unlikely(delta < 0))
7566-
delta = 0;
7560+
#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
7561+
irq = READ_ONCE(rq->avg_irq.util_avg);
75677562

7568-
total = sched_avg_period() + delta;
7563+
if (unlikely(irq >= max))
7564+
return 1;
7565+
#endif
75697566

7570-
used = div_u64(avg, total);
7567+
used = READ_ONCE(rq->avg_rt.util_avg);
7568+
used += READ_ONCE(rq->avg_dl.util_avg);
75717569

7572-
if (likely(used < SCHED_CAPACITY_SCALE))
7573-
return SCHED_CAPACITY_SCALE - used;
7570+
if (unlikely(used >= max))
7571+
return 1;
75747572

7575-
return 1;
7573+
free = max - used;
7574+
#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
7575+
free *= (max - irq);
7576+
free /= max;
7577+
#endif
7578+
return free;
75767579
}
75777580

75787581
static void update_cpu_capacity(struct sched_domain *sd, int cpu)
75797582
{
7580-
unsigned long capacity = arch_scale_cpu_capacity(sd, cpu);
7583+
unsigned long capacity = scale_rt_capacity(cpu);
75817584
struct sched_group *sdg = sd->groups;
75827585

7583-
cpu_rq(cpu)->cpu_capacity_orig = capacity;
7584-
7585-
capacity *= scale_rt_capacity(cpu);
7586-
capacity >>= SCHED_CAPACITY_SHIFT;
7586+
cpu_rq(cpu)->cpu_capacity_orig = arch_scale_cpu_capacity(sd, cpu);
75877587

75887588
if (!capacity)
75897589
capacity = 1;

kernel/sched/pelt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ ___update_load_avg(struct sched_avg *sa, unsigned long load, unsigned long runna
237237
*/
238238
sa->load_avg = div_u64(load * sa->load_sum, divider);
239239
sa->runnable_load_avg = div_u64(runnable * sa->runnable_load_sum, divider);
240-
sa->util_avg = sa->util_sum / divider;
240+
WRITE_ONCE(sa->util_avg, sa->util_sum / divider);
241241
}
242242

243243
/*

kernel/sched/rt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,6 @@ static void update_curr_rt(struct rq *rq)
973973
curr->se.exec_start = now;
974974
cgroup_account_cputime(curr, delta_exec);
975975

976-
sched_rt_avg_update(rq, delta_exec);
977-
978976
if (!rt_bandwidth_enabled())
979977
return;
980978

0 commit comments

Comments
 (0)