[tip: sched/core] sched/fair: optimize the PLACE_LAG when se->vlag is zero

tip-bot2 for Huang Shijie posted 1 patch 1 month, 2 weeks ago
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[tip: sched/core] sched/fair: optimize the PLACE_LAG when se->vlag is zero
Posted by tip-bot2 for Huang Shijie 1 month, 2 weeks ago
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 <shijie@os.amperecomputing.com>
AuthorDate:    Tue, 01 Oct 2024 15:00:21 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
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.

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Christoph Lameter (Ampere) <cl@linux.com>
Link: https://lkml.kernel.org/r/20241001070021.10626-1-shijie@os.amperecomputing.com
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c9e3b8d..5a62121 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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;