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

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 4 04:53:32 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.9
------>
commit 2f88f9da5c4dad028bd97bc5085b413d772449fa
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Thu Jun 4 15:53:32 2015 +0400

    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>
---
 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 ec866ed..7f1ff1d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3295,7 +3295,8 @@ static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
 		/* in !on_rq case, update occurred at dequeue */
 		update_entity_load_avg(prev, 1);
 		cfs_rq->prev = prev;
-	}
+	} else
+		cfs_rq->prev = NULL;
 	cfs_rq->curr = NULL;
 }
 



More information about the Devel mailing list