Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf/arm-cmn: Fix PMU instance naming

Although it's neat to avoid the suffix for the typical case of a
single PMU, it means systems with multiple CMN instances end up with
inconsistent naming. I think it also breaks perf tool's "uncore alias"
logic if the common instance prefix is also the full name of one.

Avoid any surprises by not trying to be clever and simply numbering
every instance, even when it might technically prove redundant.

Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/649a2281233f193d59240b13ed91b57337c77b32.1611839564.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Robin Murphy and committed by
Will Deacon
79d7c3dc f0c14048

+5 -10
+1 -1
Documentation/admin-guide/perf/arm-cmn.rst
··· 17 17 ---------- 18 18 19 19 The PMU driver registers a single PMU device for the whole interconnect, 20 - see /sys/bus/event_source/devices/arm_cmn. Multi-chip systems may link 20 + see /sys/bus/event_source/devices/arm_cmn_0. Multi-chip systems may link 21 21 more than one CMN together via external CCIX links - in this situation, 22 22 each mesh counts its own events entirely independently, and additional 23 23 PMU devices will be named arm_cmn_{1..n}.
+4 -9
drivers/perf/arm-cmn.c
··· 1502 1502 struct arm_cmn *cmn; 1503 1503 const char *name; 1504 1504 static atomic_t id; 1505 - int err, rootnode, this_id; 1505 + int err, rootnode; 1506 1506 1507 1507 cmn = devm_kzalloc(&pdev->dev, sizeof(*cmn), GFP_KERNEL); 1508 1508 if (!cmn) ··· 1549 1549 .cancel_txn = arm_cmn_end_txn, 1550 1550 }; 1551 1551 1552 - this_id = atomic_fetch_inc(&id); 1553 - if (this_id == 0) { 1554 - name = "arm_cmn"; 1555 - } else { 1556 - name = devm_kasprintf(cmn->dev, GFP_KERNEL, "arm_cmn_%d", this_id); 1557 - if (!name) 1558 - return -ENOMEM; 1559 - } 1552 + name = devm_kasprintf(cmn->dev, GFP_KERNEL, "arm_cmn_%d", atomic_fetch_inc(&id)); 1553 + if (!name) 1554 + return -ENOMEM; 1560 1555 1561 1556 err = cpuhp_state_add_instance(arm_cmn_hp_state, &cmn->cpuhp_node); 1562 1557 if (err)