Skip to contentSkip to conversation

sched/fair: simplfy the work when reweighting entity

PATCH Applied Jiang Biao 5 participants 5 messages Aug 11, 2020 – Aug 27, 2020 Scheduler

lore
Share & tools
lore

Jiang Biao

author
#0 lore raw

PATCH v3 1/1 sched/fair: simplfy the work when reweighting entity

From: Jiang Biao <[email protected]>

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.

---
v3<-v2: Amend commit log taking Dietmar's advice. Thx. v2<-v1: Amend the commit log

 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
index 04fa8dbcfa4d..18a8fc7bd0de 100644
@@ -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
reviewer Reviewed-by on v3 1/1
#1 lore raw
Quoted 36 lines · Jiang Biao

From: Jiang Biao <[email protected]>

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.

---
v3<-v2: Amend commit log taking Dietmar's advice. Thx. v2<-v1: Amend the commit log

 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +1 -1
index 04fa8dbcfa4d..18a8fc7bd0de 100644
@@ -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);
 

kernel/sched/fair.c static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, · line 3107

Quoted 7 lines
kernel/sched/fair.c +1 -1
@@ -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);
 
 }
maintainer Reviewed-by on v3 1/1
#2 lore raw
In reply to Jiang Biao
Quoted 9 lines · Jiang Biao

From: Jiang Biao <[email protected]>

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.

Quoted 7 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 the rq->cfs_tasks list management of the entity accounting are never called, the redundant cfs_rq->nr_running decrement/increment will be avoided.

Minor typo of the subject: s/simplfy/simplify/

Quoted 32 lines

---
v3<-v2: Amend commit log taking Dietmar's advice. Thx. v2<-v1: Amend the commit log

 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -3
index 04fa8dbcfa4d..18a8fc7bd0de 100644
@@ -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

#3 lore raw
Quoted 16 lines · Vincent Guittot
Quoted 15 lines · Jiang Biao

From: Jiang Biao <[email protected]>

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 3 lines
Quoted 1 line

Minor typo of the subject: s/simplfy/simplify/

I've made it "Simplify" :-)

Thanks guys!

merge bot Applied
#4 lore raw

[tip: sched/core] sched/fair: Simplify the work when reweighting entity

In reply to Jiang Biao
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     1724b95b92979a8ea8e55a4817d05b3bb7750958
Gitweb:        https://git.kernel.org/tip/1724b95b92979a8ea8e55a4817d05b3bb7750958
Author:        Jiang Biao <[email protected]>
AuthorDate:    Tue, 11 Aug 2020 19:32:09 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Wed, 26 Aug 2020 12:41:58 +02:00

sched/fair: Simplify the work when reweighting entity

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.

---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
index 90ebaa4..33699db 100644
@@ -3084,7 +3084,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);
 
@@ -3100,7 +3100,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);
 
 }