linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint()
@ 2021-05-18  9:17 Thomas Gleixner
  2021-05-18  9:17 ` [patch 1/8] genirq: Export affinity setter for modules Thomas Gleixner
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

The modular PMU drivers use 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.

Sigh, if people would at least talk if something is missing...

Clean up the mess by exposing irq_set_affinity() and converting the drivers
over to that.

Thanks,

	tglx
---
 drivers/perf/arm-ccn.c                        |    6 +---
 drivers/perf/arm-cmn.c                        |    9 +-----
 drivers/perf/arm_dmc620_pmu.c                 |    5 +--
 drivers/perf/arm_dsu_pmu.c                    |    8 +----
 drivers/perf/arm_smmuv3_pmu.c                 |   10 ++-----
 drivers/perf/fsl_imx8_ddr_perf.c              |    5 +--
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c |    3 --
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  |    3 --
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  |    3 --
 drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   |    3 --
 drivers/perf/hisilicon/hisi_uncore_pmu.c      |    4 +-
 drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c |    3 --
 include/linux/interrupt.h                     |   35 +-------------------------
 kernel/irq/manage.c                           |   33 +++++++++++++++++++++++-
 14 files changed, 49 insertions(+), 81 deletions(-)


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 1/8] genirq: Export affinity setter for modules
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18  9:17 ` [patch 2/8] perf/arm-ccn: Use irq_set_affinity() Thomas Gleixner
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

Perf modules abuse irq_set_affinity_hint() to set the affinity of system
PMU interrupts just because irq_set_affinity() was not exported.

The fact that irq_set_affinity_hint() actually sets the affinity is a
non-documented side effect and the name is clearly saying it's a hint.

To clean this up, export the real affinity setter.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/interrupt.h |   35 ++---------------------------------
 kernel/irq/manage.c       |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 34 deletions(-)

--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -322,39 +322,8 @@ struct irq_affinity_desc {
 
 extern cpumask_var_t irq_default_affinity;
 
-/* Internal implementation. Use the helpers below */
-extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
-			      bool force);
-
-/**
- * irq_set_affinity - Set the irq affinity of a given irq
- * @irq:	Interrupt to set affinity
- * @cpumask:	cpumask
- *
- * Fails if cpumask does not contain an online CPU
- */
-static inline int
-irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
-{
-	return __irq_set_affinity(irq, cpumask, false);
-}
-
-/**
- * irq_force_affinity - Force the irq affinity of a given irq
- * @irq:	Interrupt to set affinity
- * @cpumask:	cpumask
- *
- * Same as irq_set_affinity, but without checking the mask against
- * online cpus.
- *
- * Solely for low level cpu hotplug code, where we need to make per
- * cpu interrupts affine before the cpu becomes online.
- */
-static inline int
-irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
-{
-	return __irq_set_affinity(irq, cpumask, true);
-}
+extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
+extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);
 
 extern int irq_can_set_affinity(unsigned int irq);
 extern int irq_select_affinity(unsigned int irq);
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -441,7 +441,8 @@ int irq_update_affinity_desc(unsigned in
 	return ret;
 }
 
-int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
+static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask,
+			      bool force)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
 	unsigned long flags;
@@ -456,6 +457,36 @@ int __irq_set_affinity(unsigned int irq,
 	return ret;
 }
 
+/**
+ * irq_set_affinity - Set the irq affinity of a given irq
+ * @irq:	Interrupt to set affinity
+ * @cpumask:	cpumask
+ *
+ * Fails if cpumask does not contain an online CPU
+ */
+int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+	return __irq_set_affinity(irq, cpumask, false);
+}
+EXPORT_SYMBOL_GPL(irq_set_affinity);
+
+/**
+ * irq_force_affinity - Force the irq affinity of a given irq
+ * @irq:	Interrupt to set affinity
+ * @cpumask:	cpumask
+ *
+ * Same as irq_set_affinity, but without checking the mask against
+ * online cpus.
+ *
+ * Solely for low level cpu hotplug code, where we need to make per
+ * cpu interrupts affine before the cpu becomes online.
+ */
+int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+	return __irq_set_affinity(irq, cpumask, true);
+}
+EXPORT_SYMBOL_GPL(irq_force_affinity);
+
 int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
 {
 	unsigned long flags;


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 2/8] perf/arm-ccn: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
  2021-05-18  9:17 ` [patch 1/8] genirq: Export affinity setter for modules Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18  9:17 ` [patch 3/8] perf/arm-cmn: " Thomas Gleixner
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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-ccn.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/perf/arm-ccn.c
+++ b/drivers/perf/arm-ccn.c
@@ -1211,7 +1211,7 @@ static int arm_ccn_pmu_offline_cpu(unsig
 	perf_pmu_migrate_context(&dt->pmu, cpu, target);
 	dt->cpu = target;
 	if (ccn->irq)
-		WARN_ON(irq_set_affinity_hint(ccn->irq, cpumask_of(dt->cpu)));
+		WARN_ON(irq_set_affinity(ccn->irq, cpumask_of(dt->cpu)));
 	return 0;
 }
 
@@ -1291,7 +1291,7 @@ static int arm_ccn_pmu_init(struct arm_c
 
 	/* Also make sure that the overflow interrupt is handled by this CPU */
 	if (ccn->irq) {
-		err = irq_set_affinity_hint(ccn->irq, cpumask_of(ccn->dt.cpu));
+		err = irq_set_affinity(ccn->irq, cpumask_of(ccn->dt.cpu));
 		if (err) {
 			dev_err(ccn->dev, "Failed to set interrupt affinity!\n");
 			goto error_set_affinity;
@@ -1325,8 +1325,6 @@ static void arm_ccn_pmu_cleanup(struct a
 
 	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
 					    &ccn->dt.node);
-	if (ccn->irq)
-		irq_set_affinity_hint(ccn->irq, NULL);
 	for (i = 0; i < ccn->num_xps; i++)
 		writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL);
 	writel(0, ccn->dt.base + CCN_DT_PMCR);


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 3/8] perf/arm-cmn: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
  2021-05-18  9:17 ` [patch 1/8] genirq: Export affinity setter for modules Thomas Gleixner
  2021-05-18  9:17 ` [patch 2/8] perf/arm-ccn: Use irq_set_affinity() Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18  9:17 ` [patch 4/8] perf/arm-dmc620: " Thomas Gleixner
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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-cmn.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -1162,7 +1162,7 @@ static int arm_cmn_pmu_offline_cpu(unsig
 
 	perf_pmu_migrate_context(&cmn->pmu, cpu, target);
 	for (i = 0; i < cmn->num_dtcs; i++)
-		irq_set_affinity_hint(cmn->dtc[i].irq, cpumask_of(target));
+		irq_set_affinity(cmn->dtc[i].irq, cpumask_of(target));
 	cmn->cpu = target;
 	return 0;
 }
@@ -1222,7 +1222,7 @@ static int arm_cmn_init_irqs(struct arm_
 		if (err)
 			return err;
 
-		err = irq_set_affinity_hint(irq, cpumask_of(cmn->cpu));
+		err = irq_set_affinity(irq, cpumask_of(cmn->cpu));
 		if (err)
 			return err;
 	next:
@@ -1568,16 +1568,11 @@ static int arm_cmn_probe(struct platform
 static int arm_cmn_remove(struct platform_device *pdev)
 {
 	struct arm_cmn *cmn = platform_get_drvdata(pdev);
-	int i;
 
 	writel_relaxed(0, cmn->dtc[0].base + CMN_DT_DTC_CTL);
 
 	perf_pmu_unregister(&cmn->pmu);
 	cpuhp_state_remove_instance(arm_cmn_hp_state, &cmn->cpuhp_node);
-
-	for (i = 0; i < cmn->num_dtcs; i++)
-		irq_set_affinity_hint(cmn->dtc[i].irq, NULL);
-
 	return 0;
 }
 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 4/8] perf/arm-dmc620: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (2 preceding siblings ...)
  2021-05-18  9:17 ` [patch 3/8] perf/arm-cmn: " Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18  9:17 ` [patch 5/8] perf/arm-dsu: " Thomas Gleixner
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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_dmc620_pmu.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/drivers/perf/arm_dmc620_pmu.c
+++ b/drivers/perf/arm_dmc620_pmu.c
@@ -421,7 +421,7 @@ static struct dmc620_pmu_irq *__dmc620_p
 	if (ret)
 		goto out_free_aff;
 
-	ret = irq_set_affinity_hint(irq_num, cpumask_of(irq->cpu));
+	ret = irq_set_affinity(irq_num, cpumask_of(irq->cpu));
 	if (ret)
 		goto out_free_irq;
 
@@ -475,7 +475,6 @@ static void dmc620_pmu_put_irq(struct dm
 	list_del(&irq->irqs_node);
 	mutex_unlock(&dmc620_pmu_irqs_lock);
 
-	WARN_ON(irq_set_affinity_hint(irq->irq_num, NULL));
 	free_irq(irq->irq_num, irq);
 	cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &irq->node);
 	kfree(irq);
@@ -622,7 +621,7 @@ static int dmc620_pmu_cpu_teardown(unsig
 		perf_pmu_migrate_context(&dmc620_pmu->pmu, irq->cpu, target);
 	mutex_unlock(&dmc620_pmu_irqs_lock);
 
-	WARN_ON(irq_set_affinity_hint(irq->irq_num, cpumask_of(target)));
+	WARN_ON(irq_set_affinity(irq->irq_num, cpumask_of(target)));
 	irq->cpu = target;
 
 	return 0;


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 5/8] perf/arm-dsu: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (3 preceding siblings ...)
  2021-05-18  9:17 ` [patch 4/8] perf/arm-dmc620: " Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18 11:31   ` John Garry
  2021-05-18  9:17 ` [patch 6/8] perf/arm-smmuv3: " Thomas Gleixner
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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(-)

--- 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);


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 6/8] perf/arm-smmuv3: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (4 preceding siblings ...)
  2021-05-18  9:17 ` [patch 5/8] perf/arm-dsu: " Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18  9:17 ` [patch 7/8] perf/imx_ddr: " Thomas Gleixner
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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_smmuv3_pmu.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -628,7 +628,7 @@ static int smmu_pmu_offline_cpu(unsigned
 
 	perf_pmu_migrate_context(&smmu_pmu->pmu, cpu, target);
 	smmu_pmu->on_cpu = target;
-	WARN_ON(irq_set_affinity_hint(smmu_pmu->irq, cpumask_of(target)));
+	WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(target)));
 
 	return 0;
 }
@@ -839,15 +839,14 @@ static int smmu_pmu_probe(struct platfor
 
 	/* Pick one CPU to be the preferred one to use */
 	smmu_pmu->on_cpu = raw_smp_processor_id();
-	WARN_ON(irq_set_affinity_hint(smmu_pmu->irq,
-				      cpumask_of(smmu_pmu->on_cpu)));
+	WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(smmu_pmu->on_cpu)));
 
 	err = cpuhp_state_add_instance_nocalls(cpuhp_state_num,
 					       &smmu_pmu->node);
 	if (err) {
 		dev_err(dev, "Error %d registering hotplug, PMU @%pa\n",
 			err, &res_0->start);
-		goto out_clear_affinity;
+		return err;
 	}
 
 	err = perf_pmu_register(&smmu_pmu->pmu, name, -1);
@@ -866,8 +865,6 @@ static int smmu_pmu_probe(struct platfor
 
 out_unregister:
 	cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
-out_clear_affinity:
-	irq_set_affinity_hint(smmu_pmu->irq, NULL);
 	return err;
 }
 
@@ -877,7 +874,6 @@ static int smmu_pmu_remove(struct platfo
 
 	perf_pmu_unregister(&smmu_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
-	irq_set_affinity_hint(smmu_pmu->irq, NULL);
 
 	return 0;
 }


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 7/8] perf/imx_ddr: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (5 preceding siblings ...)
  2021-05-18  9:17 ` [patch 6/8] perf/arm-smmuv3: " Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18  9:17 ` [patch 8/8] perf/hisi: " Thomas Gleixner
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Frank Li, Will Deacon, Mark Rutland, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-arm-kernel, Shaokun Zhang

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: Frank Li <Frank.li@nxp.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/perf/fsl_imx8_ddr_perf.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/drivers/perf/fsl_imx8_ddr_perf.c
+++ b/drivers/perf/fsl_imx8_ddr_perf.c
@@ -674,7 +674,7 @@ static int ddr_perf_offline_cpu(unsigned
 	perf_pmu_migrate_context(&pmu->pmu, cpu, target);
 	pmu->cpu = target;
 
-	WARN_ON(irq_set_affinity_hint(pmu->irq, cpumask_of(pmu->cpu)));
+	WARN_ON(irq_set_affinity(pmu->irq, cpumask_of(pmu->cpu)));
 
 	return 0;
 }
@@ -749,7 +749,7 @@ static int ddr_perf_probe(struct platfor
 	}
 
 	pmu->irq = irq;
-	ret = irq_set_affinity_hint(pmu->irq, cpumask_of(pmu->cpu));
+	ret = irq_set_affinity(pmu->irq, cpumask_of(pmu->cpu));
 	if (ret) {
 		dev_err(pmu->dev, "Failed to set interrupt affinity!\n");
 		goto ddr_perf_err;
@@ -777,7 +777,6 @@ static int ddr_perf_remove(struct platfo
 
 	cpuhp_state_remove_instance_nocalls(pmu->cpuhp_state, &pmu->node);
 	cpuhp_remove_multi_state(pmu->cpuhp_state);
-	irq_set_affinity_hint(pmu->irq, NULL);
 
 	perf_pmu_unregister(&pmu->pmu);
 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch 8/8] perf/hisi: Use irq_set_affinity()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (6 preceding siblings ...)
  2021-05-18  9:17 ` [patch 7/8] perf/imx_ddr: " Thomas Gleixner
@ 2021-05-18  9:17 ` Thomas Gleixner
  2021-05-18 10:11 ` [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Mark Rutland
  2021-05-18 10:48 ` Will Deacon
  9 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18  9:17 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Shaokun Zhang, Will Deacon, Mark Rutland,
	linux-arm-kernel, Frank Li, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team

These drivers use 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: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c |    3 ---
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  |    3 ---
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  |    3 ---
 drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   |    3 ---
 drivers/perf/hisilicon/hisi_uncore_pmu.c      |    4 ++--
 drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c |    3 ---
 6 files changed, 2 insertions(+), 17 deletions(-)

--- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
@@ -537,7 +537,6 @@ static int hisi_ddrc_pmu_probe(struct pl
 		dev_err(ddrc_pmu->dev, "DDRC PMU register failed!\n");
 		cpuhp_state_remove_instance_nocalls(
 			CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE, &ddrc_pmu->node);
-		irq_set_affinity_hint(ddrc_pmu->irq, NULL);
 	}
 
 	return ret;
@@ -550,8 +549,6 @@ static int hisi_ddrc_pmu_remove(struct p
 	perf_pmu_unregister(&ddrc_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE,
 					    &ddrc_pmu->node);
-	irq_set_affinity_hint(ddrc_pmu->irq, NULL);
-
 	return 0;
 }
 
--- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
@@ -540,7 +540,6 @@ static int hisi_hha_pmu_probe(struct pla
 		dev_err(hha_pmu->dev, "HHA PMU register failed!\n");
 		cpuhp_state_remove_instance_nocalls(
 			CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE, &hha_pmu->node);
-		irq_set_affinity_hint(hha_pmu->irq, NULL);
 	}
 
 	return ret;
@@ -553,8 +552,6 @@ static int hisi_hha_pmu_remove(struct pl
 	perf_pmu_unregister(&hha_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE,
 					    &hha_pmu->node);
-	irq_set_affinity_hint(hha_pmu->irq, NULL);
-
 	return 0;
 }
 
--- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
@@ -578,7 +578,6 @@ static int hisi_l3c_pmu_probe(struct pla
 		dev_err(l3c_pmu->dev, "L3C PMU register failed!\n");
 		cpuhp_state_remove_instance_nocalls(
 			CPUHP_AP_PERF_ARM_HISI_L3_ONLINE, &l3c_pmu->node);
-		irq_set_affinity_hint(l3c_pmu->irq, NULL);
 	}
 
 	return ret;
@@ -591,8 +590,6 @@ static int hisi_l3c_pmu_remove(struct pl
 	perf_pmu_unregister(&l3c_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_L3_ONLINE,
 					    &l3c_pmu->node);
-	irq_set_affinity_hint(l3c_pmu->irq, NULL);
-
 	return 0;
 }
 
--- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
@@ -436,7 +436,6 @@ static int hisi_pa_pmu_probe(struct plat
 		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
 		cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_PA_ONLINE,
 					    &pa_pmu->node);
-		irq_set_affinity_hint(pa_pmu->irq, NULL);
 		return ret;
 	}
 
@@ -451,8 +450,6 @@ static int hisi_pa_pmu_remove(struct pla
 	perf_pmu_unregister(&pa_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_PA_ONLINE,
 					    &pa_pmu->node);
-	irq_set_affinity_hint(pa_pmu->irq, NULL);
-
 	return 0;
 }
 
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
@@ -488,7 +488,7 @@ int hisi_uncore_pmu_online_cpu(unsigned
 	hisi_pmu->on_cpu = cpu;
 
 	/* Overflow interrupt also should use the same CPU */
-	WARN_ON(irq_set_affinity_hint(hisi_pmu->irq, cpumask_of(cpu)));
+	WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(cpu)));
 
 	return 0;
 }
@@ -521,7 +521,7 @@ int hisi_uncore_pmu_offline_cpu(unsigned
 	perf_pmu_migrate_context(&hisi_pmu->pmu, cpu, target);
 	/* Use this CPU for event counting */
 	hisi_pmu->on_cpu = target;
-	WARN_ON(irq_set_affinity_hint(hisi_pmu->irq, cpumask_of(target)));
+	WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(target)));
 
 	return 0;
 }
--- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
@@ -465,7 +465,6 @@ static int hisi_sllc_pmu_probe(struct pl
 		dev_err(sllc_pmu->dev, "PMU register failed, ret = %d\n", ret);
 		cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_SLLC_ONLINE,
 					    &sllc_pmu->node);
-		irq_set_affinity_hint(sllc_pmu->irq, NULL);
 		return ret;
 	}
 
@@ -481,8 +480,6 @@ static int hisi_sllc_pmu_remove(struct p
 	perf_pmu_unregister(&sllc_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_SLLC_ONLINE,
 					    &sllc_pmu->node);
-	irq_set_affinity_hint(sllc_pmu->irq, NULL);
-
 	return 0;
 }
 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (7 preceding siblings ...)
  2021-05-18  9:17 ` [patch 8/8] perf/hisi: " Thomas Gleixner
@ 2021-05-18 10:11 ` Mark Rutland
  2021-05-18 10:48 ` Will Deacon
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2021-05-18 10:11 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, linux-arm-kernel, Frank Li, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Shaokun Zhang

Hi Thomas,

On Tue, May 18, 2021 at 11:17:25AM +0200, Thomas Gleixner wrote:
> The modular PMU drivers use 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.
> 
> Sigh, if people would at least talk if something is missing...
> 
> Clean up the mess by exposing irq_set_affinity() and converting the drivers
> over to that.

Sorry about this, and thanks for cleaning this up.

For the series:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

> 
> Thanks,
> 
> 	tglx
> ---
>  drivers/perf/arm-ccn.c                        |    6 +---
>  drivers/perf/arm-cmn.c                        |    9 +-----
>  drivers/perf/arm_dmc620_pmu.c                 |    5 +--
>  drivers/perf/arm_dsu_pmu.c                    |    8 +----
>  drivers/perf/arm_smmuv3_pmu.c                 |   10 ++-----
>  drivers/perf/fsl_imx8_ddr_perf.c              |    5 +--
>  drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c |    3 --
>  drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  |    3 --
>  drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  |    3 --
>  drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   |    3 --
>  drivers/perf/hisilicon/hisi_uncore_pmu.c      |    4 +-
>  drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c |    3 --
>  include/linux/interrupt.h                     |   35 +-------------------------
>  kernel/irq/manage.c                           |   33 +++++++++++++++++++++++-
>  14 files changed, 49 insertions(+), 81 deletions(-)
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint()
  2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
                   ` (8 preceding siblings ...)
  2021-05-18 10:11 ` [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Mark Rutland
@ 2021-05-18 10:48 ` Will Deacon
  2021-05-18 15:51   ` Thomas Gleixner
  9 siblings, 1 reply; 16+ messages in thread
From: Will Deacon @ 2021-05-18 10:48 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Mark Rutland, linux-arm-kernel, Frank Li,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Shaokun Zhang

Hi Thomas,

On Tue, May 18, 2021 at 11:17:25AM +0200, Thomas Gleixner wrote:
> The modular PMU drivers use 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.
> 
> Sigh, if people would at least talk if something is missing...
> 
> Clean up the mess by exposing irq_set_affinity() and converting the drivers
> over to that.

This all looks good to me, thanks. Given the number of PMU drivers it
touches, it may well conflict with driver work for 5.14. If you put the
IRQ core stuff on a stable branch, then I could pull that into the Arm
perf tree and stick all the driver changes on top. That also means any
new drivers that come in can use irq_set_affinity() right away.

Does that work for you?

Cheers,

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 5/8] perf/arm-dsu: Use irq_set_affinity()
  2021-05-18  9:17 ` [patch 5/8] perf/arm-dsu: " Thomas Gleixner
@ 2021-05-18 11:31   ` John Garry
  2021-05-18 15:50     ` Thomas Gleixner
  0 siblings, 1 reply; 16+ messages in thread
From: John Garry @ 2021-05-18 11:31 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 5/8] perf/arm-dsu: Use irq_set_affinity()
  2021-05-18 11:31   ` John Garry
@ 2021-05-18 15:50     ` Thomas Gleixner
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18 15:50 UTC (permalink / raw)
  To: John Garry, LKML
  Cc: Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Will Deacon, Mark Rutland, linux-arm-kernel,
	Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint()
  2021-05-18 10:48 ` Will Deacon
@ 2021-05-18 15:51   ` Thomas Gleixner
  2021-05-19  9:08     ` Thomas Gleixner
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-18 15:51 UTC (permalink / raw)
  To: Will Deacon
  Cc: LKML, Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Mark Rutland, linux-arm-kernel, Frank Li,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Shaokun Zhang

On Tue, May 18 2021 at 11:48, Will Deacon wrote:
> On Tue, May 18, 2021 at 11:17:25AM +0200, Thomas Gleixner wrote:
>> The modular PMU drivers use 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.
>> 
>> Sigh, if people would at least talk if something is missing...
>> 
>> Clean up the mess by exposing irq_set_affinity() and converting the drivers
>> over to that.
>
> This all looks good to me, thanks. Given the number of PMU drivers it
> touches, it may well conflict with driver work for 5.14. If you put the
> IRQ core stuff on a stable branch, then I could pull that into the Arm
> perf tree and stick all the driver changes on top. That also means any
> new drivers that come in can use irq_set_affinity() right away.
>
> Does that work for you?

Sure. I'll send you a tag to pull ...

Thanks,

        tglx

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint()
  2021-05-18 15:51   ` Thomas Gleixner
@ 2021-05-19  9:08     ` Thomas Gleixner
  2021-05-24 20:20       ` Will Deacon
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Gleixner @ 2021-05-19  9:08 UTC (permalink / raw)
  To: Will Deacon
  Cc: LKML, Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Mark Rutland, linux-arm-kernel, Frank Li,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Shaokun Zhang

On Tue, May 18 2021 at 17:51, Thomas Gleixner wrote:
> Sure. I'll send you a tag to pull ...

Here you go:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq-export-set-affinity

Thanks,

        tglx

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint()
  2021-05-19  9:08     ` Thomas Gleixner
@ 2021-05-24 20:20       ` Will Deacon
  0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2021-05-24 20:20 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Peter Zijlstra, Robin Murphy, Nitesh Lal, Jesse Brandeburg,
	Marc Zyngier, Mark Rutland, linux-arm-kernel, Frank Li,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Shaokun Zhang

On Wed, May 19, 2021 at 11:08:30AM +0200, Thomas Gleixner wrote:
> On Tue, May 18 2021 at 17:51, Thomas Gleixner wrote:
> > Sure. I'll send you a tag to pull ...
> 
> Here you go:
> 
>    git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq-export-set-affinity

Cheers, I've pulled that in and stuck the driver patches on top.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-05-25  2:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  9:17 [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Thomas Gleixner
2021-05-18  9:17 ` [patch 1/8] genirq: Export affinity setter for modules Thomas Gleixner
2021-05-18  9:17 ` [patch 2/8] perf/arm-ccn: Use irq_set_affinity() Thomas Gleixner
2021-05-18  9:17 ` [patch 3/8] perf/arm-cmn: " Thomas Gleixner
2021-05-18  9:17 ` [patch 4/8] perf/arm-dmc620: " Thomas Gleixner
2021-05-18  9:17 ` [patch 5/8] perf/arm-dsu: " Thomas Gleixner
2021-05-18 11:31   ` John Garry
2021-05-18 15:50     ` Thomas Gleixner
2021-05-18  9:17 ` [patch 6/8] perf/arm-smmuv3: " Thomas Gleixner
2021-05-18  9:17 ` [patch 7/8] perf/imx_ddr: " Thomas Gleixner
2021-05-18  9:17 ` [patch 8/8] perf/hisi: " Thomas Gleixner
2021-05-18 10:11 ` [patch 0/8] genirq, perf: Cleanup the abuse of irq_set_affinity_hint() Mark Rutland
2021-05-18 10:48 ` Will Deacon
2021-05-18 15:51   ` Thomas Gleixner
2021-05-19  9:08     ` Thomas Gleixner
2021-05-24 20:20       ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).