From 94ef8a9adf23ec495b8cd75b7523f2231947092a Mon Sep 17 00:00:00 2001 From: Cruz Zhao Date: Fri, 7 May 2021 13:53:34 +0800 Subject: [PATCH 2704/2944] alinux: sched: fix the bug that performence reduction on arm fix #34327689 fix #34328292 During the test, we found that commit 665b07fdaac0 caused performence reduction on arm, and we found it's caused by function throttled_hierarchy() called by __update_identity(). We doubt the root cause is that the text segment isn't aligned, so we modified __update_identity() and make id_make_up_nr_running() from __always_inline to noinline, which workaround. TODO: x86 doesn't have this issue, the doubt about alignment on arm needs to be confirmed. Signed-off-by: Cruz Zhao Acked-by: Michael Wang --- kernel/sched/fair.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 820a8d8..f2c8b0b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -926,7 +926,7 @@ static inline bool is_idle_seeker_task(struct task_struct *p) return avg_idle >= sysctl_sched_idle_saver_wmark; } -static __always_inline void +static noinline void id_make_up_nr_running(struct task_group *tg, struct rq *rq, long delta) { struct sched_entity *se = tg->se[cpu_of(rq)]; @@ -1046,7 +1046,7 @@ static void __update_identity(struct task_group *tg, int flags) tg->id_flags = flags; for_each_online_cpu(cpu) { - bool on_rq; + bool on_rq, throttled; long delta, ei_delta; struct cfs_rq *cfs_rq; struct sched_entity *se; @@ -1060,12 +1060,13 @@ static void __update_identity(struct task_group *tg, int flags) delta = se->my_q->nr_tasks; ei_delta = get_h_nr_expel_immune(se); on_rq = se->on_rq; + throttled = throttled_hierarchy(cfs_rq); if (on_rq) { if (se != cfs_rq->curr) __dequeue_entity(cfs_rq, se); hierarchy_update_nr_expel_immune(se, -ei_delta); - if (!throttled_hierarchy(cfs_rq)) + if (!throttled) id_update_nr_running(tg, rq, -delta); update_curr(cfs_rq); @@ -1080,7 +1081,7 @@ static void __update_identity(struct task_group *tg, int flags) if (se != cfs_rq->curr) __enqueue_entity(cfs_rq, se); hierarchy_update_nr_expel_immune(se, ei_delta); - if (!throttled_hierarchy(cfs_rq)) + if (!throttled) id_update_nr_running(tg, rq, delta); update_min_vruntime(cfs_rq); @@ -1729,8 +1730,8 @@ static inline u64 id_vruntime(struct sched_entity *se) return 0; } -static __always_inline -void id_make_up_nr_running(struct task_group *tg, struct rq *rq, long delta) +static inline void +id_make_up_nr_running(struct task_group *tg, struct rq *rq, long delta) { } @@ -4369,8 +4370,6 @@ static long calc_group_runnable(struct cfs_rq *cfs_rq, long shares) } #endif /* CONFIG_SMP */ -static inline int throttled_hierarchy(struct cfs_rq *cfs_rq); - /* * Recomputes the group entity based on the current state of its group * runqueue. -- 1.8.3.1