ia64/xen-unstable

changeset 10062:4fd6ba0e3336

[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@redhat.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue May 16 09:08:06 2006 +0100 (2006-05-16)
parents dc213d745642
children 6a285d7d7b39
files linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Mon May 15 16:32:09 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Tue May 16 09:08:06 2006 +0100
     1.3 @@ -141,56 +141,40 @@ xenoprof_ovf_interrupt(int irq, void * d
     1.4  }
     1.5  
     1.6  
     1.7 -static void unbind_virq_cpu(void * info)
     1.8 -{
     1.9 -	int cpu = smp_processor_id();
    1.10 -	if (ovf_irq[cpu] >= 0) {
    1.11 -		unbind_from_irqhandler(ovf_irq[cpu], NULL);
    1.12 -		ovf_irq[cpu] = -1;
    1.13 -	}
    1.14 -}
    1.15 -
    1.16 -
    1.17  static void unbind_virq(void)
    1.18  {
    1.19 -	on_each_cpu(unbind_virq_cpu, NULL, 0, 1);
    1.20 -}
    1.21 -
    1.22 -
    1.23 -int bind_virq_error;
    1.24 -
    1.25 -static void bind_virq_cpu(void * info)
    1.26 -{
    1.27 -	int result;
    1.28 -	int cpu = smp_processor_id();
    1.29 +	int i;
    1.30  
    1.31 -	result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
    1.32 -					 cpu,
    1.33 -					 xenoprof_ovf_interrupt,
    1.34 -					 SA_INTERRUPT,
    1.35 -					 "xenoprof",
    1.36 -					 NULL);
    1.37 -
    1.38 -	if (result<0) {
    1.39 -		bind_virq_error = result;
    1.40 -		printk("xenoprof.c: binding VIRQ_XENOPROF to IRQ failed on CPU "
    1.41 -		       "%d\n", cpu);
    1.42 -	} else {
    1.43 -		ovf_irq[cpu] = result;
    1.44 +	for_each_cpu(i) {
    1.45 +		if (ovf_irq[i] >= 0) {
    1.46 +			unbind_from_irqhandler(ovf_irq[i], NULL);
    1.47 +			ovf_irq[i] = -1;
    1.48 +		}
    1.49  	}
    1.50  }
    1.51  
    1.52  
    1.53  static int bind_virq(void)
    1.54  {
    1.55 -	bind_virq_error = 0;
    1.56 -	on_each_cpu(bind_virq_cpu, NULL, 0, 1);
    1.57 -	if (bind_virq_error) {
    1.58 -		unbind_virq();
    1.59 -		return bind_virq_error;
    1.60 -	} else {
    1.61 -		return 0;
    1.62 +	int i, result;
    1.63 +
    1.64 +	for_each_cpu(i) {
    1.65 +		result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
    1.66 +						 i,
    1.67 +						 xenoprof_ovf_interrupt,
    1.68 +						 SA_INTERRUPT,
    1.69 +						 "xenoprof",
    1.70 +						 NULL);
    1.71 +
    1.72 +		if (result < 0) {
    1.73 +			unbind_virq();
    1.74 +			return result;
    1.75 +		}
    1.76 +
    1.77 +		ovf_irq[i] = result;
    1.78  	}
    1.79 +		
    1.80 +	return 0;
    1.81  }
    1.82  
    1.83