2022-04-07 19:51:04

by Chengming Zhou

[permalink] [raw]
Subject: [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.

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(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d4bd299d67ab..e6fa5d1141b4 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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


2022-04-07 21:42:44

by Benjamin Segall

[permalink] [raw]
Subject: Re: [PATCH 1/2] sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq

Chengming Zhou <[email protected]> writes:

> 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.

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.

Reviewed-by: Ben Segall <[email protected]>

>
> 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(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d4bd299d67ab..e6fa5d1141b4 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -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() */

2022-04-08 06:53:53

by Chengming Zhou

[permalink] [raw]
Subject: Re: [External] Re: [PATCH 1/2] sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq

On 2022/4/8 04:57, Benjamin Segall wrote:
> Chengming Zhou <[email protected]> writes:
>
>> 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.
>
> 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.

It's a good suggestion, will do and send v2.

Thanks.

>
> Reviewed-by: Ben Segall <[email protected]>
>
>>
>> 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(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index d4bd299d67ab..e6fa5d1141b4 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -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() */

2022-04-08 07:44:20

by Vincent Guittot

[permalink] [raw]
Subject: Re: [PATCH 1/2] sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq

On Thu, 7 Apr 2022 at 04:17, Chengming Zhou <[email protected]> wrote:
>
> 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.
>
> Fixes: 23127296889f ("sched/fair: Update scale invariance of PELT")
> Signed-off-by: Chengming Zhou <[email protected]>

Reviewed-by: Vincent Guittot <[email protected]>

> ---
> kernel/sched/fair.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d4bd299d67ab..e6fa5d1141b4 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -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
>