Skip to content

Commit 8cd5601

Browse files
msrasmusseningomolnar
authored andcommitted
sched/fair: Convert arch_scale_cpu_capacity() from weak function to #define
Bring arch_scale_cpu_capacity() in line with the recent change of its arch_scale_freq_capacity() sibling in commit dfbca41 ("sched: Optimize freq invariant accounting") from weak function to #define to allow inlining of the function. While at it, remove the ARCH_CAPACITY sched_feature as well. With the change to #define there isn't a straightforward way to allow runtime switch between an arch implementation and the default implementation of arch_scale_cpu_capacity() using sched_feature. The default was to use the arch-specific implementation, but only the arm architecture provides one and that is essentially equivalent to the default implementation. Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Dietmar Eggemann <Dietmar.Eggemann@arm.com> Cc: Juri Lelli <Juri.Lelli@arm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: daniel.lezcano@linaro.org Cc: mturquette@baylibre.com Cc: pang.xunlei@zte.com.cn Cc: rjw@rjwysocki.net Cc: sgurrappadi@nvidia.com Cc: vincent.guittot@linaro.org Cc: yuyang.du@intel.com Link: http://lkml.kernel.org/r/1439569394-11974-3-git-send-email-morten.rasmussen@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent e0f5f3a commit 8cd5601

3 files changed

Lines changed: 12 additions & 26 deletions

File tree

‎kernel/sched/fair.c‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6054,19 +6054,6 @@ static inline int get_sd_load_idx(struct sched_domain *sd,
60546054
return load_idx;
60556055
}
60566056

6057-
static unsigned long default_scale_cpu_capacity(struct sched_domain *sd, int cpu)
6058-
{
6059-
if ((sd->flags & SD_SHARE_CPUCAPACITY) && (sd->span_weight > 1))
6060-
return sd->smt_gain / sd->span_weight;
6061-
6062-
return SCHED_CAPACITY_SCALE;
6063-
}
6064-
6065-
unsigned long __weak arch_scale_cpu_capacity(struct sched_domain *sd, int cpu)
6066-
{
6067-
return default_scale_cpu_capacity(sd, cpu);
6068-
}
6069-
60706057
static unsigned long scale_rt_capacity(int cpu)
60716058
{
60726059
struct rq *rq = cpu_rq(cpu);
@@ -6096,16 +6083,9 @@ static unsigned long scale_rt_capacity(int cpu)
60966083

60976084
static void update_cpu_capacity(struct sched_domain *sd, int cpu)
60986085
{
6099-
unsigned long capacity = SCHED_CAPACITY_SCALE;
6086+
unsigned long capacity = arch_scale_cpu_capacity(sd, cpu);
61006087
struct sched_group *sdg = sd->groups;
61016088

6102-
if (sched_feat(ARCH_CAPACITY))
6103-
capacity *= arch_scale_cpu_capacity(sd, cpu);
6104-
else
6105-
capacity *= default_scale_cpu_capacity(sd, cpu);
6106-
6107-
capacity >>= SCHED_CAPACITY_SHIFT;
6108-
61096089
cpu_rq(cpu)->cpu_capacity_orig = capacity;
61106090

61116091
capacity *= scale_rt_capacity(cpu);

‎kernel/sched/features.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ SCHED_FEAT(CACHE_HOT_BUDDY, true)
3636
*/
3737
SCHED_FEAT(WAKEUP_PREEMPTION, true)
3838

39-
/*
40-
* Use arch dependent cpu capacity functions
41-
*/
42-
SCHED_FEAT(ARCH_CAPACITY, true)
43-
4439
SCHED_FEAT(HRTICK, false)
4540
SCHED_FEAT(DOUBLE_TICK, false)
4641
SCHED_FEAT(LB_BIAS, true)

‎kernel/sched/sched.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,17 @@ unsigned long arch_scale_freq_capacity(struct sched_domain *sd, int cpu)
13941394
}
13951395
#endif
13961396

1397+
#ifndef arch_scale_cpu_capacity
1398+
static __always_inline
1399+
unsigned long arch_scale_cpu_capacity(struct sched_domain *sd, int cpu)
1400+
{
1401+
if ((sd->flags & SD_SHARE_CPUCAPACITY) && (sd->span_weight > 1))
1402+
return sd->smt_gain / sd->span_weight;
1403+
1404+
return SCHED_CAPACITY_SCALE;
1405+
}
1406+
#endif
1407+
13971408
static inline void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
13981409
{
13991410
rq->rt_avg += rt_delta * arch_scale_freq_capacity(NULL, cpu_of(rq));

0 commit comments

Comments
 (0)