Skip to content

Commit 6320e69

Browse files
athira-rajeevmpe
authored andcommitted
powerpc/perf: Add support for caps under sysfs in powerpc
Add caps support under "/sys/bus/event_source/devices/<pmu>/" for powerpc. This directory can be used to expose some of the specific features that powerpc PMU supports to the user. Example: pmu_name. The name of PMU registered will depend on platform, say power9 or power10 or it could be Generic Compat PMU. Currently the only way to know which is the registered PMU is from the dmesg logs. But clearing the dmesg will make it difficult to know exact PMU backend used. And even extracting from dmesg will be complicated, as we need to parse the dmesg logs and add filters for pmu name. Whereas by exposing it via caps will make it easy as we just need to directly read it from the sysfs. Add a caps directory to /sys/bus/event_source/devices/cpu/ for power8, power9, power10 and generic compat PMU in respective PMU driver code. Update the pmu_name file under caps folder in core-book3s using "attr_update". The information exposed currently: - pmu_name : Underlying PMU name from the driver Example result with power9 pmu: # ls /sys/bus/event_source/devices/cpu/caps pmu_name # cat /sys/bus/event_source/devices/cpu/caps/pmu_name POWER9 Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220520084630.15181-1-atrajeev@linux.vnet.ibm.com
1 parent 78988b2 commit 6320e69

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

arch/powerpc/perf/core-book3s.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
24832483
return 0;
24842484
}
24852485

2486+
static ssize_t pmu_name_show(struct device *cdev,
2487+
struct device_attribute *attr,
2488+
char *buf)
2489+
{
2490+
if (ppmu)
2491+
return sysfs_emit(buf, "%s", ppmu->name);
2492+
2493+
return 0;
2494+
}
2495+
2496+
static DEVICE_ATTR_RO(pmu_name);
2497+
2498+
static struct attribute *pmu_caps_attrs[] = {
2499+
&dev_attr_pmu_name.attr,
2500+
NULL
2501+
};
2502+
2503+
static const struct attribute_group pmu_caps_group = {
2504+
.name = "caps",
2505+
.attrs = pmu_caps_attrs,
2506+
};
2507+
2508+
static const struct attribute_group *pmu_caps_groups[] = {
2509+
&pmu_caps_group,
2510+
NULL,
2511+
};
2512+
24862513
int __init register_power_pmu(struct power_pmu *pmu)
24872514
{
24882515
if (ppmu)
@@ -2493,6 +2520,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
24932520
pmu->name);
24942521

24952522
power_pmu.attr_groups = ppmu->attr_groups;
2523+
2524+
if (ppmu->flags & PPMU_ARCH_207S)
2525+
power_pmu.attr_update = pmu_caps_groups;
2526+
24962527
power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
24972528

24982529
#ifdef MSR_HV

arch/powerpc/perf/generic-compat-pmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
151151
.attrs = generic_compat_pmu_format_attr,
152152
};
153153

154+
static struct attribute *generic_compat_pmu_caps_attrs[] = {
155+
NULL
156+
};
157+
158+
static struct attribute_group generic_compat_pmu_caps_group = {
159+
.name = "caps",
160+
.attrs = generic_compat_pmu_caps_attrs,
161+
};
162+
154163
static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
155164
&generic_compat_pmu_format_group,
156165
&generic_compat_pmu_events_group,
166+
&generic_compat_pmu_caps_group,
157167
NULL,
158168
};
159169

arch/powerpc/perf/power10-pmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
258258
.attrs = power10_pmu_format_attr,
259259
};
260260

261+
static struct attribute *power10_pmu_caps_attrs[] = {
262+
NULL
263+
};
264+
265+
static struct attribute_group power10_pmu_caps_group = {
266+
.name = "caps",
267+
.attrs = power10_pmu_caps_attrs,
268+
};
269+
261270
static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
262271
&power10_pmu_format_group,
263272
&power10_pmu_events_group_dd1,
@@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
267276
static const struct attribute_group *power10_pmu_attr_groups[] = {
268277
&power10_pmu_format_group,
269278
&power10_pmu_events_group,
279+
&power10_pmu_caps_group,
270280
NULL,
271281
};
272282

arch/powerpc/perf/power8-pmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
187187
.attrs = power8_events_attr,
188188
};
189189

190+
static struct attribute *power8_pmu_caps_attrs[] = {
191+
NULL
192+
};
193+
194+
static struct attribute_group power8_pmu_caps_group = {
195+
.name = "caps",
196+
.attrs = power8_pmu_caps_attrs,
197+
};
198+
190199
static const struct attribute_group *power8_pmu_attr_groups[] = {
191200
&isa207_pmu_format_group,
192201
&power8_pmu_events_group,
202+
&power8_pmu_caps_group,
193203
NULL,
194204
};
195205

arch/powerpc/perf/power9-pmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
258258
.attrs = power9_pmu_format_attr,
259259
};
260260

261+
static struct attribute *power9_pmu_caps_attrs[] = {
262+
NULL
263+
};
264+
265+
static struct attribute_group power9_pmu_caps_group = {
266+
.name = "caps",
267+
.attrs = power9_pmu_caps_attrs,
268+
};
269+
261270
static const struct attribute_group *power9_pmu_attr_groups[] = {
262271
&power9_pmu_format_group,
263272
&power9_pmu_events_group,
273+
&power9_pmu_caps_group,
264274
NULL,
265275
};
266276

0 commit comments

Comments
 (0)