[Devel] [PATCH rh7] Port diff-sched-clear-prev-entity-if-curr-is-dequeued

Vladimir Davydov vdavydov at parallels.com
Fri May 29 06:18:44 PDT 2015


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 ec866ed667c2..7f1ff1da8a29 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;
 }
 
-- 
2.1.4




More information about the Devel mailing list