Skip to content

Commit 7e1a920

Browse files
Juri LelliIngo Molnar
authored andcommitted
sched/cpufreq: Move arch_scale_{freq,cpu}_capacity() outside of #ifdef CONFIG_SMP
Currently, frequency and cpu capacity scaling is only performed on CONFIG_SMP systems (as CFS PELT signals are only present for such systems). However, other scheduling classes want to do freq/cpu scaling, and for !CONFIG_SMP configurations as well. arch_scale_freq_capacity() is useful to implement frequency scaling even on !CONFIG_SMP platforms, so we simply move it outside CONFIG_SMP ifdeffery. Even if arch_scale_cpu_capacity() is not useful on !CONFIG_SMP platforms, we make a default implementation available for such configurations anyway to simplify scheduler code doing CPU scale invariance. Signed-off-by: Juri Lelli <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 7673c8a commit 7e1a920

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

include/linux/sched/topology.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
#include <linux/sched/idle.h>
88

9+
/*
10+
* Increase resolution of cpu_capacity calculations
11+
*/
12+
#define SCHED_CAPACITY_SHIFT SCHED_FIXEDPOINT_SHIFT
13+
#define SCHED_CAPACITY_SCALE (1L << SCHED_CAPACITY_SHIFT)
14+
915
/*
1016
* sched-domains (multiprocessor balancing) declarations:
1117
*/
@@ -27,12 +33,6 @@
2733
#define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */
2834
#define SD_NUMA 0x4000 /* cross-node balancing */
2935

30-
/*
31-
* Increase resolution of cpu_capacity calculations
32-
*/
33-
#define SCHED_CAPACITY_SHIFT SCHED_FIXEDPOINT_SHIFT
34-
#define SCHED_CAPACITY_SCALE (1L << SCHED_CAPACITY_SHIFT)
35-
3636
#ifdef CONFIG_SCHED_SMT
3737
static inline int cpu_smt_flags(void)
3838
{

kernel/sched/sched.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,9 +1670,6 @@ static inline int hrtick_enabled(struct rq *rq)
16701670

16711671
#endif /* CONFIG_SCHED_HRTICK */
16721672

1673-
#ifdef CONFIG_SMP
1674-
extern void sched_avg_update(struct rq *rq);
1675-
16761673
#ifndef arch_scale_freq_capacity
16771674
static __always_inline
16781675
unsigned long arch_scale_freq_capacity(int cpu)
@@ -1681,6 +1678,9 @@ unsigned long arch_scale_freq_capacity(int cpu)
16811678
}
16821679
#endif
16831680

1681+
#ifdef CONFIG_SMP
1682+
extern void sched_avg_update(struct rq *rq);
1683+
16841684
#ifndef arch_scale_cpu_capacity
16851685
static __always_inline
16861686
unsigned long arch_scale_cpu_capacity(struct sched_domain *sd, int cpu)
@@ -1698,6 +1698,13 @@ static inline void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
16981698
sched_avg_update(rq);
16991699
}
17001700
#else
1701+
#ifndef arch_scale_cpu_capacity
1702+
static __always_inline
1703+
unsigned long arch_scale_cpu_capacity(void __always_unused *sd, int cpu)
1704+
{
1705+
return SCHED_CAPACITY_SCALE;
1706+
}
1707+
#endif
17011708
static inline void sched_rt_avg_update(struct rq *rq, u64 rt_delta) { }
17021709
static inline void sched_avg_update(struct rq *rq) { }
17031710
#endif

0 commit comments

Comments
 (0)