sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq
PATCH 1/2 sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq
Since commit 23127296889f ("sched/fair: Update scale invariance of PELT") change to use rq_clock_pelt() instead of rq_clock_task(), we should also use rq_clock_pelt() for throttled_clock_task_time and throttled_clock_task accounting.
--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/fair.c +3 -3
@@ -4846,7 +4846,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttle_count--;if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task_time +=rq_clock_task (rq) - + cfs_rq->throttled_clock_task_time +=rq_clock_pelt (rq) - cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */
@@ -4864,7 +4864,7 @@ static int tg_throttle_down(struct task_group *tg, void *data)/* group is entering throttled state, stop time */ if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task =rq_clock_task (rq); + cfs_rq->throttled_clock_task =rq_clock_pelt (rq);list_del_leaf_cfs_rq (cfs_rq); } cfs_rq->throttle_count++;
@@ -5308,7 +5308,7 @@ static void sync_throttle(struct task_group *tg, int cpu) pcfs_rq = tg->parent->cfs_rq[cpu]; cfs_rq->throttle_count = pcfs_rq->throttle_count; - cfs_rq->throttled_clock_task =rq_clock_task (cpu_rq (cpu)); + cfs_rq->throttled_clock_task =rq_clock_pelt (cpu_rq (cpu)); }/* conditionally throttle active cfs_rq's from put_prev_entity() */
Signature · 1 line
2.35.1
PATCH 2/2 sched/fair: Delete useless condition in tg_unthrottle_up()
Fully decayed cfs_rq is impossible to have queued entities, the first condition "!cfs_rq_is_decayed(cfs_rq)" is enough to cover.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -4850,7 +4850,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */ -if (!cfs_rq_is_decayed (cfs_rq) || cfs_rq->nr_running) +if (!cfs_rq_is_decayed (cfs_rq))list_add_leaf_cfs_rq (cfs_rq); }
Signature · 1 line
2.35.1
Re: [PATCH 2/2] sched/fair: Delete useless condition in tg_unthrottle_up()
Quoted 3 lines · Chengming Zhou
Fully decayed
cfs_rqis impossible to have queued entities, the first condition "!cfs_rq_is_decayed(cfs_rq)" is enough to cover.
In particular, cfs_rq->load.weight is part of cfs_rq_is_decayed.
Quoted 18 lines
Signed-off-by Chengming Zhou <[email protected]>--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/fair.c +1
-1@@ -4850,7 +4850,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */ -if (!cfs_rq_is_decayed (cfs_rq) || cfs_rq->nr_running) +if (!cfs_rq_is_decayed (cfs_rq))list_add_leaf_cfs_rq (cfs_rq); }
Re: [PATCH 2/2] sched/fair: Delete useless condition in tg_unthrottle_up()
Quoted 8 lines · Benjamin Segall
Quoted 3 lines · Chengming Zhou
Fully decayed
cfs_rqis impossible to have queued entities, the first condition "!cfs_rq_is_decayed(cfs_rq)" is enough to cover.In particular,
cfs_rq->load.weightis part ofcfs_rq_is_decayed.
Testing cfs_rq->load.weight is the key point because nothing prevent to add a task with null load
Quoted 21 lines
Reviewed-by Ben Segall <[email protected]>Quoted 18 lines
Signed-off-by Chengming Zhou <[email protected]>--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/fair.c +1
-1@@ -4850,7 +4850,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */ -if (!cfs_rq_is_decayed (cfs_rq) || cfs_rq->nr_running) +if (!cfs_rq_is_decayed (cfs_rq))list_add_leaf_cfs_rq (cfs_rq); }
Quoted 4 lines · Chengming Zhou
Since commit
23127296889f("sched/fair: Update scale invariance of PELT") change to userq_clock_pelt()instead ofrq_clock_task(), we should also userq_clock_pelt()forthrottled_clock_task_timeandthrottled_clock_taskaccounting.
I think this patch is indeed what we want, despite the confusing interactions between pelt slowdown+skipping and throttle_clock_task trying to freeze time.
I think it would be slightly better to rename throttled_clock_task(_time) to be clock_pelt rather than clock_task, but that's minor.
Quoted 38 lines
Fixes 23127296889f ("sched/fair: Update scale invariance of PELT")Signed-off-by Chengming Zhou <[email protected]>--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/sched/fair.c +3
-3@@ -4846,7 +4846,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttle_count--;if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task_time +=rq_clock_task (rq) - + cfs_rq->throttled_clock_task_time +=rq_clock_pelt (rq) - cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */ @@ -4864,7 +4864,7 @@ static int tg_throttle_down(struct task_group *tg, void *data)/* group is entering throttled state, stop time */ if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task =rq_clock_task (rq); + cfs_rq->throttled_clock_task =rq_clock_pelt (rq);list_del_leaf_cfs_rq (cfs_rq); } cfs_rq->throttle_count++;@@ -5308,7 +5308,7 @@ static void sync_throttle(struct task_group *tg, int cpu) pcfs_rq = tg->parent->cfs_rq[cpu]; cfs_rq->throttle_count = pcfs_rq->throttle_count; - cfs_rq->throttled_clock_task =rq_clock_task (cpu_rq (cpu)); + cfs_rq->throttled_clock_task =rq_clock_pelt (cpu_rq (cpu)); }/* conditionally throttle active cfs_rq's from put_prev_entity() */
Quoted 7 lines · Benjamin Segall
Quoted 4 lines · Chengming Zhou
Since commit
23127296889f("sched/fair: Update scale invariance of PELT") change to userq_clock_pelt()instead ofrq_clock_task(), we should also userq_clock_pelt()forthrottled_clock_task_timeandthrottled_clock_taskaccounting.
Quoted 7 lines
I think this patch is indeed what we want, despite the confusing interactions between pelt slowdown+skipping and
throttle_clock_tasktrying to freeze time.I think it would be slightly better to rename
throttled_clock_task(_time)to beclock_peltrather thanclock_task, but that's minor.
It's a good suggestion, will do and send v2.
Thanks.
Quoted 41 lines
Reviewed-by Ben Segall <[email protected]>Quoted 38 lines
Fixes 23127296889f ("sched/fair: Update scale invariance of PELT")Signed-off-by Chengming Zhou <[email protected]>--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/sched/fair.c +3
-3@@ -4846,7 +4846,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttle_count--;if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task_time +=rq_clock_task (rq) - + cfs_rq->throttled_clock_task_time +=rq_clock_pelt (rq) - cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */ @@ -4864,7 +4864,7 @@ static int tg_throttle_down(struct task_group *tg, void *data)/* group is entering throttled state, stop time */ if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task =rq_clock_task (rq); + cfs_rq->throttled_clock_task =rq_clock_pelt (rq);list_del_leaf_cfs_rq (cfs_rq); } cfs_rq->throttle_count++;@@ -5308,7 +5308,7 @@ static void sync_throttle(struct task_group *tg, int cpu) pcfs_rq = tg->parent->cfs_rq[cpu]; cfs_rq->throttle_count = pcfs_rq->throttle_count; - cfs_rq->throttled_clock_task =rq_clock_task (cpu_rq (cpu)); + cfs_rq->throttled_clock_task =rq_clock_pelt (cpu_rq (cpu)); }/* conditionally throttle active cfs_rq's from put_prev_entity() */
Quoted 8 lines · Chengming Zhou
Since commit
23127296889f("sched/fair: Update scale invariance of PELT") change to userq_clock_pelt()instead ofrq_clock_task(), we should also userq_clock_pelt()forthrottled_clock_task_timeandthrottled_clock_taskaccounting.Fixes 23127296889f ("sched/fair: Update scale invariance of PELT")Signed-off-by Chengming Zhou <[email protected]>
Quoted 38 lines
--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/sched/fair.c +3
-4@@ -4846,7 +4846,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttle_count--;if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task_time +=rq_clock_task (rq) - + cfs_rq->throttled_clock_task_time +=rq_clock_pelt (rq) - cfs_rq->throttled_clock_task;/* Add cfs_rq with load or one or more already running entities to the list */ @@ -4864,7 +4864,7 @@ static int tg_throttle_down(struct task_group *tg, void *data)/* group is entering throttled state, stop time */ if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task =rq_clock_task (rq); + cfs_rq->throttled_clock_task =rq_clock_pelt (rq);list_del_leaf_cfs_rq (cfs_rq); } cfs_rq->throttle_count++;@@ -5308,7 +5308,7 @@ static void sync_throttle(struct task_group *tg, int cpu) pcfs_rq = tg->parent->cfs_rq[cpu]; cfs_rq->throttle_count = pcfs_rq->throttle_count; - cfs_rq->throttled_clock_task =rq_clock_task (cpu_rq (cpu)); + cfs_rq->throttled_clock_task =rq_clock_pelt (cpu_rq (cpu)); }/* conditionally throttle active cfs_rq's from put_prev_entity() */ --2.35.1