path: root/kernel/fork.c
diff options
authorJason Low <>2015-04-28 13:00:22 -0700
committerIngo Molnar <>2015-05-08 12:15:31 +0200
commit1018016c706f7ff9f56fde3a649789c47085a293 (patch)
tree1f564aa153c8b4d3610c354ebb3e963c6a29e165 /kernel/fork.c
parent7e5a2c1729f1612618ed236249a15bf15f309325 (diff)
sched, timer: Replace spinlocks with atomics in thread_group_cputimer(), to improve scalability
While running a database workload, we found a scalability issue with itimers. Much of the problem was caused by the thread_group_cputimer spinlock. Each time we account for group system/user time, we need to obtain a thread_group_cputimer's spinlock to update the timers. On larger systems (such as a 16 socket machine), this caused more than 30% of total time spent trying to obtain this kernel lock to update these group timer stats. This patch converts the timers to 64-bit atomic variables and use atomic add to update them without a lock. With this patch, the percent of total time spent updating thread group cputimer timers was reduced from 30% down to less than 1%. Note: On 32-bit systems using the generic 64-bit atomics, this causes sample_group_cputimer() to take locks 3 times instead of just 1 time. However, we tested this patch on a 32-bit system ARM system using the generic atomics and did not find the overhead to be much of an issue. An explanation for why this isn't an issue is that 32-bit systems usually have small numbers of CPUs, and cacheline contention from extra spinlocks called periodically is not really apparent on smaller systems. Signed-off-by: Jason Low <> Signed-off-by: Peter Zijlstra (Intel) <> Acked-by: Thomas Gleixner <> Acked-by: Rik van Riel <> Cc: Andrew Morton <> Cc: Aswin Chandramouleeswaran <> Cc: Borislav Petkov <> Cc: Davidlohr Bueso <> Cc: Frederic Weisbecker <> Cc: H. Peter Anvin <> Cc: Linus Torvalds <> Cc: Mel Gorman <> Cc: Mike Galbraith <> Cc: Oleg Nesterov <> Cc: Paul E. McKenney <> Cc: Peter Zijlstra <> Cc: Preeti U Murthy <> Cc: Scott J Norton <> Cc: Steven Rostedt <> Cc: Waiman Long <> Link: Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'kernel/fork.c')
1 files changed, 0 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 47c37a411a62..2e670864174f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1091,9 +1091,6 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
unsigned long cpu_limit;
- /* Thread group counters. */
- thread_group_cputime_init(sig);
cpu_limit = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
if (cpu_limit != RLIM_INFINITY) {
sig->cputime_expires.prof_exp = secs_to_cputime(cpu_limit);