]> Git Repo - linux.git/commit
cputimer: Cure lock inversion
authorPeter Zijlstra <[email protected]>
Mon, 17 Oct 2011 09:50:30 +0000 (11:50 +0200)
committerThomas Gleixner <[email protected]>
Tue, 18 Oct 2011 09:36:59 +0000 (11:36 +0200)
commitbcd5cff7216f9b2de0a148cc355eac199dc6f1cf
tree384674b2b0e16e489f591148982046bf2d25608b
parent899e3ee404961a90b828ad527573aaaac39f0ab1
cputimer: Cure lock inversion

There's a lock inversion between the cputimer->lock and rq->lock;
notably the two callchains involved are:

 update_rlimit_cpu()
   sighand->siglock
   set_process_cpu_timer()
     cpu_timer_sample_group()
       thread_group_cputimer()
         cputimer->lock
         thread_group_cputime()
           task_sched_runtime()
             ->pi_lock
             rq->lock

 scheduler_tick()
   rq->lock
   task_tick_fair()
     update_curr()
       account_group_exec()
         cputimer->lock

Where the first one is enabling a CLOCK_PROCESS_CPUTIME_ID timer, and
the second one is keeping up-to-date.

This problem was introduced by e8abccb7193 ("posix-cpu-timers: Cure
SMP accounting oddities").

Cure the problem by removing the cputimer->lock and rq->lock nesting,
this leaves concurrent enablers doing duplicate work, but the time
wasted should be on the same order otherwise wasted spinning on the
lock and the greater-than assignment filter should ensure we preserve
monotonicity.

Reported-by: Dave Jones <[email protected]>
Reported-by: Simon Kirby <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: Linus Torvalds <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Link: http://lkml.kernel.org/r/1318928713.21167.4.camel@twins
Signed-off-by: Thomas Gleixner <[email protected]>
kernel/posix-cpu-timers.c
This page took 0.055488 seconds and 4 git commands to generate.