From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759483AbcIPVRV (ORCPT ); Fri, 16 Sep 2016 17:17:21 -0400 Received: from albert.ini-tech.com ([192.99.4.57]:35610 "EHLO smtp.ini-tech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755980AbcIPVQh (ORCPT ); Fri, 16 Sep 2016 17:16:37 -0400 From: Julien Desfossez To: peterz@infradead.org, tglx@linutronix.de, rostedt@goodmis.org, mingo@redhat.com, daolivei@redhat.com Cc: mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, Julien Desfossez Subject: [RFC PATCH 1/6] sched/fair: check_preempt_wakeup: Fix assumption on the default policy Date: Fri, 16 Sep 2016 17:09:03 -0400 Message-Id: <1474060148-13171-1-git-send-email-jdesfossez@efficios.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tasks with RT or deadline scheduling class may inherit from a task with a "fair" scheduling class. This priority inheritance changes the scheduling class, but not the task "policy" field. Therefore, the fair scheduler should not assume that policy != SCHED_NORMAL is the same as (policy == SCHED_BATCH || policy == SCHED_IDLE), because the policy could also be SCHED_RR, SCHED_FIFO, or SCHED_DEADLINE. The incorrect comparison in check_preempt_wakeup makes RR, FIFO and DEADLINE tasks which inherit from a fair task behave as if they were IDLE or BATCH tasks, thus awaiting the following tick before preempting the current task. Cc: Peter Zijlstra Cc: Steven Rostedt (Red Hat) Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Mathieu Desnoyers Signed-off-by: Julien Desfossez --- 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 07aaa7f..f3aef21 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5669,7 +5669,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ * Batch and idle tasks do not preempt non-idle tasks (their preemption * is driven by the tick): */ - if (unlikely(p->policy != SCHED_NORMAL) || !sched_feat(WAKEUP_PREEMPTION)) + if (unlikely(p->policy == SCHED_BATCH || p->policy == SCHED_IDLE) || + !sched_feat(WAKEUP_PREEMPTION)) return; find_matching_se(&se, &pse); -- 1.9.1