Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751492AbaAMIqG (ORCPT ); Mon, 13 Jan 2014 03:46:06 -0500 Received: from mail-bk0-f54.google.com ([209.85.214.54]:52442 "EHLO mail-bk0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbaAMIqD (ORCPT ); Mon, 13 Jan 2014 03:46:03 -0500 Date: Mon, 13 Jan 2014 09:45:55 +0100 From: Robert Richter To: Weng Meiling Cc: oprofile-list@lists.sf.net, linux-kernel@vger.kernel.org, Li Zefan , wangnan0@huawei.com, "zhangwei(Jovi)" , Huang Qiang Subject: Re: [PATCH] oprofile: check whether oprofile perf enabled in op_overflow_handler() Message-ID: <20140113084555.GU20315@rric.localhost> References: <52B3F66D.6060707@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52B3F66D.6060707@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Weng, sorry for answering late, your mail hit the holiday season. On 20.12.13 15:49:01, Weng Meiling wrote: > > From: Weng Meiling > > There is a situation event is triggered before oprofile_perf_start() finish. > Because the event is still not stored in per_cpu(perf_events, cpu)[event], > op_overflow_handler() will print the warning. During the time, if unregistered > event is triggered again, the cpu will print again. This may make cpu keeping > on printing and trigger softlockup. So check whether events register finished > in op_overflow_handler(). > > The problem was once triggered on kernel 2.6.34, the main information: > <3>BUG: soft lockup - CPU#0 stuck for 60005ms! [opcontrol:8673] > > Pid: 8673, comm: opcontrol > =====================SOFTLOCKUP INFO BEGIN======================= > [CPU#0] the task [opcontrol] is not waiting for a lock,maybe a delay or deadcricle! > <6>opcontrol R running 0 8673 7603 0x00000002 > locked: > bf0e1928 mutex 0 [] oprofile_start+0x10/0x68 [oprofile] > bf0e1a24 mutex 0 [] op_arm_start+0x10/0x48 [oprofile] > c0628020 &ctx->mutex 0 [] perf_event_create_kernel_counter+0xa4/0x14c I rather suspect the code of perf_install_in_context() of 2.6.34 to cause the locking issue. There was a lot of rework in between there. Can you further explain the locking and why your fix should solve it? It would be better to go through the bunch of fixes between 2.6.34 and current kernel. Or, to use the latest kernel and/or operf if possible. See also below. > [] (unwind_backtrace+0x0/0x164) from [] (show_stack+0x10/0x14) > [] (show_stack+0x10/0x14) from [] (show_lock_info+0x9c/0x168) > [] (show_lock_info+0x9c/0x168) from [] (softlockup_tick+0x1c4/0x234) > [] (softlockup_tick+0x1c4/0x234) from [] (update_process_times+0x2c/0x50) > [] (update_process_times+0x2c/0x50) from [] (tick_sched_timer+0x268/0x2c4) > [] (tick_sched_timer+0x268/0x2c4) from [] (__run_hrtimer+0x158/0x25c) > [] (__run_hrtimer+0x158/0x25c) from [] (hrtimer_interrupt+0x13c/0x2f8) > [] (hrtimer_interrupt+0x13c/0x2f8) from [] (timer64_timer_interrupt+0x20/0x2c) > [] (timer64_timer_interrupt+0x20/0x2c) from [] (handle_IRQ_event+0x144/0x2ec) > [] (handle_IRQ_event+0x144/0x2ec) from [] (handle_level_irq+0xc0/0x13c) > [] (handle_level_irq+0xc0/0x13c) from [] (asm_do_IRQ+0x80/0xbc) > [] (asm_do_IRQ+0x80/0xbc) from [] (__irq_svc+0x4c/0xe4) > Exception stack(0xc4099db8 to 0xc4099e00) > 9da0: c0357538 00000000 > 9dc0: 00000000 c0380cc0 c4098000 00000202 00000028 c4098000 3fca9fbc c4098000 > 9de0: c0028b08 00000000 c4098000 c4099e00 c005eb50 c005e544 20000113 ffffffff > [] (__irq_svc+0x4c/0xe4) from [] (__do_softirq+0x64/0x25c) > [] (__do_softirq+0x64/0x25c) from [] (irq_exit+0x48/0x5c) > [] (irq_exit+0x48/0x5c) from [] (asm_do_IRQ+0x84/0xbc) > [] (asm_do_IRQ+0x84/0xbc) from [] (__irq_svc+0x4c/0xe4) > Exception stack(0xc4099e58 to 0xc4099ea0) > 9e40: c0628010 20000093 > 9e60: 00000001 00000000 00000000 60000013 c00aff24 cc4f6c00 00000001 c4098000 > 9e80: 00000000 00000000 00000000 c4099ea0 c0084fa0 c0084fa4 60000013 ffffffff > [] (__irq_svc+0x4c/0xe4) from [] (smp_call_function_single+0xc0/0x1d8) > [] (smp_call_function_single+0xc0/0x1d8) from [] (perf_event_create_kernel_counter+0xb4/0x14c) > [] (perf_event_create_kernel_counter+0xb4/0x14c) from [] (op_perf_start+0x54/0xf0 [oprofile]) > [] (op_perf_start+0x54/0xf0 [oprofile]) from [] (op_arm_start+0x20/0x48 [oprofile]) > [] (op_arm_start+0x20/0x48 [oprofile]) from [] (oprofile_start+0x38/0x68 [oprofile]) > [] (oprofile_start+0x38/0x68 [oprofile]) from [] (enable_write+0x34/0x54 [oprofile]) > [] (enable_write+0x34/0x54 [oprofile]) from [] (vfs_write+0xa8/0x150) > [] (vfs_write+0xa8/0x150) from [] (sys_write+0x3c/0x100) > [] (sys_write+0x3c/0x100) from [] (ret_fast_syscall+0x0/0x30) > =====================SOFTLOCKUP INFO END========================= > <0>Kernel panic - not syncing: softlockup: hung tasks > > Cc: # 2.6.34+ > Signed-off-by: Weng Meiling > --- > drivers/oprofile/oprofile_perf.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/oprofile/oprofile_perf.c b/drivers/oprofile/oprofile_perf.c > index d5b2732..a9e5761 100644 > --- a/drivers/oprofile/oprofile_perf.c > +++ b/drivers/oprofile/oprofile_perf.c > @@ -38,6 +38,9 @@ static void op_overflow_handler(struct perf_event *event, > int id; > u32 cpu = smp_processor_id(); > > + if (!oprofile_perf_enabled) > + return; > + > for (id = 0; id < num_counters; ++id) > if (per_cpu(perf_events, cpu)[id] == event) > break; Your newly introduced check does basically the same as this existing check, except that it now prevents printing the warning and thus stays shorter in the interrupt handler. So it might work accidentally due to different timing and does not solve the problem. Using oprofile_perf_enabled would also require protection by the oprofile_perf_mutex. But op_overflow_handler() does not contain code protected either by oprofile_perf_enabled nor oprofile_perf_mutex. Since the mutex can't be used in the interrupt handler you also can't use oprofile_perf_enabled there. -Robert > -- > 1.8.3 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/