Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754682Ab3ECEsv (ORCPT ); Fri, 3 May 2013 00:48:51 -0400 Received: from mail-qe0-f50.google.com ([209.85.128.50]:58822 "EHLO mail-qe0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753117Ab3ECEst (ORCPT ); Fri, 3 May 2013 00:48:49 -0400 From: kosaki.motohiro@gmail.com To: linux-kernel@vger.kernel.org Cc: Olivier Langlois , Thomas Gleixner , Frederic Weisbecker , Ingo Molnar , Peter Zijlstra , KOSAKI Motohiro Subject: [PATCH 1/7] posix-cpu-timers: don't account cpu timer after stopped thread runtime accounting Date: Fri, 3 May 2013 00:47:42 -0400 Message-Id: <1367556468-4021-3-git-send-email-kosaki.motohiro@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1367556468-4021-1-git-send-email-kosaki.motohiro@gmail.com> References: <1367556468-4021-1-git-send-email-kosaki.motohiro@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1703 Lines: 48 From: KOSAKI Motohiro When tsk->signal->cputimer->running is 1, signal->cputimer and tsk->sum_sched_runtime increase at the same pace because update_curr() increases both accounting. However, there is one exception. When thread exiting, __exit_signal() turns over task's sum_shced_runtime to sig->sum_sched_runtime, but it doesn't stop signal->cputimer accounting. This inconsistency makes POSIX timer wake up too early. This patch fixes it. Cc: Thomas Gleixner Cc: Frederic Weisbecker Cc: Ingo Molnar Acked-by: Peter Zijlstra Signed-off-by: Olivier Langlois Signed-off-by: KOSAKI Motohiro --- kernel/sched/stats.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h index 2ef90a5..5a0cfc4 100644 --- a/kernel/sched/stats.h +++ b/kernel/sched/stats.h @@ -225,6 +225,13 @@ static inline void account_group_exec_runtime(struct task_struct *tsk, if (!cputimer->running) return; + /* + * After turning over se.sum_exec_runtime to sig->sum_sched_runtime + * in __exit_signal(), we must not account exec_runtime for consistency. + */ + if (unlikely(!tsk->sighand)) + return; + raw_spin_lock(&cputimer->lock); cputimer->cputime.sum_exec_runtime += ns; raw_spin_unlock(&cputimer->lock); -- 1.7.1 -- 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/