From 0e927cb90dc581a8355010f0f81ec7d2c20035f3 Mon Sep 17 00:00:00 2001 From: He Yujie Date: Mon, 9 Dec 2024 12:30:08 +0000 Subject: [PATCH] sched: Optimize the latency of select_task_rq and pick_next_task. hulk inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBA1PI -------------------------------- Reducing the select_task_rq run time by Checking the enable status of dynamic affinity before attempting to hold rcu_lock and deleting the enable check int dynamic_affinity_mode function. Inline functions are used to reduce the execution time of pick_next_time functions. Fixes: 6eb07f9925a9 ("sched: Introduce smart grid scheduling strategy for cfs") Signed-off-by: He Yujie --- kernel/sched/fair.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c05094e4769d..fadc59328e3b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6861,9 +6861,6 @@ static inline struct cpumask *task_prefer_cpus(struct task_struct *p) static inline int dynamic_affinity_mode(struct task_struct *p) { - if (!prefer_cpus_valid(p)) - return -1; - if (smart_grid_used()) return task_group(p)->auto_affinity->mode == 0 ? -1 : 1; @@ -7324,9 +7321,6 @@ static inline struct cpumask *task_prefer_cpus(struct task_struct *p) static inline int dynamic_affinity_mode(struct task_struct *p) { - if (!prefer_cpus_valid(p)) - return -1; - return 0; } #endif /* CONFIG_QOS_SCHED_DYNAMIC_AFFINITY */ @@ -9055,6 +9049,9 @@ static void set_task_select_cpus(struct task_struct *p, int *idlest_cpu, int cpu, mode; p->select_cpus = p->cpus_ptr; + if (!prefer_cpus_valid(p)) + return; + rcu_read_lock(); mode = dynamic_affinity_mode(p); if (mode == -1) { @@ -9734,7 +9731,7 @@ static int __init qos_sched_smt_noexpell_setup(char *__unused) } __setup("nosmtexpell", qos_sched_smt_noexpell_setup); -static bool qos_smt_check_siblings_status(int this_cpu) +static __always_inline bool qos_smt_check_siblings_status(int this_cpu) { int cpu; -- Gitee