[Devel] [PATCH RH8] sched: Port diff-sched-clear-prev-entity-if-curr-is-dequeued
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri May 7 17:56:15 MSK 2021
From: Vladimir Davydov <vdavydov at parallels.com>
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 409c82642d4f6bb1d897dcfdb937a0c504541780)
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 b7032226483cf..8f22066ddd820 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;
}
--
2.30.2
More information about the Devel
mailing list