[PATCH 01/10] perf/alibaba_uncore_drw: Use correct CPU affinity

Robin Murphy robin.murphy at arm.com
Tue Mar 12 10:34:03 PDT 2024


Although this driver is trying to use the IRQ-multiplexing mechanism to
handle context migration correctly, it's failing to make events follow
the IRQ instance, instead forcing them onto a per-PMU CPU which is set
once at probe time then never maintained. Fix this by using the correct
CPU from the IRQ instance, and remove the erroneous per-PMU data plus
the redundant check which does not mean what it thinks it means.

CC: Shuai Xue <xueshuai at linux.alibaba.com>
Fixes: cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")
Signed-off-by: Robin Murphy <robin.murphy at arm.com>
---
 drivers/perf/alibaba_uncore_drw_pmu.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c
index 19d459a36be5..b37e9794823a 100644
--- a/drivers/perf/alibaba_uncore_drw_pmu.c
+++ b/drivers/perf/alibaba_uncore_drw_pmu.c
@@ -96,8 +96,6 @@ struct ali_drw_pmu {
 
 	struct list_head pmus_node;
 	struct ali_drw_pmu_irq *irq;
-	int irq_num;
-	int cpu;
 	DECLARE_BITMAP(used_mask, ALI_DRW_PMU_COMMON_MAX_COUNTERS);
 	struct perf_event *events[ALI_DRW_PMU_COMMON_MAX_COUNTERS];
 	int evtids[ALI_DRW_PMU_COMMON_MAX_COUNTERS];
@@ -221,7 +219,7 @@ static ssize_t ali_drw_pmu_cpumask_show(struct device *dev,
 {
 	struct ali_drw_pmu *drw_pmu = to_ali_drw_pmu(dev_get_drvdata(dev));
 
-	return cpumap_print_to_pagebuf(true, buf, cpumask_of(drw_pmu->cpu));
+	return cpumap_print_to_pagebuf(true, buf, cpumask_of(drw_pmu->irq->cpu));
 }
 
 static struct device_attribute ali_drw_pmu_cpumask_attr =
@@ -550,11 +548,7 @@ static int ali_drw_pmu_event_init(struct perf_event *event)
 		return -EOPNOTSUPP;
 	}
 
-	event->cpu = drw_pmu->cpu;
-	if (event->cpu < 0) {
-		dev_err(dev, "Per-task mode not supported!\n");
-		return -EOPNOTSUPP;
-	}
+	event->cpu = drw_pmu->irq->cpu;
 
 	if (event->group_leader != event &&
 	    !is_software_event(event->group_leader)) {
@@ -701,8 +695,6 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
 	/* clearing interrupt status */
 	writel(0xffffff, drw_pmu->cfg_base + ALI_DRW_PMU_OV_INTR_CLR);
 
-	drw_pmu->cpu = smp_processor_id();
-
 	ret = ali_drw_pmu_init_irq(drw_pmu, pdev);
 	if (ret)
 		return ret;
-- 
2.39.2.101.g768bb238c484.dirty




More information about the linux-arm-kernel mailing list