From 5eab3ce0b33af1eda06d8725498673a08805bc53 Mon Sep 17 00:00:00 2001 From: zhangwei123171 Date: Mon, 4 Sep 2023 11:57:27 +0800 Subject: [PATCH] sched/fair: fix qos_idle_h_nr_running in enqueue/dequeue jingdong inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7X9JY ----------------------------------------------------- When the container switches from offline mode to online mode, or from offline mode to online mode, qos_idle_h_nr_running will count errors. If task se is counted according to the online task when it enters rq, then it must also be counted according to the online task when it leaves the rq. Fixes: 57b5487b858d0 ("sched/fair: Start tracking qos_offline tasks count in cfs_rq") Signed-off-by: zhangwei123171 Reviewed-by: zhaoxiaoqiang11 --- include/linux/sched.h | 4 ++++ kernel/sched/fair.c | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 5e413d309e77..d39427f8044d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -516,7 +516,11 @@ struct sched_entity { struct sched_avg avg; #endif +#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER + KABI_USE(1, long qos_idle) +#else KABI_RESERVE(1) +#endif KABI_RESERVE(2) KABI_RESERVE(3) KABI_RESERVE(4) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index daa853b19853..6c711b53f440 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5847,12 +5847,17 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) struct cfs_rq *cfs_rq; struct sched_entity *se = &p->se; int idle_h_nr_running = task_has_idle_policy(p); -#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER - int qos_idle_h_nr_running = task_has_qos_idle_policy(p); -#endif + int task_new = !(flags & ENQUEUE_WAKEUP); unsigned int prev_nr = rq->cfs.h_nr_running; +#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER + int qos_idle_h_nr_running; + + se->qos_idle = task_has_qos_idle_policy(p); + qos_idle_h_nr_running = se->qos_idle ? 1 : 0; +#endif + /* * The code below (indirectly) updates schedutil which looks at * the cfs_rq utilization to select a frequency. @@ -5974,12 +5979,16 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) struct sched_entity *se = &p->se; int task_sleep = flags & DEQUEUE_SLEEP; int idle_h_nr_running = task_has_idle_policy(p); -#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER - int qos_idle_h_nr_running = task_has_qos_idle_policy(p); -#endif + unsigned int prev_nr = rq->cfs.h_nr_running; bool was_sched_idle = sched_idle_rq(rq); +#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER + int qos_idle_h_nr_running = se->qos_idle ? 1 : 0; + + se->qos_idle = 0; +#endif + util_est_dequeue(&rq->cfs, p); for_each_sched_entity(se) { -- Gitee