All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
@ 2022-06-21 15:45 Zhaoyu Liu
  2022-06-22 15:20 ` Vincent Guittot
  0 siblings, 1 reply; 5+ messages in thread
From: Zhaoyu Liu @ 2022-06-21 15:45 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, vschneid, kuyo.chang
  Cc: linux-kernel

In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg() corner case"),
these code was committed:
	if (se_weight(se) < se->avg.load_sum)
		se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
	else
		se->avg.load_sum = 1;

they could be replace with:
	se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;

to make the code cleaner.

Signed-off-by: Zhaoyu Liu <zackary.liu.pro@gmail.com>
---
 kernel/sched/fair.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 78795a997d9c..ed32f66bbd3d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3881,10 +3881,7 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
 	se->avg.runnable_sum = se->avg.runnable_avg * divider;
 
 	se->avg.load_sum = se->avg.load_avg * divider;
-	if (se_weight(se) < se->avg.load_sum)
-		se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
-	else
-		se->avg.load_sum = 1;
+	se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
 
 	enqueue_load_avg(cfs_rq, se);
 	cfs_rq->avg.util_avg += se->avg.util_avg;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
  2022-06-21 15:45 [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg() Zhaoyu Liu
@ 2022-06-22 15:20 ` Vincent Guittot
  2022-06-22 15:49   ` Zackary Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Vincent Guittot @ 2022-06-22 15:20 UTC (permalink / raw)
  To: Zhaoyu Liu
  Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, bristot, vschneid, kuyo.chang, linux-kernel

On Tue, 21 Jun 2022 at 17:45, Zhaoyu Liu <zackary.liu.pro@gmail.com> wrote:
>
> In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg() corner case"),
> these code was committed:
>         if (se_weight(se) < se->avg.load_sum)
>                 se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
>         else
>                 se->avg.load_sum = 1;
>
> they could be replace with:
>         se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
>
> to make the code cleaner.

This quite subjective as I consider current version cleaner than your proposal

>
> Signed-off-by: Zhaoyu Liu <zackary.liu.pro@gmail.com>
> ---
>  kernel/sched/fair.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 78795a997d9c..ed32f66bbd3d 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3881,10 +3881,7 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
>         se->avg.runnable_sum = se->avg.runnable_avg * divider;
>
>         se->avg.load_sum = se->avg.load_avg * divider;
> -       if (se_weight(se) < se->avg.load_sum)
> -               se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
> -       else
> -               se->avg.load_sum = 1;
> +       se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
>
>         enqueue_load_avg(cfs_rq, se);
>         cfs_rq->avg.util_avg += se->avg.util_avg;
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
  2022-06-22 15:20 ` Vincent Guittot
@ 2022-06-22 15:49   ` Zackary Liu
  2022-07-15 14:33     ` Zackary Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Zackary Liu @ 2022-06-22 15:49 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com,
	mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com,
	kuyo.chang@mediatek.com, linux-kernel@vger.kernel.org

On Jun 22 2022, at 11:20 pm, Vincent Guittot
<vincent.guittot@linaro.org> wrote:

> On Tue, 21 Jun 2022 at 17:45, Zhaoyu Liu <zackary.liu.pro@gmail.com> wrote:
>> 
>> In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg()
>> corner case"),
>> these code was committed:
>>         if (se_weight(se) < se->avg.load_sum)
>>                 se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
>>         else
>>                 se->avg.load_sum = 1;
>> 
>> they could be replace with:
>>         se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se))
>> ?: 1;
>> 
>> to make the code cleaner.
> 
> This quite subjective as I consider current version cleaner than your proposal

Thanks for your reply, vincent

Perhaps, this code is more concise, and this form can exist in many
places in the kernel, and can be searched with 'grep "?: 1;" -nR kernel'

--
zackary

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
  2022-06-22 15:49   ` Zackary Liu
@ 2022-07-15 14:33     ` Zackary Liu
  2022-07-18 10:27       ` Vincent Guittot
  0 siblings, 1 reply; 5+ messages in thread
From: Zackary Liu @ 2022-07-15 14:33 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com,
	mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com,
	kuyo.chang@mediatek.com, linux-kernel@vger.kernel.org



On Jun 22 2022, at 11:49 pm, Zackary Liu <zackary.liu.pro@gmail.com> wrote:

> On Jun 22 2022, at 11:20 pm, Vincent Guittot
> <vincent.guittot@linaro.org> wrote:
> 
>> On Tue, 21 Jun 2022 at 17:45, Zhaoyu Liu <zackary.liu.pro@gmail.com> wrote:
>>> 
>>> In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg()
>>> corner case"),
>>> these code was committed:
>>>         if (se_weight(se) < se->avg.load_sum)
>>>                 se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
>>>         else
>>>                 se->avg.load_sum = 1;
>>> 
>>> they could be replace with:
>>>         se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se))
>>> ?: 1;
>>> 
>>> to make the code cleaner.
>> 
>> This quite subjective as I consider current version cleaner than your proposal
> 
> Thanks for your reply, vincent
> 
> Perhaps, this code is more concise, and this form can exist in many
> places in the kernel, and can be searched with 'grep "?: 1;" -nR kernel'
> 
> --
> zackary

I have sent a patch couple days ago but still i don't get the reply,
I am looking forward to your reply,
thank you

--
zackary

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
  2022-07-15 14:33     ` Zackary Liu
@ 2022-07-18 10:27       ` Vincent Guittot
  0 siblings, 0 replies; 5+ messages in thread
From: Vincent Guittot @ 2022-07-18 10:27 UTC (permalink / raw)
  To: Zackary Liu
  Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com,
	mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com,
	kuyo.chang@mediatek.com, linux-kernel@vger.kernel.org

On Fri, 15 Jul 2022 at 16:33, Zackary Liu <zackary.liu.pro@gmail.com> wrote:
>
>
>
> On Jun 22 2022, at 11:49 pm, Zackary Liu <zackary.liu.pro@gmail.com> wrote:
>
> > On Jun 22 2022, at 11:20 pm, Vincent Guittot
> > <vincent.guittot@linaro.org> wrote:
> >
> >> On Tue, 21 Jun 2022 at 17:45, Zhaoyu Liu <zackary.liu.pro@gmail.com> wrote:
> >>>
> >>> In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg()
> >>> corner case"),
> >>> these code was committed:
> >>>         if (se_weight(se) < se->avg.load_sum)
> >>>                 se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
> >>>         else
> >>>                 se->avg.load_sum = 1;
> >>>
> >>> they could be replace with:
> >>>         se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se))
> >>> ?: 1;
> >>>
> >>> to make the code cleaner.
> >>
> >> This quite subjective as I consider current version cleaner than your proposal
> >
> > Thanks for your reply, vincent
> >
> > Perhaps, this code is more concise, and this form can exist in many
> > places in the kernel, and can be searched with 'grep "?: 1;" -nR kernel'

As said, the current code is cleaner and easier to read and I don't
see any benefit from this patch.
So it's a NAK


> >
> > --
> > zackary
>
> I have sent a patch couple days ago but still i don't get the reply,
> I am looking forward to your reply,
> thank you
>
> --
> zackary

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-18 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-21 15:45 [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg() Zhaoyu Liu
2022-06-22 15:20 ` Vincent Guittot
2022-06-22 15:49   ` Zackary Liu
2022-07-15 14:33     ` Zackary Liu
2022-07-18 10:27       ` Vincent Guittot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.