Skip to content

Commit cd92bfd

Browse files
deggemanIngo Molnar
authored andcommitted
sched/core: Store maximum per-CPU capacity in root domain
To be able to compare the capacity of the target CPU with the highest available CPU capacity, store the maximum per-CPU capacity in the root domain. The max per-CPU capacity should be 1024 for all systems except SMT, where the capacity is currently based on smt_gain and the number of hardware threads and is <1024. If SMT can be brought to work with a per-thread capacity of 1024, this patch can be dropped and replaced by a hard-coded max capacity of 1024 (=SCHED_CAPACITY_SCALE). Signed-off-by: Dietmar Eggemann <[email protected]> Signed-off-by: Morten Rasmussen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mike Galbraith <[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] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 9ee1cda commit cd92bfd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

kernel/sched/core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6903,6 +6903,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
69036903
enum s_alloc alloc_state;
69046904
struct sched_domain *sd;
69056905
struct s_data d;
6906+
struct rq *rq = NULL;
69066907
int i, ret = -ENOMEM;
69076908

69086909
alloc_state = __visit_domain_allocation_hell(&d, cpu_map);
@@ -6953,11 +6954,22 @@ static int build_sched_domains(const struct cpumask *cpu_map,
69536954
/* Attach the domains */
69546955
rcu_read_lock();
69556956
for_each_cpu(i, cpu_map) {
6957+
rq = cpu_rq(i);
69566958
sd = *per_cpu_ptr(d.sd, i);
6959+
6960+
/* Use READ_ONCE()/WRITE_ONCE() to avoid load/store tearing: */
6961+
if (rq->cpu_capacity_orig > READ_ONCE(d.rd->max_cpu_capacity))
6962+
WRITE_ONCE(d.rd->max_cpu_capacity, rq->cpu_capacity_orig);
6963+
69576964
cpu_attach_domain(sd, d.rd, i);
69586965
}
69596966
rcu_read_unlock();
69606967

6968+
if (rq) {
6969+
pr_info("span: %*pbl (max cpu_capacity = %lu)\n",
6970+
cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity);
6971+
}
6972+
69616973
ret = 0;
69626974
error:
69636975
__free_domain_allocs(&d, alloc_state, cpu_map);

kernel/sched/sched.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ struct root_domain {
565565
*/
566566
cpumask_var_t rto_mask;
567567
struct cpupri cpupri;
568+
569+
unsigned long max_cpu_capacity;
568570
};
569571

570572
extern struct root_domain def_root_domain;

0 commit comments

Comments
 (0)