Skip to contentSkip to conversation

ARM: perf: ensure the cpu is available to scheduler when set irq affinity

PATCH In review [email protected] 2 participants 3 messages Oct 21, 2015 – Oct 28, 2015 Arm PMU profiling and debugging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: perf: ensure the cpu is available to scheduler when set irq affinity

From: Li RongQing <[email protected]>

when there are 4 cpus, but only one is available to schedule, the warning will be generated when run the below command:

    # perf record -g -e cpu-clock -- find / -name "*.ko"
    CPU PMU: unable to set irq affinity (irq=28, cpu=1)
    CPU PMU: unable to set irq affinity (irq=29, cpu=2)
    CPU PMU: unable to set irq affinity (irq=30, cpu=3)

so ensure the cpu is available to scheduler when set irq affinity

---
 drivers/perf/arm_pmu.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/perf/arm_pmu.c +6 -0
index 2365a32..9401aa8 100644
@@ -619,6 +619,9 @@ static void cpu_pmu_free_irq(struct arm_pmu *cpu_pmu)
 			if (cpu_pmu->irq_affinity)
 				cpu = cpu_pmu->irq_affinity[i];
 
+			if (!cpu_online(cpu))
+				continue;
+
 			if (!cpumask_test_and_clear_cpu(cpu, &cpu_pmu->active_irqs))
 				continue;
 			irq = platform_get_irq(pmu_device, i);
@@ -665,6 +668,9 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
 			if (cpu_pmu->irq_affinity)
 				cpu = cpu_pmu->irq_affinity[i];
 
+			if (!cpu_online(cpu))
+				continue;
+
 			/*
 			 * If we have a single PMU interrupt that we can't shift,
 			 * assume that we're running on a uniprocessor machine and
Signature · 1 line
2.1.4
#1 lore raw
Quoted 31 lines · On Wed, Oct 21, 2015 at 03:56:02PM +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

when there are 4 cpus, but only one is available to schedule, the warning will be generated when run the below command:

    # perf record -g -e cpu-clock -- find / -name "*.ko"
    CPU PMU: unable to set irq affinity (irq=28, cpu=1)
    CPU PMU: unable to set irq affinity (irq=29, cpu=2)
    CPU PMU: unable to set irq affinity (irq=30, cpu=3)

so ensure the cpu is available to scheduler when set irq affinity

---
 drivers/perf/arm_pmu.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/perf/arm_pmu.c +3 -0
index 2365a32..9401aa8 100644
@@ -619,6 +619,9 @@ static void cpu_pmu_free_irq(struct arm_pmu *cpu_pmu)
 			if (cpu_pmu->irq_affinity)
 				cpu = cpu_pmu->irq_affinity[i];
 
+			if (!cpu_online(cpu))
+				continue;
+
 			if (!cpumask_test_and_clear_cpu(cpu, &cpu_pmu->active_irqs))
 				continue;
 			irq = platform_get_irq(pmu_device, i);

drivers/perf/arm_pmu.c static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler) · line 673

Quoted 6 lines
drivers/perf/arm_pmu.c +3 -0
@@ -665,6 +668,9 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
 			if (cpu_pmu->irq_affinity)
 				cpu = cpu_pmu->irq_affinity[i];
 
+			if (!cpu_online(cpu))
+				continue;
+

Isn't this all racy against concurrent hotplug events? We're probably better off requesting the IRQs at PMU probe time, since we no longer have to worry about sharing the IRQ lines with other subsystems such as oprofile, which is why it was designed this way originally.

Will

#2 lore raw
Quoted 7 lines · Will Deacon

Review

Quoted 2 lines
(quoted diff) +2 -0
+                             continue;
+

Isn't this all racy against concurrent hotplug events? We're probably better off requesting the IRQs at PMU probe time, since we no longer have to worry about sharing the IRQ lines with other subsystems such as oprofile, which is why it was designed this way originally.

Could you write a patch?
Thanks

-Roy