Offering: HULK hulk inclusion category: feature bugzilla: NA -------------------------------- Use tg_qos_throttle_down() and tg_qos_unthrottle_up() for QoS throttle to avoid conflicts with CFS bandwidth throttle's task-based model. This removes the need for separate PELT clock handling logic while keeping the list_add/list_del operations. Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com> --- kernel/sched/fair.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 60f7a99eda64..2e4b5d666507 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9722,6 +9722,32 @@ static inline bool is_offline_task(struct task_struct *p) static void start_qos_hrtimer(int cpu); +static int tg_qos_throttle_down(struct task_group *tg, void *data) +{ + struct rq *rq = data; + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + + if (!cfs_rq->throttle_count) + list_del_leaf_cfs_rq(cfs_rq); + + cfs_rq->throttle_count++; + + return 0; +} + +static int tg_qos_unthrottle_up(struct task_group *tg, void *data) +{ + struct rq *rq = data; + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + + cfs_rq->throttle_count--; + + if (!cfs_rq->throttle_count && !cfs_rq_is_decayed(cfs_rq)) + list_add_leaf_cfs_rq(cfs_rq); + + return 0; +} + static void throttle_qos_cfs_rq(struct cfs_rq *cfs_rq) { struct rq *rq = rq_of(cfs_rq); @@ -9736,7 +9762,7 @@ static void throttle_qos_cfs_rq(struct cfs_rq *cfs_rq) /* freeze hierarchy runnable averages while throttled */ rcu_read_lock(); - walk_tg_tree_from(cfs_rq->tg, tg_throttle_down, tg_nop, (void *)rq); + walk_tg_tree_from(cfs_rq->tg, tg_qos_throttle_down, tg_nop, (void *)rq); rcu_read_unlock(); task_delta = cfs_rq->h_nr_running; @@ -9821,7 +9847,7 @@ static void unthrottle_qos_cfs_rq(struct cfs_rq *cfs_rq) /* update hierarchical throttle state */ rcu_read_lock(); - walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_unthrottle_up, (void *)rq); + walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_qos_unthrottle_up, (void *)rq); rcu_read_unlock(); if (!cfs_rq->load.weight) { -- 2.18.0