From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934145AbcIVOC6 (ORCPT ); Thu, 22 Sep 2016 10:02:58 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56858 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756994AbcIVOCl (ORCPT ); Thu, 22 Sep 2016 10:02:41 -0400 Date: Thu, 22 Sep 2016 07:01:55 -0700 From: tip-bot for Srivatsa Vaddagiri Message-ID: Cc: torvalds@linux-foundation.org, hpa@zytor.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, joonwoop@codeaurora.org, vatsa@codeaurora.org Reply-To: hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, joonwoop@codeaurora.org, vatsa@codeaurora.org, mingo@kernel.org, peterz@infradead.org In-Reply-To: <1474075731-11550-1-git-send-email-joonwoop@codeaurora.org> References: <1474075731-11550-1-git-send-email-joonwoop@codeaurora.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/fair: Fix SCHED_HRTICK bug leading to late preemption of tasks Git-Commit-ID: 8bf46a39be910937d4c9e8d999a7438a7ae1a75b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8bf46a39be910937d4c9e8d999a7438a7ae1a75b Gitweb: http://git.kernel.org/tip/8bf46a39be910937d4c9e8d999a7438a7ae1a75b Author: Srivatsa Vaddagiri AuthorDate: Fri, 16 Sep 2016 18:28:51 -0700 Committer: Ingo Molnar CommitDate: Thu, 22 Sep 2016 15:20:18 +0200 sched/fair: Fix SCHED_HRTICK bug leading to late preemption of tasks SCHED_HRTICK feature is useful to preempt SCHED_FAIR tasks on-the-dot (just when they would have exceeded their ideal_runtime). It makes use of a per-CPU hrtimer resource and hence arming that hrtimer should be based on total SCHED_FAIR tasks a CPU has across its various cfs_rqs, rather than being based on number of tasks in a particular cfs_rq (as implemented currently). As a result, with current code, its possible for a running task (which is the sole task in its cfs_rq) to be preempted much after its ideal_runtime has elapsed, resulting in increased latency for tasks in other cfs_rq on same CPU. Fix this by arming sched hrtimer based on total number of SCHED_FAIR tasks a CPU has across its various cfs_rqs. Signed-off-by: Srivatsa Vaddagiri Signed-off-by: Joonwoo Park Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1474075731-11550-1-git-send-email-joonwoop@codeaurora.org Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 986c10c..8fb4d19 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4469,7 +4469,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p) WARN_ON(task_rq(p) != rq); - if (cfs_rq->nr_running > 1) { + if (rq->cfs.h_nr_running > 1) { u64 slice = sched_slice(cfs_rq, se); u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime; s64 delta = slice - ran;