[Devel] [PATCH RHEL8 COMMIT] sched: Port diff-sched-clear-prev-entity-if-curr-is-dequeued

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 11 18:37:06 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.27
------>
commit 4cc2708f2a713a5ad5a727529fde5b8c22e6f65d
Author: Vladimir Davydov <vdavydov.dev at gmail.com>
Date:   Tue May 11 18:37:06 2021 +0300

    sched: Port diff-sched-clear-prev-entity-if-curr-is-dequeued
    
    Author: Vladimir Davydov
    Email: vdavydov at parallels.com
    Subject: sched: clear prev entity if curr is dequeued
    Date: Fri, 20 Sep 2013 16:55:23 +0400
    
    cfs_rq->prev is used for ctxsw accounting: on put_prev_entity()
    cfs_rq->prev is set to curr if curr is on rq, and on set_next_entity()
    nr_switches is increased if curr != prev. However, If the current task
    goes to sleep, cfs_rq->prev won't be updated, which will lead to a ctxsw
    not accounted. The patch fixes this by clearing cfs_rq->prev if current
    is not on rq.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    
    =============================================================================
    
    Related to https://jira.sw.ru/browse/PSBM-33642
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    
    https://jira.sw.ru/browse/PSBM-127780
    (cherry-picked from vz7 commit 409c82642d4f ("sched: Port
    diff-sched-clear-prev-entity-if-curr-is-dequeued"))
    Fixes: dc03756f0c397 ("sched/stat: account ctxsw per task group")
    
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 kernel/sched/fair.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b7032226483c..8f22066ddd82 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4381,7 +4381,8 @@ static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
 		/* in !on_rq case, update occurred at dequeue */
 		update_load_avg(cfs_rq, prev, 0);
 		cfs_rq->prev = prev;
-	}
+	} else
+		cfs_rq->prev = NULL;
 	cfs_rq->curr = NULL;
 }
 


More information about the Devel mailing list