From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753975AbbHJJD1 (ORCPT ); Mon, 10 Aug 2015 05:03:27 -0400 Received: from lgeamrelo02.lge.com ([156.147.1.126]:48857 "EHLO lgeamrelo02.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752830AbbHJJD0 (ORCPT ); Mon, 10 Aug 2015 05:03:26 -0400 X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: byungchul.park@lge.com To: mingo@kernel.org, peterz@infradead.org Cc: linux-kernel@vger.kernel.org, Byungchul Park Subject: [PATCH] sched: ensure a task has a non-normalized vruntime when returning back to cfs Date: Mon, 10 Aug 2015 18:02:55 +0900 Message-Id: <1439197375-27927-1-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Byungchul Park current code ensures a task has a normalized vruntime when switching off from fair class, but it does not ensure the task has a non-normalized vruntime when switching back to the fair class. this is an example breaking this consistency. 1. a task is in fair class and !queue 2. change its class to rt class (still !queue) 3. change its class to fair class again (stll !queue) Signed-off-by: Byungchul Park --- kernel/sched/fair.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ffa70dc..df265f5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8150,8 +8150,22 @@ static void switched_to_fair(struct rq *rq, struct task_struct *p) */ se->depth = se->parent ? se->parent->depth + 1 : 0; #endif - if (!task_on_rq_queued(p)) + + if (!task_on_rq_queued(p)) { + + /* + * Ensure the task has a non-normalized vruntime when it is switched + * back to the fair class with !queued, so that enqueue_entity() at + * wake-up time will do the right thing. + * + * If it's queued, then the enqueue_entity(.flags=0) makes the task + * has non-normalized vruntime, if it's !queued, then it still has + * normalized vruntime. + */ + if (p->state != TASK_RUNNING) + se->vruntime += cfs_rq_of(se)->min_vruntime; return; + } /* * We were most likely switched from sched_rt, so -- 1.7.9.5