[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [XENOPROFILE] Fix incorrect use of on_each_cpu() which could lead



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 4fd6ba0e333673a275403867aebd805efc14d41d
# Parent  dc213d745642690b4bbc34af951e57f0d04c2d04
[XENOPROFILE] Fix incorrect use of on_each_cpu() which could lead
to sleep with interrupts disabled. 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.

Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
---
 linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c |   68 ++++++++-------------
 1 files changed, 26 insertions(+), 42 deletions(-)

diff -r dc213d745642 -r 4fd6ba0e3336 
linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c
--- a/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c        Mon May 15 
16:32:09 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c        Tue May 16 
09:08:06 2006 +0100
@@ -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();
-
-       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;
+       int i;
+
+       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;
 }
 
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.