[2.6.28-rc6] oprofile: "opcontrol --start" output two warnings

From: KOSAKI Motohiro
Date: Mon Nov 24 2008 - 22:18:49 EST


Hi

2.6.28-rc6 on P4 box output following two warning when run "opcontrol --start".
Can I get any suggestion?


(1) bad smp_processor_id() usage

[ 83.652906] BUG: using smp_processor_id() in preemptible [00000000] code: oprofiled/4227
[ 83.749539] caller is get_stagger+0x6/0x30
[ 83.798524] Pid: 4227, comm: oprofiled Not tainted 2.6.28-rc6 #1
[ 83.870334] Call Trace:
[ 83.899520] [<c0295871>] debug_smp_processor_id+0xc1/0xd0
[ 83.965080] [<c0426de6>] get_stagger+0x6/0x30
[ 84.018266] [<c042734b>] p4_fill_in_addresses+0x1b/0x350
[ 84.082939] [<c0426314>] nmi_setup+0xd4/0x190
[ 84.136014] [<c0425120>] event_buffer_open+0x0/0x70
[ 84.195306] [<c0424197>] oprofile_setup+0x37/0xd0
[ 84.252536] [<c0425173>] event_buffer_open+0x53/0x70
[ 84.312869] [<c019e41b>] __dentry_open+0xeb/0x270
[ 84.370097] [<c019e5e7>] nameidata_to_filp+0x47/0x60
[ 84.430492] [<c01aa94d>] do_filp_open+0x16d/0x730
[ 84.487716] [<c01b2cb6>] alloc_fd+0xd6/0x100
[ 84.539724] [<c04f69e5>] _spin_unlock+0x25/0x40
[ 84.594857] [<c019e1ce>] do_sys_open+0x4e/0xf0
[ 84.648944] [<c0103584>] restore_nocheck_notrace+0x0/0xe
[ 84.713424] [<c019e2ec>] sys_open+0x2c/0x40
[ 84.764433] [<c01034bd>] sysenter_do_call+0x12/0x35


(2) IRQ imbalance warnings

[ 93.616186] ------------[ cut here ]------------
[ 93.620006] WARNING: at kernel/lockdep.c:2882 check_flags+0x13c/0x160()
[ 93.620006] Modules linked in: piix ide_pci_generic usb_storage
ahci ata_piix libata ehci_hcd ohci_hcd uhci_hcd
[ 93.620006] Pid: 4142, comm: opcontrol Not tainted 2.6.28-rc6 #3
[ 93.620006] Call Trace:
[ 93.620006] [<c012f1ff>] warn_on_slowpath+0x5f/0x90
[ 93.620006] [<c04f99b9>] __atomic_notifier_call_chain+0x89/0xb0
[ 93.620006] [<c04f9930>] __atomic_notifier_call_chain+0x0/0xb0
[ 93.620006] [<c04f99f7>] atomic_notifier_call_chain+0x17/0x20
[ 93.620006] [<c01488e0>] notify_die+0x30/0x40
[ 93.620006] [<c04f7fbf>] nmi_watchdog_tick+0xdf/0x1e0
[ 93.620006] [<c04f71c7>] do_nmi+0xb7/0x2d0
[ 93.620006] [<c04f6ef4>] nmi_stack_correct+0x2b/0x30
[ 93.620006] [<c0150eac>] check_flags+0x13c/0x160
[ 93.620006] [<c0152998>] lock_acquired+0x38/0x1f0
[ 93.620006] [<c0183645>] handle_mm_fault+0x155/0x960
[ 93.620006] [<c04f901c>] do_page_fault+0x1dc/0x9a0
[ 93.620006] [<c0147c76>] down_read_trylock+0x56/0x60
[ 93.620006] [<c04f90cd>] do_page_fault+0x28d/0x9a0
[ 93.620006] [<c012e553>] do_fork+0xf3/0x320
[ 93.620006] [<c0103584>] restore_nocheck_notrace+0x0/0xe
[ 93.620006] [<c04f8e40>] do_page_fault+0x0/0x9a0
[ 93.620006] [<c01542b4>] trace_hardirqs_on_caller+0xc4/0x140
[ 93.620006] [<c04f8e40>] do_page_fault+0x0/0x9a0
[ 93.620006] [<c04f6e3f>] error_code+0x77/0x7c
[ 93.620006] ---[ end trace 04c2700d7cdea4d9 ]---
[ 93.620006] possible reason: unannotated irqs-on.
[ 93.620006] irq event stamp: 27660
[ 93.620006] hardirqs last enabled at (27659): [<c04f8ff6>]
do_page_fault+0x1b6/0x9a0
[ 93.620006] hardirqs last disabled at (27660): [<c04f6eeb>]
nmi_stack_correct+0x22/0x30
[ 93.620006] softirqs last enabled at (27594): [<c01053b2>]
call_on_stack+0x12/0x20
[ 93.620006] softirqs last disabled at (27563): [<c01053b2>]
call_on_stack+0x12/0x20



following dumb fix patch can solve (1).
but I'm not sure about it is correct way or not.

and I don't know why (2) happend.


===============================================================
following command cause lockdep warning.

$ opcontrol --start


[ 83.652906] BUG: using smp_processor_id() in preemptible [00000000] code: oprofiled/4227
[ 83.749539] caller is get_stagger+0x6/0x30
[ 83.798524] Pid: 4227, comm: oprofiled Not tainted 2.6.28-rc6 #1
[ 83.870334] Call Trace:
[ 83.899520] [<c0295871>] debug_smp_processor_id+0xc1/0xd0
[ 83.965080] [<c0426de6>] get_stagger+0x6/0x30
[ 84.018266] [<c042734b>] p4_fill_in_addresses+0x1b/0x350
[ 84.082939] [<c0426314>] nmi_setup+0xd4/0x190
[ 84.136014] [<c0425120>] event_buffer_open+0x0/0x70
[ 84.195306] [<c0424197>] oprofile_setup+0x37/0xd0
[ 84.252536] [<c0425173>] event_buffer_open+0x53/0x70
[ 84.312869] [<c019e41b>] __dentry_open+0xeb/0x270
[ 84.370097] [<c019e5e7>] nameidata_to_filp+0x47/0x60
[ 84.430492] [<c01aa94d>] do_filp_open+0x16d/0x730
[ 84.487716] [<c01b2cb6>] alloc_fd+0xd6/0x100
[ 84.539724] [<c04f69e5>] _spin_unlock+0x25/0x40
[ 84.594857] [<c019e1ce>] do_sys_open+0x4e/0xf0
[ 84.648944] [<c0103584>] restore_nocheck_notrace+0x0/0xe
[ 84.713424] [<c019e2ec>] sys_open+0x2c/0x40
[ 84.764433] [<c01034bd>] sysenter_do_call+0x12/0x35


Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
---
arch/x86/oprofile/op_model_p4.c | 4 ++++
1 file changed, 4 insertions(+)

Index: b/arch/x86/oprofile/op_model_p4.c
===================================================================
--- a/arch/x86/oprofile/op_model_p4.c 2008-11-24 06:20:04.000000000 +0900
+++ b/arch/x86/oprofile/op_model_p4.c 2008-11-24 06:29:09.000000000 +0900
@@ -399,6 +399,8 @@ static void p4_fill_in_addresses(struct
unsigned int i;
unsigned int addr, cccraddr, stag;

+ get_cpu();
+
setup_num_counters();
stag = get_stagger();

@@ -482,6 +484,8 @@ static void p4_fill_in_addresses(struct
msrs->controls[i++].addr = MSR_P4_CRU_ESCR5;
}
}
+
+ put_cpu();
}


Attachment: .config
Description: Binary data