Skip to content

Commit 398ba2b

Browse files
Abel-WYPeter Zijlstra
authored andcommitted
sched/fair: Default to false in test_idle_cores()
It's uncertain whether idle cores exist or not if shared sched- domains are not ready, so returning "no idle cores" usually makes sense. While __update_idle_core() is an exception, it checks status of this core and set hint to shared sched-domain if necessary. So the whole logic of this function depends on the existence of shared sched-domain, and can certainly bail out early if it is not available. It's somehow a little tricky, and as Josh suggested that it should be transient while the domain isn't ready. So remove the self-defined default value to make things more clearer. Signed-off-by: Abel Wu <wuyun.abel@bytedance.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Josh Don <joshdon@google.com> Acked-by: Mel Gorman <mgorman@techsingularity.net> Link: https://lore.kernel.org/r/20220907112000.1854-5-wuyun.abel@bytedance.com
1 parent 8eeeed9 commit 398ba2b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

kernel/sched/fair.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,11 +1588,11 @@ numa_type numa_classify(unsigned int imbalance_pct,
15881588

15891589
#ifdef CONFIG_SCHED_SMT
15901590
/* Forward declarations of select_idle_sibling helpers */
1591-
static inline bool test_idle_cores(int cpu, bool def);
1591+
static inline bool test_idle_cores(int cpu);
15921592
static inline int numa_idle_core(int idle_core, int cpu)
15931593
{
15941594
if (!static_branch_likely(&sched_smt_present) ||
1595-
idle_core >= 0 || !test_idle_cores(cpu, false))
1595+
idle_core >= 0 || !test_idle_cores(cpu))
15961596
return idle_core;
15971597

15981598
/*
@@ -6271,15 +6271,15 @@ static inline void set_idle_cores(int cpu, int val)
62716271
WRITE_ONCE(sds->has_idle_cores, val);
62726272
}
62736273

6274-
static inline bool test_idle_cores(int cpu, bool def)
6274+
static inline bool test_idle_cores(int cpu)
62756275
{
62766276
struct sched_domain_shared *sds;
62776277

62786278
sds = rcu_dereference(per_cpu(sd_llc_shared, cpu));
62796279
if (sds)
62806280
return READ_ONCE(sds->has_idle_cores);
62816281

6282-
return def;
6282+
return false;
62836283
}
62846284

62856285
/*
@@ -6295,7 +6295,7 @@ void __update_idle_core(struct rq *rq)
62956295
int cpu;
62966296

62976297
rcu_read_lock();
6298-
if (test_idle_cores(core, true))
6298+
if (test_idle_cores(core))
62996299
goto unlock;
63006300

63016301
for_each_cpu(cpu, cpu_smt_mask(core)) {
@@ -6367,9 +6367,9 @@ static inline void set_idle_cores(int cpu, int val)
63676367
{
63686368
}
63696369

6370-
static inline bool test_idle_cores(int cpu, bool def)
6370+
static inline bool test_idle_cores(int cpu)
63716371
{
6372-
return def;
6372+
return false;
63736373
}
63746374

63756375
static inline int select_idle_core(struct task_struct *p, int core, struct cpumask *cpus, int *idle_cpu)
@@ -6608,7 +6608,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
66086608
return target;
66096609

66106610
if (sched_smt_active()) {
6611-
has_idle_core = test_idle_cores(target, false);
6611+
has_idle_core = test_idle_cores(target);
66126612

66136613
if (!has_idle_core && cpus_share_cache(prev, target)) {
66146614
i = select_idle_smt(p, prev);

0 commit comments

Comments
 (0)