2021-03-27 08:25:17

by Tian Tao

[permalink] [raw]
Subject: [PATCH] sched/fair: Remove the redundant check in numa_id_core

the numa_idle_core() function have a little redundant. then this patch
move the "idle_core >= 0" check in numa_idle_core() to its caller in
update_numa_stats() and then remove the redundant check in
!static_branch_likely(&sched_smt_present) check in numa_idle_core.

This patch is based on the following discussion:
https://lore.kernel.org/lkml/[email protected]/

Signed-off-by: Tian Tao <[email protected]>
---
kernel/sched/fair.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6d73bdbb..fbff7f1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1569,8 +1569,7 @@ numa_type numa_classify(unsigned int imbalance_pct,
static inline bool test_idle_cores(int cpu, bool def);
static inline int numa_idle_core(int idle_core, int cpu)
{
- if (!static_branch_likely(&sched_smt_present) ||
- idle_core >= 0 || !test_idle_cores(cpu, false))
+ if (!test_idle_cores(cpu, false))
return idle_core;

/*
@@ -1622,7 +1621,8 @@ static void update_numa_stats(struct task_numa_env *env,
if (ns->idle_cpu == -1)
ns->idle_cpu = cpu;

- idle_core = numa_idle_core(idle_core, cpu);
+ if (idle_core >= 0)
+ idle_core = numa_idle_core(idle_core, cpu);
}
}
rcu_read_unlock();
--
2.7.4