[PATCH] sched/fair: Fix cfs_rq_is_decayed() on !SMP

chengming.zhou@linux.dev posted 1 patch 2 years, 4 months ago
There is a newer version of this series
kernel/sched/fair.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] sched/fair: Fix cfs_rq_is_decayed() on !SMP
Posted by chengming.zhou@linux.dev 2 years, 4 months ago
From: Chengming Zhou <zhouchengming@bytedance.com>

We don't need to maintain per-queue leaf_cfs_rq_list on !SMP, since
it's used for cfs_rq load tracking & balance on SMP.

But sched debug interface use it to print per-cfs_rq stats, which
maybe better to change to use walk_tg_tree_from() instead.

This patch just fix the !SMP version cfs_rq_is_decayed(), so the
per-queue leaf_cfs_rq_list is also maintained correctly on !SMP,
to fix the warning in assert_list_leaf_cfs_rq().

Fixes: 0a00a354644e ("sched/fair: Delete useless condition in tg_unthrottle_up()")
Reported-by: Leo Liang <ycliang@andestech.com>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a80a73909dc2..00ef7e86a95b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4654,6 +4654,8 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq)
 
 static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
 {
+	if (cfs_rq->load.weight)
+		return false;
 	return true;
 }
 
-- 
2.41.0
Re: [PATCH] sched/fair: Fix cfs_rq_is_decayed() on !SMP
Posted by Vincent Guittot 2 years, 4 months ago
On Fri, 18 Aug 2023 at 13:37, <chengming.zhou@linux.dev> wrote:
>
> From: Chengming Zhou <zhouchengming@bytedance.com>
>
> We don't need to maintain per-queue leaf_cfs_rq_list on !SMP, since
> it's used for cfs_rq load tracking & balance on SMP.
>
> But sched debug interface use it to print per-cfs_rq stats, which
> maybe better to change to use walk_tg_tree_from() instead.
>
> This patch just fix the !SMP version cfs_rq_is_decayed(), so the
> per-queue leaf_cfs_rq_list is also maintained correctly on !SMP,
> to fix the warning in assert_list_leaf_cfs_rq().
>
> Fixes: 0a00a354644e ("sched/fair: Delete useless condition in tg_unthrottle_up()")
> Reported-by: Leo Liang <ycliang@andestech.com>
> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
> ---
>  kernel/sched/fair.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a80a73909dc2..00ef7e86a95b 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4654,6 +4654,8 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq)
>
>  static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
>  {
> +       if (cfs_rq->load.weight)
> +               return false;
>         return true;

Why not :

return !(cfs_rq->nr_running);

The above seems easier to understand although I agree that both do the
same thing at the end

>  }
>
> --
> 2.41.0
>
Re: [PATCH] sched/fair: Fix cfs_rq_is_decayed() on !SMP
Posted by Chengming Zhou 2 years, 4 months ago
On 2023/8/18 20:25, Vincent Guittot wrote:
> On Fri, 18 Aug 2023 at 13:37, <chengming.zhou@linux.dev> wrote:
>>
>> From: Chengming Zhou <zhouchengming@bytedance.com>
>>
>> We don't need to maintain per-queue leaf_cfs_rq_list on !SMP, since
>> it's used for cfs_rq load tracking & balance on SMP.
>>
>> But sched debug interface use it to print per-cfs_rq stats, which
>> maybe better to change to use walk_tg_tree_from() instead.
>>
>> This patch just fix the !SMP version cfs_rq_is_decayed(), so the
>> per-queue leaf_cfs_rq_list is also maintained correctly on !SMP,
>> to fix the warning in assert_list_leaf_cfs_rq().
>>
>> Fixes: 0a00a354644e ("sched/fair: Delete useless condition in tg_unthrottle_up()")
>> Reported-by: Leo Liang <ycliang@andestech.com>
>> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
>> ---
>>  kernel/sched/fair.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index a80a73909dc2..00ef7e86a95b 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -4654,6 +4654,8 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq)
>>
>>  static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
>>  {
>> +       if (cfs_rq->load.weight)
>> +               return false;
>>         return true;
> 
> Why not :
> 
> return !(cfs_rq->nr_running);
> 
> The above seems easier to understand although I agree that both do the
> same thing at the end
> 

Yes, this is better.

Thanks.