Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031201AbbD1UBH (ORCPT ); Tue, 28 Apr 2015 16:01:07 -0400 Received: from g4t3425.houston.hp.com ([15.201.208.53]:16470 "EHLO g4t3425.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030826AbbD1UBE (ORCPT ); Tue, 28 Apr 2015 16:01:04 -0400 From: Jason Low To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, "Paul E. McKenney" , Andrew Morton , Oleg Nesterov , Frederic Weisbecker , Mel Gorman , Rik van Riel , Steven Rostedt , Preeti U Murthy , Mike Galbraith , Davidlohr Bueso , Waiman Long , Aswin Chandramouleeswaran , Scott J Norton , Jason Low Subject: [PATCH v2 4/5] sched, timer: Provide an atomic task_cputime data structure Date: Tue, 28 Apr 2015 13:00:23 -0700 Message-Id: <1430251224-5764-5-git-send-email-jason.low2@hp.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1430251224-5764-1-git-send-email-jason.low2@hp.com> References: <1430251224-5764-1-git-send-email-jason.low2@hp.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1364 Lines: 46 This patch adds an atomic variant of the task_cputime data structure, which can be used to store and update task_cputime statistics without needing to do locking. Suggested-by: Ingo Molnar Signed-off-by: Jason Low --- include/linux/sched.h | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index c736a47..7092192 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -575,6 +575,23 @@ struct task_cputime { .sum_exec_runtime = 0, \ } +/* + * This is the atomic variant of task_cputime, which can be used for + * storing and updating task_cputime statistics without locking. + */ +struct task_cputime_atomic { + atomic64_t utime; + atomic64_t stime; + atomic64_t sum_exec_runtime; +}; + +#define INIT_CPUTIME_ATOMIC \ + (struct task_cputime_atomic) { \ + .utime = ATOMIC64_INIT(0), \ + .stime = ATOMIC64_INIT(0), \ + .sum_exec_runtime = ATOMIC64_INIT(0), \ + } + #ifdef CONFIG_PREEMPT_COUNT #define PREEMPT_DISABLED (1 + PREEMPT_ENABLED) #else -- 1.7.2.5 -- 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/