linux-stable/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 gcov: disable CONSTRUCTORS for UML 2011-07-26 16:49:45 -07:00
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.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
audit.h
audit_tree.c
audit_watch.c
auditfilter.c
auditsc.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
backtracetest.c
bounds.c
capability.c
cgroup.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6 2011-07-27 19:26:38 -07:00
cgroup_freezer.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 kernel/configs.c: include MODULE_*() when CONFIG_IKCONFIG_PROC=n 2011-07-25 20:57:15 -07:00
cpu.c
cpuset.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
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 ipc: introduce shm_rmid_forced sysctl 2011-07-26 16:49:44 -07:00
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.c Merge branch 'linus' into core/urgent 2011-08-04 09:09:27 +02:00
futex_compat.c
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.c lockdep: Fix wrong assumption in match_held_lock 2011-08-09 11:57:35 +02:00
lockdep_internals.h
lockdep_proc.c
lockdep_states.h
Makefile jump label: Reduce the cycle count by changing the link order 2011-08-05 23:57:33 +02:00
module.c module: add /sys/module/<name>/uevent files 2011-07-24 22:06:04 +09:30
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
notifier.c notifiers: sys: move reboot notifiers into reboot.h 2011-07-25 20:57:14 -07:00
nsproxy.c
padata.c
panic.c panic: panic=-1 for immediate reboot 2011-07-26 16:49:45 -07:00
params.c module: add /sys/module/<name>/uevent files 2011-07-24 22:06:04 +09:30
pid.c
pid_namespace.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 atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
rcutiny.c
rcutiny_plugin.h
rcutorture.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
rcutree.c
rcutree.h
rcutree_plugin.h
rcutree_trace.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
relay.c
res_counter.c
resource.c Resource: fix wrong resource window calculation 2011-09-29 20:04:34 -07:00
rtmutex-debug.c
rtmutex-debug.h
rtmutex-tester.c
rtmutex.c
rtmutex.h
rtmutex_common.h
rwsem.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
sched.c posix-cpu-timers: Cure SMP wobbles 2011-09-30 14:07:06 +02:00
sched_autogroup.c
sched_autogroup.h
sched_clock.c
sched_cpupri.c
sched_cpupri.h
sched_debug.c
sched_fair.c
sched_features.h Merge branch 'kvm-updates/3.1' of git://git.kernel.org/pub/scm/virt/kvm/kvm 2011-07-24 09:07:03 -07:00
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
seccomp.c
semaphore.c
signal.c signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked() 2011-07-27 12:53:36 -07:00
smp.c
softirq.c
spinlock.c
srcu.c
stacktrace.c
stop_machine.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
sys.c Avoid using variable-length arrays in kernel/sys.c 2011-10-17 08:24:24 -07:00
sys_ni.c All Arch: remove linkage for sys_nfsservctl system call 2011-08-26 15:09:58 -07:00
sysctl.c
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
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-return-notifier.c
user.c
user_namespace.c
utsname.c
utsname_sysctl.c
wait.c
watchdog.c
workqueue.c workqueue: lock cwq access in drain_workqueue 2011-09-14 18:09:38 -07:00
workqueue_sched.h