diff mbox series

[5/8] perf/arm-dsu: Use irq_set_affinity()

Message ID 20210518093118.505110632@linutronix.de (mailing list archive)
State New, archived
Headers show
Series genirq, perf: Cleanup the abuse of irq_set_affinity_hint() | expand

Commit Message

Thomas Gleixner May 18, 2021, 9:17 a.m. UTC
The driver uses irq_set_affinity_hint() to set the affinity for the PMU
interrupts, which relies on the undocumented side effect that this function
actually sets the affinity under the hood.

Setting an hint is clearly not a guarantee and for these PMU interrupts an
affinity hint, which is supposed to guide userspace for setting affinity,
is beyond pointless, because the affinity of these interrupts cannot be
modified from user space.

Aside of that the error checks are bogus because the only error which is
returned from irq_set_affinity_hint() is when there is no irq descriptor
for the interrupt number, but not when the affinity set fails. That's on
purpose because the hint can point to an offline CPU.

Replace the mindless abuse with irq_set_affinity().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/perf/arm_dsu_pmu.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

John Garry May 18, 2021, 11:31 a.m. UTC | #1
On 18/05/2021 10:17, Thomas Gleixner wrote:
>   
> @@ -769,7 +769,6 @@ static int dsu_pmu_device_probe(struct p
>   	if (rc) {

nit: I think that someone will send a patch to remove these {} later...

>   		cpuhp_state_remove_instance(dsu_pmu_cpuhp_state,
>   						 &dsu_pmu->cpuhp_node);
> -		irq_set_affinity_hint(dsu_pmu->irq, NULL);
>   	}

Thanks,
John
Thomas Gleixner May 18, 2021, 3:50 p.m. UTC | #2
On Tue, May 18 2021 at 12:31, John Garry wrote:
> On 18/05/2021 10:17, Thomas Gleixner wrote:
>>   
>> @@ -769,7 +769,6 @@ static int dsu_pmu_device_probe(struct p
>>   	if (rc) {
>
> nit: I think that someone will send a patch to remove these {} later...
>
>>   		cpuhp_state_remove_instance(dsu_pmu_cpuhp_state,
>>   						 &dsu_pmu->cpuhp_node);
>> -		irq_set_affinity_hint(dsu_pmu->irq, NULL);
>>   	}

which should be rejected because

		cpuhp_state_remove_instance(dsu_pmu_cpuhp_state,
  					    &dsu_pmu->cpuhp_node);

is _NOT_ a one line statement.

	if (foo)
		cpuhp_state_remove_instance(state, &node);

is fine, but

	if (foo)
		cpuhp_state_remove_instance(dsu_pmu_cpuhp_state,
  					    &dsu_pmu->cpuhp_node);

breaks the expectation of a single line following the condition which
confuses my brain based OCR. :)

So I left the brackets there on purpose.

Thanks,

        tglx
diff mbox series

Patch

--- a/drivers/perf/arm_dsu_pmu.c
+++ b/drivers/perf/arm_dsu_pmu.c
@@ -687,7 +687,7 @@  static void dsu_pmu_probe_pmu(struct dsu
 static void dsu_pmu_set_active_cpu(int cpu, struct dsu_pmu *dsu_pmu)
 {
 	cpumask_set_cpu(cpu, &dsu_pmu->active_cpu);
-	if (irq_set_affinity_hint(dsu_pmu->irq, &dsu_pmu->active_cpu))
+	if (irq_set_affinity(dsu_pmu->irq, &dsu_pmu->active_cpu))
 		pr_warn("Failed to set irq affinity to %d\n", cpu);
 }
 
@@ -769,7 +769,6 @@  static int dsu_pmu_device_probe(struct p
 	if (rc) {
 		cpuhp_state_remove_instance(dsu_pmu_cpuhp_state,
 						 &dsu_pmu->cpuhp_node);
-		irq_set_affinity_hint(dsu_pmu->irq, NULL);
 	}
 
 	return rc;
@@ -781,7 +780,6 @@  static int dsu_pmu_device_remove(struct
 
 	perf_pmu_unregister(&dsu_pmu->pmu);
 	cpuhp_state_remove_instance(dsu_pmu_cpuhp_state, &dsu_pmu->cpuhp_node);
-	irq_set_affinity_hint(dsu_pmu->irq, NULL);
 
 	return 0;
 }
@@ -840,10 +838,8 @@  static int dsu_pmu_cpu_teardown(unsigned
 
 	dst = dsu_pmu_get_online_cpu_any_but(dsu_pmu, cpu);
 	/* If there are no active CPUs in the DSU, leave IRQ disabled */
-	if (dst >= nr_cpu_ids) {
-		irq_set_affinity_hint(dsu_pmu->irq, NULL);
+	if (dst >= nr_cpu_ids)
 		return 0;
-	}
 
 	perf_pmu_migrate_context(&dsu_pmu->pmu, cpu, dst);
 	dsu_pmu_set_active_cpu(dst, dsu_pmu);