sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
PATCH 1/1 sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
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.
--- kernel/sched/fair.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/sched/fair.c +1 -4
@@ -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;
Signature · 1 line
2.17.1
Vincent Guittot
maintainerQuoted 8 lines · Zhaoyu Liu
In commit
40f5aa4c5eae("sched/pelt: Fixattach_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;
Quoted 4 lines
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
Quoted 25 lines
Signed-off-by Zhaoyu Liu <[email protected]>--- kernel/sched/fair.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)kernel/sched/fair.c +1
-5@@ -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
Quoted 10 lines · Vincent Guittot
Quoted 9 lines · Zhaoyu Liu
In commit
40f5aa4c5eae("sched/pelt: Fixattach_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;
Quoted 7 lines
Quoted 5 lines
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
Quoted 21 lines · Zackary Liu
Quoted 10 lines · Vincent Guittot
Quoted 9 lines · Zhaoyu Liu
In commit
40f5aa4c5eae("sched/pelt: Fixattach_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;Quoted 7 lines
Quoted 5 lines
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
Quoted 7 lines
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
Vincent Guittot
maintainerQuoted 22 lines · Zackary Liu
Quoted 17 lines · Zackary Liu
Quoted 14 lines · Vincent Guittot
Quoted 13 lines · Zhaoyu Liu
In commit
40f5aa4c5eae("sched/pelt: Fixattach_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;
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
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
Quoted 10 lines
Quoted 3 lines
--
zackaryI 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