Skip to content

Commit 3b051bb

Browse files
Yicong Yangwilldeacon
authored andcommitted
drivers/perf: hisi: Export associated CPUs of each PMU through sysfs
Although the event of the uncore PMU can only be opened on a single CPU, some PMU does have the affinity on a range of CPUs. For example the L3C PMU is associated to the CPUs sharing the L3T it monitors. Users may infer this affinity by the PMU name which may have SCCL ID and CCL ID encoded (for L3C etc), but it's not that straightforward. So export this information by adding an "associated_cpus" sysfs attribute then user can get this directly. Reviewed-by: Jonathan Cameron <Joanthan.Cameron@huawei.com> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20241210141525.37788-9-yangyicong@huawei.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 8688c01 commit 3b051bb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Documentation/admin-guide/perf/hisi-pmu.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ e.g. hisi_sccl1_hha0/rx_operations is RX_OPERATIONS event of HHA index #0 in
3535
SCCL ID #1.
3636

3737
The driver also provides a "cpumask" sysfs attribute, which shows the CPU core
38-
ID used to count the uncore PMU event.
38+
ID used to count the uncore PMU event. An "associated_cpus" sysfs attribute is
39+
also provided to show the CPUs associated with this PMU. The "cpumask" indicates
40+
the CPUs to open the events, usually as a hint for userspaces tools like perf.
41+
It only contains one associated CPU from the "associated_cpus".
3942

4043
Example usage of perf::
4144

drivers/perf/hisilicon/hisi_uncore_pmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ EXPORT_SYMBOL_NS_GPL(hisi_cpumask_sysfs_show, "HISI_PMU");
5151

5252
static DEVICE_ATTR(cpumask, 0444, hisi_cpumask_sysfs_show, NULL);
5353

54+
static ssize_t hisi_associated_cpus_sysfs_show(struct device *dev,
55+
struct device_attribute *attr, char *buf)
56+
{
57+
struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev));
58+
59+
return cpumap_print_to_pagebuf(true, buf, &hisi_pmu->associated_cpus);
60+
}
61+
static DEVICE_ATTR(associated_cpus, 0444, hisi_associated_cpus_sysfs_show, NULL);
62+
5463
static struct attribute *hisi_pmu_cpumask_attrs[] = {
5564
&dev_attr_cpumask.attr,
65+
&dev_attr_associated_cpus.attr,
5666
NULL
5767
};
5868

0 commit comments

Comments
 (0)