From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752438Ab2LTSlz (ORCPT ); Thu, 20 Dec 2012 13:41:55 -0500 Received: from mail-we0-f176.google.com ([74.125.82.176]:43593 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752328Ab2LTSll (ORCPT ); Thu, 20 Dec 2012 13:41:41 -0500 From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Alessio Igor Bogani , Andrew Morton , Avi Kivity , Chris Metcalf , Christoph Lameter , Geoff Levand , Gilad Ben Yossef , Hakan Akkan , Ingo Molnar , "Paul E. McKenney" , Paul Gortmaker , Peter Zijlstra , Steven Rostedt , Thomas Gleixner Subject: [PATCH 14/24] sched: Update rq clock on tickless CPUs before calling check_preempt_curr() Date: Thu, 20 Dec 2012 19:33:01 +0100 Message-Id: <1356028391-14427-15-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1356028391-14427-1-git-send-email-fweisbec@gmail.com> References: <1356028391-14427-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org check_preempt_wakeup() of fair class needs an uptodate sched clock value to update runtime stats of the current task. When a task is woken up, activate_task() is usually called right before ttwu_do_wakeup() unless the task is already in the runqueue. In this case we need to update the rq clock manually in case the CPU runs tickless because ttwu_do_wakeup() calls check_preempt_wakeup(). Signed-off-by: Frederic Weisbecker Cc: Alessio Igor Bogani Cc: Andrew Morton Cc: Avi Kivity Cc: Chris Metcalf Cc: Christoph Lameter Cc: Geoff Levand Cc: Gilad Ben Yossef Cc: Hakan Akkan Cc: Ingo Molnar Cc: Paul E. McKenney Cc: Paul Gortmaker Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner --- kernel/sched/core.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5d9060a..9cbace7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1323,6 +1323,12 @@ static int ttwu_remote(struct task_struct *p, int wake_flags) rq = __task_rq_lock(p); if (p->on_rq) { + /* + * Ensure check_preempt_curr() won't deal with a stale value + * of rq clock if the CPU is tickless. BTW do we actually need + * check_preempt_curr() to be called here? + */ + update_nohz_rq_clock(rq); ttwu_do_wakeup(rq, p, wake_flags); ret = 1; } @@ -1500,8 +1506,17 @@ static void try_to_wake_up_local(struct task_struct *p) if (!(p->state & TASK_NORMAL)) goto out; - if (!p->on_rq) + if (!p->on_rq) { ttwu_activate(rq, p, ENQUEUE_WAKEUP); + } else { + /* + * Even if the task is on the runqueue we still + * need to ensure check_preempt_curr() won't + * deal with a stale rq clock value on a tickless + * CPU + */ + update_nohz_rq_clock(rq); + } ttwu_do_wakeup(rq, p, 0); ttwu_stat(p, smp_processor_id(), 0); -- 1.7.5.4