* [PATCH RFC] sched/fair: simplfy the work when reweighting entity @ 2020-08-04 7:12 Jiang Biao 2020-08-05 16:21 ` Dietmar Eggemann 0 siblings, 1 reply; 4+ messages in thread From: Jiang Biao @ 2020-08-04 7:12 UTC (permalink / raw) To: mingo, peterz, juri.lelli, vincent.guittot Cc: dietmar.eggemann, rostedt, bsegall, mgorman, linux-kernel, Jiang Biao If a se is on_rq when reweighting entity, all we need should be updating the load of cfs_rq, other dequeue/enqueue works could be redundant, such as, * account_numa_dequeue/account_numa_enqueue * list_del/list_add from/into cfs_tasks * nr_running--/nr_running++ Just simplfy the work. Could be helpful for the hot path. Signed-off-by: Jiang Biao <benbjiang@tencent.com> --- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 04fa8dbcfa4d..18a8fc7bd0de 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -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); } -- 2.21.0 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] sched/fair: simplfy the work when reweighting entity 2020-08-04 7:12 [PATCH RFC] sched/fair: simplfy the work when reweighting entity Jiang Biao @ 2020-08-05 16:21 ` Dietmar Eggemann 2020-08-06 2:42 ` benbjiang(蒋彪) 0 siblings, 1 reply; 4+ messages in thread From: Dietmar Eggemann @ 2020-08-05 16:21 UTC (permalink / raw) To: Jiang Biao, mingo, peterz, juri.lelli, vincent.guittot Cc: rostedt, bsegall, mgorman, linux-kernel, Jiang Biao On 04/08/2020 09:12, Jiang Biao wrote: > If a se is on_rq when reweighting entity, all we need should be > updating the load of cfs_rq, other dequeue/enqueue works could be > redundant, such as, > * account_numa_dequeue/account_numa_enqueue > * list_del/list_add from/into cfs_tasks > * nr_running--/nr_running++ I think this could make sense. Have you spotted a code path where this gives you a change? I guess only for a task on the rq, so: entity_is_task(se) && se->on_rq > Just simplfy the work. Could be helpful for the hot path. IMHO hotpath is update_cfs_group() -> reweight_entity() but this is only called for '!entity_is_task(se)'. See 3290 if (!gcfs_rq) 3291 return; in update_cfs_group(). The 'entity_is_task(se)' case is set_load_weight(struct task_struct *p, ...) -> reweight_task(p, ...) -> reweight_entity(..., &p->se, ...) but here !se->on_rq. > Signed-off-by: Jiang Biao <benbjiang@tencent.com> > --- > kernel/sched/fair.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 04fa8dbcfa4d..18a8fc7bd0de 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -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); > > } ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] sched/fair: simplfy the work when reweighting entity 2020-08-05 16:21 ` Dietmar Eggemann @ 2020-08-06 2:42 ` benbjiang(蒋彪) 2020-08-06 14:48 ` Dietmar Eggemann 0 siblings, 1 reply; 4+ messages in thread From: benbjiang(蒋彪) @ 2020-08-06 2:42 UTC (permalink / raw) To: Dietmar Eggemann Cc: Jiang Biao, mingo, Peter Zijlstra, juri.lelli, vincent.guittot, rostedt, bsegall, mgorman, linux-kernel > On Aug 6, 2020, at 12:21 AM, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote: > > On 04/08/2020 09:12, Jiang Biao wrote: >> If a se is on_rq when reweighting entity, all we need should be >> updating the load of cfs_rq, other dequeue/enqueue works could be >> redundant, such as, >> * account_numa_dequeue/account_numa_enqueue >> * list_del/list_add from/into cfs_tasks >> * nr_running--/nr_running++ > > I think this could make sense. Have you spotted a code path where this > gives you a change? > > I guess only for a task on the rq, so: entity_is_task(se) && se->on_rq Yes, you're right. No other code path I spotted except what you list below. > >> Just simplfy the work. Could be helpful for the hot path. > > IMHO hotpath is update_cfs_group() -> reweight_entity() but this is only > called for '!entity_is_task(se)'. > > See > > 3290 if (!gcfs_rq) > 3291 return; > > in update_cfs_group(). Yes, It is. But *nr_running--/nr_running++* works are still redundant for ‘!entity_is_task(se)' hot path. :) Besides, I guess we could simplify the logic and make it cleaner and more readable with this patch. If it could make sense to you, would you mind if I resend the patch with the commit log amended? > > The 'entity_is_task(se)' case is > > set_load_weight(struct task_struct *p, ...) -> reweight_task(p, ...) -> > reweight_entity(..., &p->se, ...) > > but here !se->on_rq. Yes, indeed. Thanks a lot for your comments. Regards, Jiang > >> Signed-off-by: Jiang Biao <benbjiang@tencent.com> >> --- >> kernel/sched/fair.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 04fa8dbcfa4d..18a8fc7bd0de 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -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); >> >> } > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] sched/fair: simplfy the work when reweighting entity 2020-08-06 2:42 ` benbjiang(蒋彪) @ 2020-08-06 14:48 ` Dietmar Eggemann 0 siblings, 0 replies; 4+ messages in thread From: Dietmar Eggemann @ 2020-08-06 14:48 UTC (permalink / raw) To: benbjiang(蒋彪) Cc: Jiang Biao, mingo, Peter Zijlstra, juri.lelli, vincent.guittot, rostedt, bsegall, mgorman, linux-kernel On 06/08/2020 04:42, benbjiang(蒋彪) wrote: > > >> On Aug 6, 2020, at 12:21 AM, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote: >> >> On 04/08/2020 09:12, Jiang Biao wrote: >>> If a se is on_rq when reweighting entity, all we need should be >>> updating the load of cfs_rq, other dequeue/enqueue works could be >>> redundant, such as, >>> * account_numa_dequeue/account_numa_enqueue >>> * list_del/list_add from/into cfs_tasks >>> * nr_running--/nr_running++ >> >> I think this could make sense. Have you spotted a code path where this >> gives you a change? >> >> I guess only for a task on the rq, so: entity_is_task(se) && se->on_rq > Yes, you're right. No other code path I spotted except what you list below. > >> >>> Just simplfy the work. Could be helpful for the hot path. >> >> IMHO hotpath is update_cfs_group() -> reweight_entity() but this is only >> called for '!entity_is_task(se)'. >> >> See >> >> 3290 if (!gcfs_rq) >> 3291 return; >> >> in update_cfs_group(). > Yes, It is. > But *nr_running--/nr_running++* works are still redundant for > ‘!entity_is_task(se)' hot path. :) True. > Besides, I guess we could simplify the logic and make it cleaner and > more readable with this patch. Yes. > If it could make sense to you, would you mind if I resend the patch > with the commit log amended? LGTM so why not? >> The 'entity_is_task(se)' case is >> >> set_load_weight(struct task_struct *p, ...) -> reweight_task(p, ...) -> >> reweight_entity(..., &p->se, ...) >> >> but here !se->on_rq. > Yes, indeed. [...] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-06 17:27 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-04 7:12 [PATCH RFC] sched/fair: simplfy the work when reweighting entity Jiang Biao 2020-08-05 16:21 ` Dietmar Eggemann 2020-08-06 2:42 ` benbjiang(蒋彪) 2020-08-06 14:48 ` Dietmar Eggemann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®