sched/fair: simplify the work when reweighting entity
RFC PATCH v2 1/1 sched/fair: simplify the work when reweighting entity
From: Jiang Biao <[email protected]>
If a se is on_rq when reweighting entity, all we need should be updating the load of cfs_rq, other dequeue/enqueue work could be redundant, such as,
* nr_running--/nr_running++
Even though the following dequeue/enqueue path would never be reached
* account_numa_dequeue/account_numa_enqueue
* list_del/list_add from/into cfs_tasks
but it could be a little confusing.
Simplifying the logic could be helpful to reduce a litte overhead for hot path, and make it cleaner and more readable.
---
v2<-v1:
- Amend the commit log.
kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
@@ -3086,7 +3086,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,/* commit outstanding execution time */ if (cfs_rq->curr == se)update_curr (cfs_rq); -account_entity_dequeue (cfs_rq, se); +update_load_sub (&cfs_rq->load, se->load.weight); }dequeue_load_avg (cfs_rq, se);
@@ -3102,7 +3102,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,enqueue_load_avg (cfs_rq, se);if (se->on_rq) -account_entity_enqueue (cfs_rq, se); +update_load_add (&cfs_rq->load, se->load.weight); }
Signature · 1 line
2.21.0
Dietmar Eggemann
reviewerQuoted 7 lines · Jiang Biao
From: Jiang Biao <[email protected]>
If a se is
on_rqwhen reweighting entity, all we need should be updating the load ofcfs_rq, other dequeue/enqueue work could be redundant, such as,
* nr_running--/nr_running++
Quoted 7 lines
Even though the following dequeue/enqueue path would never be reached
* account_numa_dequeue/account_numa_enqueue
* list_del/list_add from/intocfs_tasks
but it could be a little confusing.Simplifying the logic could be helpful to reduce a litte overhead for hot path, and make it cleaner and more readable.
LGTM. I guess you have to resend it w/o the RFC tag.
Maybe you can rework the patch header a little?
Something like this:
The code in reweight_entity() can be simplified.
For a sched entity on the rq, the entity accounting can be replaced by cfs_rq instantaneous load updates currently called from within the entity accounting.
Even though an entity on the rq can't represent a task in reweight_entity() (a task is always dequeued before calling this function) and so the numa task accounting and the rq->cfs_tasks list management of the entity accounting are never called, the redundant cfs_rq->nr_running decrement/increment will be avoided.
Quoted 30 lines
Signed-off-by Jiang Biao <[email protected]>---
v2<-v1:
- Amend the commit log.kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/sched/fair.c +2
-2@@ -3086,7 +3086,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,/* commit outstanding execution time */ if (cfs_rq->curr == se)update_curr (cfs_rq); -account_entity_dequeue (cfs_rq, se); +update_load_sub (&cfs_rq->load, se->load.weight); }dequeue_load_avg (cfs_rq, se);@@ -3102,7 +3102,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,enqueue_load_avg (cfs_rq, se);if (se->on_rq) -account_entity_enqueue (cfs_rq, se); +update_load_add (&cfs_rq->load, se->load.weight); }
Re: [PATCH RFC v2] sched/fair: simplify the work when reweighting entity(Internet mail)
Hi,
Quoted 15 lines · Dietmar Eggemann
Quoted 12 lines · Jiang Biao
From: Jiang Biao <[email protected]>
If a se is
on_rqwhen reweighting entity, all we need should be updating the load ofcfs_rq, other dequeue/enqueue work could be redundant, such as,
* nr_running--/nr_running++Even though the following dequeue/enqueue path would never be reached
* account_numa_dequeue/account_numa_enqueue
* list_del/list_add from/intocfs_tasks
but it could be a little confusing.
Quoted 4 lines
Quoted 2 lines
Simplifying the logic could be helpful to reduce a litte overhead for hot path, and make it cleaner and more readable.
LGTM. I guess you have to resend it w/o the RFC tag.
Will do soon.
Quoted 11 lines
Maybe you can rework the patch header a little?
Something like this:
The code in
reweight_entity()can be simplified.For a sched entity on the rq, the entity accounting can be replaced by
cfs_rqinstantaneous load updates currently called from within the entity accounting.
Quoted 5 lines
Even though an entity on the rq can't represent a task in
reweight_entity()(a task is always dequeued before calling this function) and so the numa task accounting and therq->cfs_taskslist management of the entity accounting are never called, the redundantcfs_rq->nr_runningdecrement/increment will be avoided.
That’s a much better. I’ll pick the header if you don’t mind. :)
Thanks a lot for your kindly reply and detailed explanation.
Regards,
Jiang
Quoted 31 lines
Quoted 31 lines
Signed-off-by Jiang Biao <[email protected]>---
v2<-v1:
- Amend the commit log.
kernel/sched/fair.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)kernel/sched/fair.c +2
-2@@ -3086,7 +3086,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,/* commit outstanding execution time */ if (cfs_rq->curr == se)update_curr (cfs_rq); -account_entity_dequeue (cfs_rq, se); +update_load_sub (&cfs_rq->load, se->load.weight); }dequeue_load_avg (cfs_rq, se);@@ -3102,7 +3102,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,enqueue_load_avg (cfs_rq, se);if (se->on_rq) -account_entity_enqueue (cfs_rq, se); +update_load_add (&cfs_rq->load, se->load.weight); }