From 19a3f9e3d11040f3df772154aa06701fa1038541 Mon Sep 17 00:00:00 2001 From: Yong Zhang Date: Wed, 11 Jul 2012 22:05:21 +0000 Subject: [PATCH] perf: Make swevent hrtimer run in irq instead of softirq Otherwise we get a deadlock like below: [ 1044.042749] BUG: scheduling while atomic: ksoftirqd/21/141/0x00010003 [ 1044.042752] INFO: lockdep is turned off. [ 1044.042754] Modules linked in: [ 1044.042757] Pid: 141, comm: ksoftirqd/21 Tainted: G W 3.4.0-rc2-rt3-23676-ga723175-dirty #29 [ 1044.042759] Call Trace: [ 1044.042761] [] __schedule_bug+0x65/0x80 [ 1044.042770] [] __schedule+0x83c/0xa70 [ 1044.042775] [] ? prepare_to_wait+0x32/0xb0 [ 1044.042779] [] schedule+0x2e/0xa0 [ 1044.042782] [] hrtimer_wait_for_timer+0x6d/0xb0 [ 1044.042786] [] ? wake_up_bit+0x40/0x40 [ 1044.042790] [] hrtimer_cancel+0x20/0x40 [ 1044.042794] [] perf_swevent_cancel_hrtimer+0x3c/0x50 [ 1044.042798] [] task_clock_event_stop+0x11/0x40 [ 1044.042802] [] task_clock_event_del+0xe/0x10 [ 1044.042805] [] event_sched_out+0x118/0x1d0 [ 1044.042809] [] group_sched_out+0x29/0x90 [ 1044.042813] [] __perf_event_disable+0x18e/0x200 [ 1044.042817] [] remote_function+0x63/0x70 [ 1044.042821] [] generic_smp_call_function_single_interrupt+0xce/0x120 [ 1044.042826] [] smp_call_function_single_interrupt+0x27/0x40 [ 1044.042831] [] call_function_single_interrupt+0x6c/0x80 [ 1044.042833] [] ? perf_event_overflow+0x20/0x20 [ 1044.042840] [] ? _raw_spin_unlock_irq+0x30/0x70 [ 1044.042844] [] ? _raw_spin_unlock_irq+0x36/0x70 [ 1044.042848] [] run_hrtimer_softirq+0xc2/0x200 [ 1044.042853] [] ? perf_event_overflow+0x20/0x20 [ 1044.042857] [] __do_softirq_common+0xf5/0x3a0 [ 1044.042862] [] __thread_do_softirq+0x15d/0x200 [ 1044.042865] [] run_ksoftirqd+0xfa/0x210 [ 1044.042869] [] ? __thread_do_softirq+0x200/0x200 [ 1044.042873] [] ? __thread_do_softirq+0x200/0x200 [ 1044.042877] [] kthread+0xb6/0xc0 [ 1044.042881] [] ? _raw_spin_unlock_irq+0x3b/0x70 [ 1044.042886] [] kernel_thread_helper+0x4/0x10 [ 1044.042889] [] ? finish_task_switch+0x8c/0x110 [ 1044.042894] [] ? _raw_spin_unlock_irq+0x3b/0x70 [ 1044.042897] [] ? retint_restore_args+0xe/0xe [ 1044.042900] [] ? kthreadd+0x1e0/0x1e0 [ 1044.042902] [] ? gs_change+0xb/0xb Signed-off-by: Yong Zhang Cc: Peter Zijlstra Cc: Steven Rostedt Link: http://lkml.kernel.org/r/1341476476-5666-1-git-send-email-yong.zhang0@gmail.com Signed-off-by: Thomas Gleixner Signed-off-by: Steven Rostedt --- kernel/events/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 08315ad82a849f..1c876e0281ec29 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5702,6 +5702,7 @@ static void perf_swevent_init_hrtimer(struct perf_event *event) hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hwc->hrtimer.function = perf_swevent_hrtimer; + hwc->hrtimer.irqsafe = 1; /* * Since hrtimers have a fixed rate, we can do a static freq->period