linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2] sched/fair: simplify the work when reweighting entity
@ 2020-08-06 16:14 Jiang Biao
  2020-08-11  9:50 ` Dietmar Eggemann
  0 siblings, 1 reply; 3+ messages in thread
From: Jiang Biao @ 2020-08-06 16:14 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, linux-kernel, Jiang Biao

From: Jiang Biao <benbjiang@tencent.com>

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.

Signed-off-by: Jiang Biao <benbjiang@tencent.com>
---
v2<-v1: 
- Amend the commit log.

 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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC v2] sched/fair: simplify the work when reweighting entity
  2020-08-06 16:14 [PATCH RFC v2] sched/fair: simplify the work when reweighting entity Jiang Biao
@ 2020-08-11  9:50 ` Dietmar Eggemann
  2020-08-11 11:19   ` [PATCH RFC v2] sched/fair: simplify the work when reweighting entity(Internet mail) benbjiang(蒋彪)
  0 siblings, 1 reply; 3+ messages in thread
From: Dietmar Eggemann @ 2020-08-11  9:50 UTC (permalink / raw)
  To: Jiang Biao, mingo, peterz, juri.lelli, vincent.guittot
  Cc: rostedt, bsegall, mgorman, linux-kernel, Jiang Biao

On 06/08/2020 18:14, Jiang Biao wrote:
> From: Jiang Biao <benbjiang@tencent.com>
> 
> 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.

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.

> 
> Signed-off-by: Jiang Biao <benbjiang@tencent.com>
> ---
> v2<-v1: 
> - Amend the commit log.
> 
>  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] 3+ messages in thread

* Re: [PATCH RFC v2] sched/fair: simplify the work when reweighting entity(Internet mail)
  2020-08-11  9:50 ` Dietmar Eggemann
@ 2020-08-11 11:19   ` benbjiang(蒋彪)
  0 siblings, 0 replies; 3+ messages in thread
From: benbjiang(蒋彪) @ 2020-08-11 11:19 UTC (permalink / raw)
  To: Dietmar Eggemann
  Cc: Jiang Biao, mingo, Peter Zijlstra, juri.lelli, vincent.guittot,
	rostedt, bsegall, mgorman, linux-kernel

Hi,

> On Aug 11, 2020, at 5:50 PM, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
> 
> On 06/08/2020 18:14, Jiang Biao wrote:
>> From: Jiang Biao <benbjiang@tencent.com>
>> 
>> 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.
> 
> LGTM. I guess you have to resend it w/o the RFC tag.
Will do soon.
> 
> 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.
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
> 
>> 
>> Signed-off-by: Jiang Biao <benbjiang@tencent.com>
>> ---
>> v2<-v1: 
>> - Amend the commit log.
>> 
>> 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] 3+ messages in thread

end of thread, other threads:[~2020-08-11 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 16:14 [PATCH RFC v2] sched/fair: simplify the work when reweighting entity Jiang Biao
2020-08-11  9:50 ` Dietmar Eggemann
2020-08-11 11:19   ` [PATCH RFC v2] sched/fair: simplify the work when reweighting entity(Internet mail) benbjiang(蒋彪)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).