From: Markus Armbruster <armbru@redhat.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 1/3] xenoprof fixes: sleep with interrupts disabled
Date: Mon, 15 May 2006 18:31:59 +0200 [thread overview]
Message-ID: <87d5ef2qrk.fsf@pike.pond.sub.org> (raw)
In-Reply-To: <87hd3r2qst.fsf@pike.pond.sub.org> (Markus Armbruster's message of "Mon, 15 May 2006 18:31:14 +0200")
Ill-advised use of on_each_cpu() can lead to sleep with interrupts
disabled. This is best explained with a backtrace:
BUG: sleeping function called from invalid context at /home/armbru/linux-2.6.tip-xen-quintela.hg/mm/slab.c:2783
in_atomic():0, irqs_disabled():1
[<c0104f36>] show_trace+0x13/0x15
[<c0105439>] dump_stack+0x18/0x1c
[<c01161ac>] __might_sleep+0x9f/0xa7
[<c0158823>] __kmalloc+0x65/0x110
[<c018e01d>] proc_create+0x8d/0xe2
[<c018e12d>] proc_mkdir_mode+0x1a/0x4d
[<c018e173>] proc_mkdir+0x13/0x15
[<c013de9b>] register_handler_proc+0x90/0x9e
[<c013d729>] setup_irq+0xdf/0xf5
[<c013d7a9>] request_irq+0x6a/0x8a
[<c0231817>] bind_virq_to_irqhandler+0xe3/0x101
[<f4c83b02>] bind_virq_cpu+0x28/0x62 [oprofile]
[<c0121453>] on_each_cpu+0x36/0x5d
[<f4c83c3b>] xenoprof_setup+0x22/0x14a [oprofile]
[<f4c820bf>] oprofile_setup+0x45/0x8b [oprofile]
[<f4c82fa3>] event_buffer_open+0x3e/0x62 [oprofile]
[<c0159eda>] __dentry_open+0xc7/0x1b0
[<c015a034>] nameidata_to_filp+0x20/0x34
[<c015a078>] do_filp_open+0x30/0x39
[<c015afe6>] do_sys_open+0x40/0xb0
[<c015b07f>] sys_open+0x13/0x15
[<c01048cf>] syscall_call+0x7/0xb
on_each_cpu() disables interrupts. proc_create() calls passes
GFP_KERNEL to kmalloc().
The patch converts from on_each_cpu() to for_each_cpu(), and then
simplifies things.
diff -rup linux-2.6.16.13-xen/arch/i386/oprofile/xenoprof.c linux-2.6.16.13-xen.patched-1/arch/i386/oprofile/xenoprof.c
--- linux-2.6.16.13-xen/arch/i386/oprofile/xenoprof.c 2006-05-15 10:32:22.000000000 +0200
+++ linux-2.6.16.13-xen.patched-1/arch/i386/oprofile/xenoprof.c 2006-05-15 10:30:49.000000000 +0200
@@ -141,56 +141,40 @@ xenoprof_ovf_interrupt(int irq, void * d
}
-static void unbind_virq_cpu(void * info)
-{
- int cpu = smp_processor_id();
- if (ovf_irq[cpu] >= 0) {
- unbind_from_irqhandler(ovf_irq[cpu], NULL);
- ovf_irq[cpu] = -1;
- }
-}
-
-
static void unbind_virq(void)
{
- on_each_cpu(unbind_virq_cpu, NULL, 0, 1);
-}
-
-
-int bind_virq_error;
-
-static void bind_virq_cpu(void * info)
-{
- int result;
- int cpu = smp_processor_id();
+ int i;
- result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
- cpu,
- xenoprof_ovf_interrupt,
- SA_INTERRUPT,
- "xenoprof",
- NULL);
-
- if (result<0) {
- bind_virq_error = result;
- printk("xenoprof.c: binding VIRQ_XENOPROF to IRQ failed on CPU "
- "%d\n", cpu);
- } else {
- ovf_irq[cpu] = result;
+ for_each_cpu(i) {
+ if (ovf_irq[i] >= 0) {
+ unbind_from_irqhandler(ovf_irq[i], NULL);
+ ovf_irq[i] = -1;
+ }
}
}
static int bind_virq(void)
{
- bind_virq_error = 0;
- on_each_cpu(bind_virq_cpu, NULL, 0, 1);
- if (bind_virq_error) {
- unbind_virq();
- return bind_virq_error;
- } else {
- return 0;
+ int i, result;
+
+ for_each_cpu(i) {
+ result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
+ i,
+ xenoprof_ovf_interrupt,
+ SA_INTERRUPT,
+ "xenoprof",
+ NULL);
+
+ if (result < 0) {
+ unbind_virq();
+ return result;
+ }
+
+ ovf_irq[i] = result;
}
+
+ return 0;
}
next prev parent reply other threads:[~2006-05-15 16:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-15 16:31 [PATCH 0/3] xenoprof fixes Markus Armbruster
2006-05-15 16:31 ` Markus Armbruster [this message]
2006-05-15 17:33 ` [PATCH 1/3] xenoprof fixes: sleep with interrupts disabled Markus Armbruster
2006-05-16 8:06 ` Keir Fraser
2006-05-15 16:32 ` [PATCH 2/3] xenoprof fixes: active_domains races Markus Armbruster
2006-05-15 17:34 ` Markus Armbruster
2006-05-16 8:09 ` Keir Fraser
2006-05-16 9:47 ` Markus Armbruster
2006-05-16 9:48 ` Keir Fraser
2006-05-16 11:47 ` Markus Armbruster
2006-05-16 11:48 ` [PATCH] xenoprof fixes: active_domains races & cleanup Markus Armbruster
2006-05-15 18:53 ` [PATCH 2/3] xenoprof fixes: active_domains races Chris Wright
2006-05-15 19:15 ` Markus Armbruster
2006-05-15 21:51 ` Santos, Jose Renato G
2006-05-16 7:23 ` Chris Wright
2006-05-16 7:40 ` Keir Fraser
2006-05-15 16:33 ` [PATCH 3/3] xenoprof fixes: active_domains cleanup Markus Armbruster
2006-05-15 17:34 ` Markus Armbruster
2006-05-15 16:55 ` [PATCH 0/3] xenoprof fixes Keir Fraser
2006-05-15 17:14 ` Markus Armbruster
2006-05-15 17:19 ` Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d5ef2qrk.fsf@pike.pond.sub.org \
--to=armbru@redhat.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.