linux/kernel
Peter Zijlstra bcd5cff721 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 e8abccb719 ("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 <davej@redhat.com>
Reported-by: Simon Kirby <sim@hostway.ca>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: stable@kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/1318928713.21167.4.camel@twins
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-10-18 11:36:59 +02:00
..
debug Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb 2011-08-01 13:39:40 -10:00
events perf_event: Fix broken calc_timer_values() 2011-08-31 15:56:29 +02:00
gcov
irq irq: Fix check for already initialized irq_domain in irq_domain_add 2011-09-20 12:16:22 +02:00
power PM / Domains: Fix build for CONFIG_PM_RUNTIME unset 2011-08-14 13:34:31 +02:00
time alarmtimers: Avoid possible denial of service with high freq periodic timers 2011-08-10 10:26:09 -07:00
trace Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2011-08-19 10:47:07 -07:00
.gitignore
acct.c
async.c
audit_tree.c
audit_watch.c
audit.c
audit.h
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
cgroup_freezer.c
cgroup.c
compat.c Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6 2011-07-30 00:08:53 -07:00
configs.c
cpu.c
cpuset.c
crash_dump.c
cred.c move RLIMIT_NPROC check from set_user() to do_execve_common() 2011-08-11 11:24:42 -07:00
delayacct.c
dma.c
elfcore.c
exec_domain.c
exit.c
extable.c
fork.c move RLIMIT_NPROC check from set_user() to do_execve_common() 2011-08-11 11:24:42 -07:00
freezer.c
futex_compat.c
futex.c Merge branch 'linus' into core/urgent 2011-08-04 09:09:27 +02:00
groups.c
hrtimer.c
hung_task.c
irq_work.c
itimer.c
jump_label.c
kallsyms.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kexec.c
kfifo.c
kmod.c Boot up with usermodehelper disabled 2011-08-03 22:03:29 -10:00
kprobes.c
ksysfs.c
kthread.c
latencytop.c
lockdep_internals.h
lockdep_proc.c
lockdep_states.h
lockdep.c lockdep: Fix wrong assumption in match_held_lock 2011-08-09 11:57:35 +02:00
Makefile jump label: Reduce the cycle count by changing the link order 2011-08-05 23:57:33 +02:00
module.c
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
notifier.c
nsproxy.c
padata.c
panic.c
params.c
pid_namespace.c
pid.c
pm_qos_params.c
posix-cpu-timers.c cputimer: Cure lock inversion 2011-10-18 11:36:59 +02:00
posix-timers.c
printk.c kernel/printk: do not turn off bootconsole in printk_late_init() if keep_bootcon 2011-08-25 16:25:34 -07:00
profile.c
ptrace.c ptrace: PTRACE_LISTEN forgets to unlock ->siglock 2011-09-25 11:02:00 -07:00
range.c
rcupdate.c
rcutiny_plugin.h
rcutiny.c
rcutorture.c
rcutree_plugin.h
rcutree_trace.c
rcutree.c
rcutree.h
relay.c
res_counter.c
resource.c Resource: fix wrong resource window calculation 2011-09-29 20:04:34 -07:00
rtmutex_common.h
rtmutex-debug.c
rtmutex-debug.h
rtmutex-tester.c
rtmutex.c
rtmutex.h
rwsem.c
sched_autogroup.c
sched_autogroup.h
sched_clock.c
sched_cpupri.c
sched_cpupri.h
sched_debug.c
sched_fair.c
sched_features.h
sched_idletask.c
sched_rt.c sched/rt: Migrate equal priority tasks to available CPUs 2011-09-18 13:48:56 +02:00
sched_stats.h
sched_stoptask.c
sched.c posix-cpu-timers: Cure SMP wobbles 2011-09-30 14:07:06 +02:00
seccomp.c
semaphore.c
signal.c
smp.c
softirq.c
spinlock.c
srcu.c
stacktrace.c
stop_machine.c
sys_ni.c All Arch: remove linkage for sys_nfsservctl system call 2011-08-26 15:09:58 -07:00
sys.c Avoid using variable-length arrays in kernel/sys.c 2011-10-17 08:24:24 -07:00
sysctl_binary.c xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
sysctl_check.c xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
sysctl.c
taskstats.c Make TASKSTATS require root access 2011-09-19 17:04:37 -07:00
test_kprobes.c
time.c
timeconst.pl
timer.c
tracepoint.c
tsacct.c Make taskstats round statistics down to nearest 1k bytes/events 2011-09-19 17:10:57 -07:00
uid16.c
up.c
user_namespace.c
user-return-notifier.c
user.c
utsname_sysctl.c
utsname.c
wait.c
watchdog.c
workqueue_sched.h
workqueue.c workqueue: lock cwq access in drain_workqueue 2011-09-14 18:09:38 -07:00