ARM: perf: set cpu affinity for the irqs correctly
authorSudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Tue, 25 Sep 2012 16:30:45 +0000 (17:30 +0100)
committerJon Medhurst <tixy@linaro.org>
Wed, 17 Jul 2013 10:12:04 +0000 (11:12 +0100)
This patch sets the cpu affinity for the perf IRQs in the logical order
within the cluster. However interupts are assumed to be specified in the
same logical order within the cluster.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
arch/arm/kernel/perf_event_cpu.c

index 725e225c84b7a9e7b983ed8b2fb3a2f27e1211d1..4b338b3bdacfcc398a88c3ffbe6837b5cf048684 100644 (file)
@@ -76,11 +76,13 @@ static void cpu_pmu_free_irq(struct arm_pmu *cpu_pmu)
 {
        int i, irq, irqs;
        struct platform_device *pmu_device = cpu_pmu->plat_device;
+       int cpu = -1;
 
        irqs = min(pmu_device->num_resources, num_possible_cpus());
 
        for (i = 0; i < irqs; ++i) {
-               if (!cpumask_test_and_clear_cpu(i, &cpu_pmu->active_irqs))
+               cpu = cpumask_next(cpu, &cpu_pmu->valid_cpus);
+               if (!cpumask_test_and_clear_cpu(cpu, &cpu_pmu->active_irqs))
                        continue;
                irq = platform_get_irq(pmu_device, i);
                if (irq >= 0)
@@ -92,6 +94,7 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
 {
        int i, err, irq, irqs;
        struct platform_device *pmu_device = cpu_pmu->plat_device;
+       int cpu = -1;
 
        if (!pmu_device)
                return -ENODEV;
@@ -104,6 +107,7 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
 
        for (i = 0; i < irqs; ++i) {
                err = 0;
+               cpu = cpumask_next(cpu, &cpu_pmu->valid_cpus);
                irq = platform_get_irq(pmu_device, i);
                if (irq < 0)
                        continue;
@@ -113,7 +117,7 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
                 * assume that we're running on a uniprocessor machine and
                 * continue. Otherwise, continue without this interrupt.
                 */
-               if (irq_set_affinity(irq, cpumask_of(i)) && irqs > 1) {
+               if (irq_set_affinity(irq, cpumask_of(cpu)) && irqs > 1) {
                        pr_warning("unable to set irq affinity (irq=%d, cpu=%u)\n",
                                    irq, i);
                        continue;
@@ -127,7 +131,7 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
                        return err;
                }
 
-               cpumask_set_cpu(i, &cpu_pmu->active_irqs);
+               cpumask_set_cpu(cpu, &cpu_pmu->active_irqs);
        }
 
        return 0;