Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030272AbbKSPtM (ORCPT ); Thu, 19 Nov 2015 10:49:12 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:32952 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934127AbbKSPrs (ORCPT ); Thu, 19 Nov 2015 10:47:48 -0500 From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Peter Zijlstra , Chris Metcalf , Thomas Gleixner , Hiroshi Shimamoto , Luiz Capitulino , Christoph Lameter , "Paul E . McKenney" , Ingo Molnar , stable@vger.kernel.org, Rik van Riel Subject: [PATCH 4/7] cputime: Correctly handle task guest time on housekeepers Date: Thu, 19 Nov 2015 16:47:31 +0100 Message-Id: <1447948054-28668-5-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1447948054-28668-1-git-send-email-fweisbec@gmail.com> References: <1447948054-28668-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1824 Lines: 48 When a task runs on a housekeeper (a CPU running with the periodic tick with neighbours running tickless), it doesn't account cputime using vtime but relies on the tick. Such a task has its vtime_snap_whence value set to VTIME_INACTIVE. Readers won't handle that correctly though. As long as vtime is running on some CPU, readers incorretly assume that vtime runs on all CPUs and always compute the tickless cputime delta, which is only junk on housekeepers. So lets fix this with checking that the target runs on a vtime CPU through the appropriate state check before computing the tickless delta. Cc: Christoph Lameter Cc: Chris Metcalf Cc: Ingo Molnar Cc: Luiz Capitulino Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Cc: Paul E. McKenney Cc: Hiroshi Shimamoto Signed-off-by: Frederic Weisbecker --- kernel/sched/cputime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 4a18a6e..5cf24e7 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -795,7 +795,7 @@ cputime_t task_gtime(struct task_struct *t) seq = read_seqbegin(&t->vtime_seqlock); gtime = t->gtime; - if (t->flags & PF_VCPU) + if (t->vtime_snap_whence == VTIME_SYS && t->flags & PF_VCPU) gtime += vtime_delta(t); } while (read_seqretry(&t->vtime_seqlock, seq)); -- 2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/