Skip to contentSkip to conversation

sched/fair: optimize the PLACE_LAG when se->vlag is zero

PATCH Applied Huang Shijie 2 participants 2 messages Oct 1, 2024 – Oct 8, 2024 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/fair: optimize the PLACE_LAG when se->vlag is zero

When PLACE_LAG is enabled, from the relationship:

            vl_i = (W + w_i)*vl'_i / W

we know that if vl'_i(se->vlag) is zero, the vl_i is zero too.

So if se->vlag is zero, there is no need to waste cycles to do the calculation.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index a7d8bb95e17c..1812c9cc079d 100644
@@ -5280,7 +5280,7 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 	 *
 	 * EEVDF: placement strategy #1 / #2
 	 */
-	if (sched_feat(PLACE_LAG) && cfs_rq->nr_running) {
+	if (sched_feat(PLACE_LAG) && cfs_rq->nr_running && se->vlag) {
 		struct sched_entity *curr = cfs_rq->curr;
 		unsigned long load;
 
Signature · 1 line
2.40.1
merge bot Applied
#1 lore raw
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:     4423af84b29794a9bd2bd07188d8e71083e54c61
Gitweb:        https://git.kernel.org/tip/4423af84b29794a9bd2bd07188d8e71083e54c61
Author:        Huang Shijie <[email protected]>
AuthorDate:    Tue, 01 Oct 2024 15:00:21 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Mon, 07 Oct 2024 09:28:41 +02:00

sched/fair: optimize the PLACE_LAG when se->vlag is zero

When PLACE_LAG is enabled, from the relationship:

            vl_i = (W + w_i)*vl'_i / W

we know that if vl'_i(se->vlag) is zero, the vl_i is zero too.

So if se->vlag is zero, there is no need to waste cycles to do the calculation.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index c9e3b8d..5a62121 100644
@@ -5280,7 +5280,7 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 	 *
 	 * EEVDF: placement strategy #1 / #2
 	 */
-	if (sched_feat(PLACE_LAG) && cfs_rq->nr_running) {
+	if (sched_feat(PLACE_LAG) && cfs_rq->nr_running && se->vlag) {
 		struct sched_entity *curr = cfs_rq->curr;
 		unsigned long load;