Skip to content

Commit 971e8a9

Browse files
Jason LowIngo Molnar
authored andcommitted
sched, timer: Provide an atomic 'struct task_cputime' data structure
This patch adds an atomic variant of the 'struct task_cputime' data structure, which can be used to store and update task_cputime statistics without needing to do locking. Suggested-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Jason Low <jason.low2@hp.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Aswin Chandramouleeswaran <aswin@hp.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Mike Galbraith <umgwanakikbuti@gmail.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com> Cc: Scott J Norton <scott.norton@hp.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Waiman Long <Waiman.Long@hp.com> Link: http://lkml.kernel.org/r/1430251224-5764-5-git-send-email-jason.low2@hp.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 1018016 commit 971e8a9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

include/linux/sched.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,23 @@ struct task_cputime {
572572
.sum_exec_runtime = 0, \
573573
}
574574

575+
/*
576+
* This is the atomic variant of task_cputime, which can be used for
577+
* storing and updating task_cputime statistics without locking.
578+
*/
579+
struct task_cputime_atomic {
580+
atomic64_t utime;
581+
atomic64_t stime;
582+
atomic64_t sum_exec_runtime;
583+
};
584+
585+
#define INIT_CPUTIME_ATOMIC \
586+
(struct task_cputime_atomic) { \
587+
.utime = ATOMIC64_INIT(0), \
588+
.stime = ATOMIC64_INIT(0), \
589+
.sum_exec_runtime = ATOMIC64_INIT(0), \
590+
}
591+
575592
#ifdef CONFIG_PREEMPT_COUNT
576593
#define PREEMPT_DISABLED (1 + PREEMPT_ENABLED)
577594
#else

0 commit comments

Comments
 (0)