All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
@ 2022-05-18  8:55 ` Athira Rajeev
  0 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-18  8:55 UTC (permalink / raw)
  To: acme, jolsa, mpe
  Cc: linux-perf-users, linuxppc-dev, linux-kernel, maddy, rnsastry,
	kjain, disgoel, irogers

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>
---
Changelog:
 v1 -> v2:
 Move the show function as generic in core-book3s
 and update show function using sysfs_emit and ppmu->name
 Added Documention for this ABI in patch 2.
 Notes: The caps directory is implemented in PMU for other
 architectures already. Reference commit for x86:
 commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")

 arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
 arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
 arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
 arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
 arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
 5 files changed, 71 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index b5b42cf0a703..a208f502a80b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
 	return 0;
 }
 
+static ssize_t pmu_name_show(struct device *cdev,
+		struct device_attribute *attr,
+		char *buf)
+{
+	if (ppmu)
+		return sysfs_emit(buf, "%s\n", ppmu->name);
+
+	return 0;
+}
+
+static DEVICE_ATTR_RO(pmu_name);
+
+static struct attribute *pmu_caps_attrs[] = {
+	&dev_attr_pmu_name.attr,
+	NULL
+};
+
+static const struct attribute_group pmu_caps_group = {
+	.name  = "caps",
+	.attrs = pmu_caps_attrs,
+};
+
+static const struct attribute_group *pmu_caps_groups[] = {
+	&pmu_caps_group,
+	NULL,
+};
+
 int __init register_power_pmu(struct power_pmu *pmu)
 {
 	if (ppmu)
@@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
 		pmu->name);
 
 	power_pmu.attr_groups = ppmu->attr_groups;
+
+	if (ppmu->flags & PPMU_ARCH_207S)
+		power_pmu.attr_update = pmu_caps_groups;
+
 	power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
 
 #ifdef MSR_HV
diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
index f3db88aee4dd..817c69863038 100644
--- a/arch/powerpc/perf/generic-compat-pmu.c
+++ b/arch/powerpc/perf/generic-compat-pmu.c
@@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
 	.attrs = generic_compat_pmu_format_attr,
 };
 
+static struct attribute *generic_compat_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group generic_compat_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = generic_compat_pmu_caps_attrs,
+};
+
 static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
 	&generic_compat_pmu_format_group,
 	&generic_compat_pmu_events_group,
+	&generic_compat_pmu_caps_group,
 	NULL,
 };
 
diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
index c6d51e7093cf..d1adcd9f52e2 100644
--- a/arch/powerpc/perf/power10-pmu.c
+++ b/arch/powerpc/perf/power10-pmu.c
@@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
 	.attrs = power10_pmu_format_attr,
 };
 
+static struct attribute *power10_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group power10_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = power10_pmu_caps_attrs,
+};
+
 static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
 	&power10_pmu_format_group,
 	&power10_pmu_events_group_dd1,
@@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
 static const struct attribute_group *power10_pmu_attr_groups[] = {
 	&power10_pmu_format_group,
 	&power10_pmu_events_group,
+	&power10_pmu_caps_group,
 	NULL,
 };
 
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index e37b1e714d2b..2518f5375d4a 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
 	.attrs = power8_events_attr,
 };
 
+static struct attribute *power8_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group power8_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = power8_pmu_caps_attrs,
+};
+
 static const struct attribute_group *power8_pmu_attr_groups[] = {
 	&isa207_pmu_format_group,
 	&power8_pmu_events_group,
+	&power8_pmu_caps_group,
 	NULL,
 };
 
diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
index c393e837648e..5c654ce1a417 100644
--- a/arch/powerpc/perf/power9-pmu.c
+++ b/arch/powerpc/perf/power9-pmu.c
@@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
 	.attrs = power9_pmu_format_attr,
 };
 
+static struct attribute *power9_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group power9_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = power9_pmu_caps_attrs,
+};
+
 static const struct attribute_group *power9_pmu_attr_groups[] = {
 	&power9_pmu_format_group,
 	&power9_pmu_events_group,
+	&power9_pmu_caps_group,
 	NULL,
 };
 
-- 
2.31.1


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

* [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
@ 2022-05-18  8:55 ` Athira Rajeev
  0 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-18  8:55 UTC (permalink / raw)
  To: acme, jolsa, mpe
  Cc: irogers, maddy, rnsastry, kjain, linux-kernel, linux-perf-users,
	disgoel, linuxppc-dev

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>
---
Changelog:
 v1 -> v2:
 Move the show function as generic in core-book3s
 and update show function using sysfs_emit and ppmu->name
 Added Documention for this ABI in patch 2.
 Notes: The caps directory is implemented in PMU for other
 architectures already. Reference commit for x86:
 commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")

 arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
 arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
 arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
 arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
 arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
 5 files changed, 71 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index b5b42cf0a703..a208f502a80b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
 	return 0;
 }
 
+static ssize_t pmu_name_show(struct device *cdev,
+		struct device_attribute *attr,
+		char *buf)
+{
+	if (ppmu)
+		return sysfs_emit(buf, "%s\n", ppmu->name);
+
+	return 0;
+}
+
+static DEVICE_ATTR_RO(pmu_name);
+
+static struct attribute *pmu_caps_attrs[] = {
+	&dev_attr_pmu_name.attr,
+	NULL
+};
+
+static const struct attribute_group pmu_caps_group = {
+	.name  = "caps",
+	.attrs = pmu_caps_attrs,
+};
+
+static const struct attribute_group *pmu_caps_groups[] = {
+	&pmu_caps_group,
+	NULL,
+};
+
 int __init register_power_pmu(struct power_pmu *pmu)
 {
 	if (ppmu)
@@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
 		pmu->name);
 
 	power_pmu.attr_groups = ppmu->attr_groups;
+
+	if (ppmu->flags & PPMU_ARCH_207S)
+		power_pmu.attr_update = pmu_caps_groups;
+
 	power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
 
 #ifdef MSR_HV
diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
index f3db88aee4dd..817c69863038 100644
--- a/arch/powerpc/perf/generic-compat-pmu.c
+++ b/arch/powerpc/perf/generic-compat-pmu.c
@@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
 	.attrs = generic_compat_pmu_format_attr,
 };
 
+static struct attribute *generic_compat_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group generic_compat_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = generic_compat_pmu_caps_attrs,
+};
+
 static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
 	&generic_compat_pmu_format_group,
 	&generic_compat_pmu_events_group,
+	&generic_compat_pmu_caps_group,
 	NULL,
 };
 
diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
index c6d51e7093cf..d1adcd9f52e2 100644
--- a/arch/powerpc/perf/power10-pmu.c
+++ b/arch/powerpc/perf/power10-pmu.c
@@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
 	.attrs = power10_pmu_format_attr,
 };
 
+static struct attribute *power10_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group power10_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = power10_pmu_caps_attrs,
+};
+
 static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
 	&power10_pmu_format_group,
 	&power10_pmu_events_group_dd1,
@@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
 static const struct attribute_group *power10_pmu_attr_groups[] = {
 	&power10_pmu_format_group,
 	&power10_pmu_events_group,
+	&power10_pmu_caps_group,
 	NULL,
 };
 
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index e37b1e714d2b..2518f5375d4a 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
 	.attrs = power8_events_attr,
 };
 
+static struct attribute *power8_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group power8_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = power8_pmu_caps_attrs,
+};
+
 static const struct attribute_group *power8_pmu_attr_groups[] = {
 	&isa207_pmu_format_group,
 	&power8_pmu_events_group,
+	&power8_pmu_caps_group,
 	NULL,
 };
 
diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
index c393e837648e..5c654ce1a417 100644
--- a/arch/powerpc/perf/power9-pmu.c
+++ b/arch/powerpc/perf/power9-pmu.c
@@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
 	.attrs = power9_pmu_format_attr,
 };
 
+static struct attribute *power9_pmu_caps_attrs[] = {
+	NULL
+};
+
+static struct attribute_group power9_pmu_caps_group = {
+	.name  = "caps",
+	.attrs = power9_pmu_caps_attrs,
+};
+
 static const struct attribute_group *power9_pmu_attr_groups[] = {
 	&power9_pmu_format_group,
 	&power9_pmu_events_group,
+	&power9_pmu_caps_group,
 	NULL,
 };
 
-- 
2.31.1


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

* [PATCH V2 2/2] docs: ABI: sysfs-bus-event_source-devices: Document sysfs caps entry for PMU
  2022-05-18  8:55 ` Athira Rajeev
@ 2022-05-18  8:55   ` Athira Rajeev
  -1 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-18  8:55 UTC (permalink / raw)
  To: acme, jolsa, mpe
  Cc: linux-perf-users, linuxppc-dev, linux-kernel, maddy, rnsastry,
	kjain, disgoel, irogers

Add ABI documentation for "caps" attribute group.
Some of the platform specific PMU features can be exposed
in "caps" attribute group/directory:
/sys/bus/event_source/devices/<dev>/

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
 .../sysfs-bus-event_source-devices-caps        | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-caps

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-caps b/Documentation/ABI/testing/sysfs-bus-event_source-devices-caps
new file mode 100644
index 000000000000..ef5f537bdd83
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-caps
@@ -0,0 +1,18 @@
+What:		/sys/bus/event_source/devices/<dev>/caps
+Date:		May 2022
+KernelVersion:	5.19
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+Description:
+		Attribute group to describe the capabilities exposed
+		for a particular pmu. Each attribute of this group can
+		expose information specific to a PMU, say pmu_name, so that
+		userspace can understand some of the feature which the
+		platform specific PMU supports.
+
+		One of the example available capability in supported platform
+		like Intel is pmu_name, which exposes underlying CPU name known
+		to the PMU driver.
+
+		Example output in powerpc:
+		grep -H . /sys/bus/event_source/devices/cpu/caps/*
+		/sys/bus/event_source/devices/cpu/caps/pmu_name:POWER9
-- 
2.31.1


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

* [PATCH V2 2/2] docs: ABI: sysfs-bus-event_source-devices: Document sysfs caps entry for PMU
@ 2022-05-18  8:55   ` Athira Rajeev
  0 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-18  8:55 UTC (permalink / raw)
  To: acme, jolsa, mpe
  Cc: irogers, maddy, rnsastry, kjain, linux-kernel, linux-perf-users,
	disgoel, linuxppc-dev

Add ABI documentation for "caps" attribute group.
Some of the platform specific PMU features can be exposed
in "caps" attribute group/directory:
/sys/bus/event_source/devices/<dev>/

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
 .../sysfs-bus-event_source-devices-caps        | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-caps

diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-caps b/Documentation/ABI/testing/sysfs-bus-event_source-devices-caps
new file mode 100644
index 000000000000..ef5f537bdd83
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-caps
@@ -0,0 +1,18 @@
+What:		/sys/bus/event_source/devices/<dev>/caps
+Date:		May 2022
+KernelVersion:	5.19
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+Description:
+		Attribute group to describe the capabilities exposed
+		for a particular pmu. Each attribute of this group can
+		expose information specific to a PMU, say pmu_name, so that
+		userspace can understand some of the feature which the
+		platform specific PMU supports.
+
+		One of the example available capability in supported platform
+		like Intel is pmu_name, which exposes underlying CPU name known
+		to the PMU driver.
+
+		Example output in powerpc:
+		grep -H . /sys/bus/event_source/devices/cpu/caps/*
+		/sys/bus/event_source/devices/cpu/caps/pmu_name:POWER9
-- 
2.31.1


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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
  2022-05-18  8:55 ` Athira Rajeev
@ 2022-05-19  4:42   ` Ian Rogers
  -1 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2022-05-19  4:42 UTC (permalink / raw)
  To: Athira Rajeev
  Cc: acme, jolsa, mpe, linux-perf-users, linuxppc-dev, linux-kernel,
	maddy, rnsastry, kjain, disgoel

On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
<atrajeev@linux.vnet.ibm.com> wrote:
>
> 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.

For ARM and x86 in the perf tool this is normally done through a cpuid
like function, is there a reason to differ on Power?

Thanks,
Ian

> 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>
> ---
> Changelog:
>  v1 -> v2:
>  Move the show function as generic in core-book3s
>  and update show function using sysfs_emit and ppmu->name
>  Added Documention for this ABI in patch 2.
>  Notes: The caps directory is implemented in PMU for other
>  architectures already. Reference commit for x86:
>  commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
>
>  arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
>  arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
>  arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
>  arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
>  arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
>  5 files changed, 71 insertions(+)
>
> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index b5b42cf0a703..a208f502a80b 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
>         return 0;
>  }
>
> +static ssize_t pmu_name_show(struct device *cdev,
> +               struct device_attribute *attr,
> +               char *buf)
> +{
> +       if (ppmu)
> +               return sysfs_emit(buf, "%s\n", ppmu->name);
> +
> +       return 0;
> +}
> +
> +static DEVICE_ATTR_RO(pmu_name);
> +
> +static struct attribute *pmu_caps_attrs[] = {
> +       &dev_attr_pmu_name.attr,
> +       NULL
> +};
> +
> +static const struct attribute_group pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = pmu_caps_attrs,
> +};
> +
> +static const struct attribute_group *pmu_caps_groups[] = {
> +       &pmu_caps_group,
> +       NULL,
> +};
> +
>  int __init register_power_pmu(struct power_pmu *pmu)
>  {
>         if (ppmu)
> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
>                 pmu->name);
>
>         power_pmu.attr_groups = ppmu->attr_groups;
> +
> +       if (ppmu->flags & PPMU_ARCH_207S)
> +               power_pmu.attr_update = pmu_caps_groups;
> +
>         power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
>
>  #ifdef MSR_HV
> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
> index f3db88aee4dd..817c69863038 100644
> --- a/arch/powerpc/perf/generic-compat-pmu.c
> +++ b/arch/powerpc/perf/generic-compat-pmu.c
> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
>         .attrs = generic_compat_pmu_format_attr,
>  };
>
> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group generic_compat_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = generic_compat_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
>         &generic_compat_pmu_format_group,
>         &generic_compat_pmu_events_group,
> +       &generic_compat_pmu_caps_group,
>         NULL,
>  };
>
> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
> index c6d51e7093cf..d1adcd9f52e2 100644
> --- a/arch/powerpc/perf/power10-pmu.c
> +++ b/arch/powerpc/perf/power10-pmu.c
> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
>         .attrs = power10_pmu_format_attr,
>  };
>
> +static struct attribute *power10_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group power10_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = power10_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>         &power10_pmu_format_group,
>         &power10_pmu_events_group_dd1,
> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>  static const struct attribute_group *power10_pmu_attr_groups[] = {
>         &power10_pmu_format_group,
>         &power10_pmu_events_group,
> +       &power10_pmu_caps_group,
>         NULL,
>  };
>
> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
> index e37b1e714d2b..2518f5375d4a 100644
> --- a/arch/powerpc/perf/power8-pmu.c
> +++ b/arch/powerpc/perf/power8-pmu.c
> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
>         .attrs = power8_events_attr,
>  };
>
> +static struct attribute *power8_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group power8_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = power8_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *power8_pmu_attr_groups[] = {
>         &isa207_pmu_format_group,
>         &power8_pmu_events_group,
> +       &power8_pmu_caps_group,
>         NULL,
>  };
>
> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
> index c393e837648e..5c654ce1a417 100644
> --- a/arch/powerpc/perf/power9-pmu.c
> +++ b/arch/powerpc/perf/power9-pmu.c
> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
>         .attrs = power9_pmu_format_attr,
>  };
>
> +static struct attribute *power9_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group power9_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = power9_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *power9_pmu_attr_groups[] = {
>         &power9_pmu_format_group,
>         &power9_pmu_events_group,
> +       &power9_pmu_caps_group,
>         NULL,
>  };
>
> --
> 2.31.1
>

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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
@ 2022-05-19  4:42   ` Ian Rogers
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2022-05-19  4:42 UTC (permalink / raw)
  To: Athira Rajeev
  Cc: maddy, rnsastry, linux-kernel, acme, linux-perf-users, jolsa,
	kjain, disgoel, linuxppc-dev

On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
<atrajeev@linux.vnet.ibm.com> wrote:
>
> 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.

For ARM and x86 in the perf tool this is normally done through a cpuid
like function, is there a reason to differ on Power?

Thanks,
Ian

> 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>
> ---
> Changelog:
>  v1 -> v2:
>  Move the show function as generic in core-book3s
>  and update show function using sysfs_emit and ppmu->name
>  Added Documention for this ABI in patch 2.
>  Notes: The caps directory is implemented in PMU for other
>  architectures already. Reference commit for x86:
>  commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
>
>  arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
>  arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
>  arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
>  arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
>  arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
>  5 files changed, 71 insertions(+)
>
> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index b5b42cf0a703..a208f502a80b 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
>         return 0;
>  }
>
> +static ssize_t pmu_name_show(struct device *cdev,
> +               struct device_attribute *attr,
> +               char *buf)
> +{
> +       if (ppmu)
> +               return sysfs_emit(buf, "%s\n", ppmu->name);
> +
> +       return 0;
> +}
> +
> +static DEVICE_ATTR_RO(pmu_name);
> +
> +static struct attribute *pmu_caps_attrs[] = {
> +       &dev_attr_pmu_name.attr,
> +       NULL
> +};
> +
> +static const struct attribute_group pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = pmu_caps_attrs,
> +};
> +
> +static const struct attribute_group *pmu_caps_groups[] = {
> +       &pmu_caps_group,
> +       NULL,
> +};
> +
>  int __init register_power_pmu(struct power_pmu *pmu)
>  {
>         if (ppmu)
> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
>                 pmu->name);
>
>         power_pmu.attr_groups = ppmu->attr_groups;
> +
> +       if (ppmu->flags & PPMU_ARCH_207S)
> +               power_pmu.attr_update = pmu_caps_groups;
> +
>         power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
>
>  #ifdef MSR_HV
> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
> index f3db88aee4dd..817c69863038 100644
> --- a/arch/powerpc/perf/generic-compat-pmu.c
> +++ b/arch/powerpc/perf/generic-compat-pmu.c
> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
>         .attrs = generic_compat_pmu_format_attr,
>  };
>
> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group generic_compat_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = generic_compat_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
>         &generic_compat_pmu_format_group,
>         &generic_compat_pmu_events_group,
> +       &generic_compat_pmu_caps_group,
>         NULL,
>  };
>
> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
> index c6d51e7093cf..d1adcd9f52e2 100644
> --- a/arch/powerpc/perf/power10-pmu.c
> +++ b/arch/powerpc/perf/power10-pmu.c
> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
>         .attrs = power10_pmu_format_attr,
>  };
>
> +static struct attribute *power10_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group power10_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = power10_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>         &power10_pmu_format_group,
>         &power10_pmu_events_group_dd1,
> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>  static const struct attribute_group *power10_pmu_attr_groups[] = {
>         &power10_pmu_format_group,
>         &power10_pmu_events_group,
> +       &power10_pmu_caps_group,
>         NULL,
>  };
>
> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
> index e37b1e714d2b..2518f5375d4a 100644
> --- a/arch/powerpc/perf/power8-pmu.c
> +++ b/arch/powerpc/perf/power8-pmu.c
> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
>         .attrs = power8_events_attr,
>  };
>
> +static struct attribute *power8_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group power8_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = power8_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *power8_pmu_attr_groups[] = {
>         &isa207_pmu_format_group,
>         &power8_pmu_events_group,
> +       &power8_pmu_caps_group,
>         NULL,
>  };
>
> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
> index c393e837648e..5c654ce1a417 100644
> --- a/arch/powerpc/perf/power9-pmu.c
> +++ b/arch/powerpc/perf/power9-pmu.c
> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
>         .attrs = power9_pmu_format_attr,
>  };
>
> +static struct attribute *power9_pmu_caps_attrs[] = {
> +       NULL
> +};
> +
> +static struct attribute_group power9_pmu_caps_group = {
> +       .name  = "caps",
> +       .attrs = power9_pmu_caps_attrs,
> +};
> +
>  static const struct attribute_group *power9_pmu_attr_groups[] = {
>         &power9_pmu_format_group,
>         &power9_pmu_events_group,
> +       &power9_pmu_caps_group,
>         NULL,
>  };
>
> --
> 2.31.1
>

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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
  2022-05-19  4:42   ` Ian Rogers
@ 2022-05-19 11:28     ` Athira Rajeev
  -1 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-19 11:28 UTC (permalink / raw)
  To: Ian Rogers
  Cc: maddy, Nageswara Sastry, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, linux-perf-users, Jiri Olsa,
	Kajol Jain, disgoel, linuxppc-dev



> On 19-May-2022, at 10:12 AM, Ian Rogers <irogers@google.com> wrote:
> 
> On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
> <atrajeev@linux.vnet.ibm.com> wrote:
>> 
>> 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.
> 
> For ARM and x86 in the perf tool this is normally done through a cpuid
> like function, is there a reason to differ on Power?
> 
> Thanks,
> Ian

Hi Ian,

Thanks for review. The information from cpuid or cpuinfo will provide
us the information of the platform/model/machine etc. In case of powerpc,
we have one case where, though platform points to specific generation of the
processor, say power9 or power10, the registered PMU could point to
different one. To be specific, this is named as Generic Compat PMU which
is a fallback PMU. This gets registered when the distro doesn't have support
for platform specific PMU. In that case distro will have a Generic
Compat PMU registered which supports basic features for performance monitoring.
This information can't be fetched from the cpuid data since that will point
to current platform.

So the pmu_name exposed via "caps" will be useful to detect the PMU
registered and also we target to use this information in some of our
selftests.

Thanks
Athira
> 
>> 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>
>> ---
>> Changelog:
>> v1 -> v2:
>> Move the show function as generic in core-book3s
>> and update show function using sysfs_emit and ppmu->name
>> Added Documention for this ABI in patch 2.
>> Notes: The caps directory is implemented in PMU for other
>> architectures already. Reference commit for x86:
>> commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
>> 
>> arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
>> arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
>> arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
>> arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
>> arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
>> 5 files changed, 71 insertions(+)
>> 
>> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
>> index b5b42cf0a703..a208f502a80b 100644
>> --- a/arch/powerpc/perf/core-book3s.c
>> +++ b/arch/powerpc/perf/core-book3s.c
>> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
>>       return 0;
>> }
>> 
>> +static ssize_t pmu_name_show(struct device *cdev,
>> +               struct device_attribute *attr,
>> +               char *buf)
>> +{
>> +       if (ppmu)
>> +               return sysfs_emit(buf, "%s\n", ppmu->name);
>> +
>> +       return 0;
>> +}
>> +
>> +static DEVICE_ATTR_RO(pmu_name);
>> +
>> +static struct attribute *pmu_caps_attrs[] = {
>> +       &dev_attr_pmu_name.attr,
>> +       NULL
>> +};
>> +
>> +static const struct attribute_group pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = pmu_caps_attrs,
>> +};
>> +
>> +static const struct attribute_group *pmu_caps_groups[] = {
>> +       &pmu_caps_group,
>> +       NULL,
>> +};
>> +
>> int __init register_power_pmu(struct power_pmu *pmu)
>> {
>>       if (ppmu)
>> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
>>               pmu->name);
>> 
>>       power_pmu.attr_groups = ppmu->attr_groups;
>> +
>> +       if (ppmu->flags & PPMU_ARCH_207S)
>> +               power_pmu.attr_update = pmu_caps_groups;
>> +
>>       power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
>> 
>> #ifdef MSR_HV
>> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
>> index f3db88aee4dd..817c69863038 100644
>> --- a/arch/powerpc/perf/generic-compat-pmu.c
>> +++ b/arch/powerpc/perf/generic-compat-pmu.c
>> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
>>       .attrs = generic_compat_pmu_format_attr,
>> };
>> 
>> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group generic_compat_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = generic_compat_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
>>       &generic_compat_pmu_format_group,
>>       &generic_compat_pmu_events_group,
>> +       &generic_compat_pmu_caps_group,
>>       NULL,
>> };
>> 
>> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
>> index c6d51e7093cf..d1adcd9f52e2 100644
>> --- a/arch/powerpc/perf/power10-pmu.c
>> +++ b/arch/powerpc/perf/power10-pmu.c
>> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
>>       .attrs = power10_pmu_format_attr,
>> };
>> 
>> +static struct attribute *power10_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group power10_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = power10_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>>       &power10_pmu_format_group,
>>       &power10_pmu_events_group_dd1,
>> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>> static const struct attribute_group *power10_pmu_attr_groups[] = {
>>       &power10_pmu_format_group,
>>       &power10_pmu_events_group,
>> +       &power10_pmu_caps_group,
>>       NULL,
>> };
>> 
>> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
>> index e37b1e714d2b..2518f5375d4a 100644
>> --- a/arch/powerpc/perf/power8-pmu.c
>> +++ b/arch/powerpc/perf/power8-pmu.c
>> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
>>       .attrs = power8_events_attr,
>> };
>> 
>> +static struct attribute *power8_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group power8_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = power8_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *power8_pmu_attr_groups[] = {
>>       &isa207_pmu_format_group,
>>       &power8_pmu_events_group,
>> +       &power8_pmu_caps_group,
>>       NULL,
>> };
>> 
>> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
>> index c393e837648e..5c654ce1a417 100644
>> --- a/arch/powerpc/perf/power9-pmu.c
>> +++ b/arch/powerpc/perf/power9-pmu.c
>> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
>>       .attrs = power9_pmu_format_attr,
>> };
>> 
>> +static struct attribute *power9_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group power9_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = power9_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *power9_pmu_attr_groups[] = {
>>       &power9_pmu_format_group,
>>       &power9_pmu_events_group,
>> +       &power9_pmu_caps_group,
>>       NULL,
>> };
>> 
>> --
>> 2.31.1


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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
@ 2022-05-19 11:28     ` Athira Rajeev
  0 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-19 11:28 UTC (permalink / raw)
  To: Ian Rogers
  Cc: maddy, Nageswara Sastry, Kajol Jain, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, linux-perf-users, Jiri Olsa, disgoel,
	linuxppc-dev



> On 19-May-2022, at 10:12 AM, Ian Rogers <irogers@google.com> wrote:
> 
> On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
> <atrajeev@linux.vnet.ibm.com> wrote:
>> 
>> 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.
> 
> For ARM and x86 in the perf tool this is normally done through a cpuid
> like function, is there a reason to differ on Power?
> 
> Thanks,
> Ian

Hi Ian,

Thanks for review. The information from cpuid or cpuinfo will provide
us the information of the platform/model/machine etc. In case of powerpc,
we have one case where, though platform points to specific generation of the
processor, say power9 or power10, the registered PMU could point to
different one. To be specific, this is named as Generic Compat PMU which
is a fallback PMU. This gets registered when the distro doesn't have support
for platform specific PMU. In that case distro will have a Generic
Compat PMU registered which supports basic features for performance monitoring.
This information can't be fetched from the cpuid data since that will point
to current platform.

So the pmu_name exposed via "caps" will be useful to detect the PMU
registered and also we target to use this information in some of our
selftests.

Thanks
Athira
> 
>> 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>
>> ---
>> Changelog:
>> v1 -> v2:
>> Move the show function as generic in core-book3s
>> and update show function using sysfs_emit and ppmu->name
>> Added Documention for this ABI in patch 2.
>> Notes: The caps directory is implemented in PMU for other
>> architectures already. Reference commit for x86:
>> commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
>> 
>> arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
>> arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
>> arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
>> arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
>> arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
>> 5 files changed, 71 insertions(+)
>> 
>> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
>> index b5b42cf0a703..a208f502a80b 100644
>> --- a/arch/powerpc/perf/core-book3s.c
>> +++ b/arch/powerpc/perf/core-book3s.c
>> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
>>       return 0;
>> }
>> 
>> +static ssize_t pmu_name_show(struct device *cdev,
>> +               struct device_attribute *attr,
>> +               char *buf)
>> +{
>> +       if (ppmu)
>> +               return sysfs_emit(buf, "%s\n", ppmu->name);
>> +
>> +       return 0;
>> +}
>> +
>> +static DEVICE_ATTR_RO(pmu_name);
>> +
>> +static struct attribute *pmu_caps_attrs[] = {
>> +       &dev_attr_pmu_name.attr,
>> +       NULL
>> +};
>> +
>> +static const struct attribute_group pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = pmu_caps_attrs,
>> +};
>> +
>> +static const struct attribute_group *pmu_caps_groups[] = {
>> +       &pmu_caps_group,
>> +       NULL,
>> +};
>> +
>> int __init register_power_pmu(struct power_pmu *pmu)
>> {
>>       if (ppmu)
>> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
>>               pmu->name);
>> 
>>       power_pmu.attr_groups = ppmu->attr_groups;
>> +
>> +       if (ppmu->flags & PPMU_ARCH_207S)
>> +               power_pmu.attr_update = pmu_caps_groups;
>> +
>>       power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
>> 
>> #ifdef MSR_HV
>> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
>> index f3db88aee4dd..817c69863038 100644
>> --- a/arch/powerpc/perf/generic-compat-pmu.c
>> +++ b/arch/powerpc/perf/generic-compat-pmu.c
>> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
>>       .attrs = generic_compat_pmu_format_attr,
>> };
>> 
>> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group generic_compat_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = generic_compat_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
>>       &generic_compat_pmu_format_group,
>>       &generic_compat_pmu_events_group,
>> +       &generic_compat_pmu_caps_group,
>>       NULL,
>> };
>> 
>> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
>> index c6d51e7093cf..d1adcd9f52e2 100644
>> --- a/arch/powerpc/perf/power10-pmu.c
>> +++ b/arch/powerpc/perf/power10-pmu.c
>> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
>>       .attrs = power10_pmu_format_attr,
>> };
>> 
>> +static struct attribute *power10_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group power10_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = power10_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>>       &power10_pmu_format_group,
>>       &power10_pmu_events_group_dd1,
>> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>> static const struct attribute_group *power10_pmu_attr_groups[] = {
>>       &power10_pmu_format_group,
>>       &power10_pmu_events_group,
>> +       &power10_pmu_caps_group,
>>       NULL,
>> };
>> 
>> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
>> index e37b1e714d2b..2518f5375d4a 100644
>> --- a/arch/powerpc/perf/power8-pmu.c
>> +++ b/arch/powerpc/perf/power8-pmu.c
>> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
>>       .attrs = power8_events_attr,
>> };
>> 
>> +static struct attribute *power8_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group power8_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = power8_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *power8_pmu_attr_groups[] = {
>>       &isa207_pmu_format_group,
>>       &power8_pmu_events_group,
>> +       &power8_pmu_caps_group,
>>       NULL,
>> };
>> 
>> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
>> index c393e837648e..5c654ce1a417 100644
>> --- a/arch/powerpc/perf/power9-pmu.c
>> +++ b/arch/powerpc/perf/power9-pmu.c
>> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
>>       .attrs = power9_pmu_format_attr,
>> };
>> 
>> +static struct attribute *power9_pmu_caps_attrs[] = {
>> +       NULL
>> +};
>> +
>> +static struct attribute_group power9_pmu_caps_group = {
>> +       .name  = "caps",
>> +       .attrs = power9_pmu_caps_attrs,
>> +};
>> +
>> static const struct attribute_group *power9_pmu_attr_groups[] = {
>>       &power9_pmu_format_group,
>>       &power9_pmu_events_group,
>> +       &power9_pmu_caps_group,
>>       NULL,
>> };
>> 
>> --
>> 2.31.1


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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
  2022-05-19 11:28     ` Athira Rajeev
@ 2022-05-19 21:36       ` Ian Rogers
  -1 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2022-05-19 21:36 UTC (permalink / raw)
  To: Athira Rajeev
  Cc: maddy, Nageswara Sastry, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, linux-perf-users, Jiri Olsa,
	Kajol Jain, disgoel, linuxppc-dev

On Thu, May 19, 2022 at 4:29 AM Athira Rajeev
<atrajeev@linux.vnet.ibm.com> wrote:
>
> > On 19-May-2022, at 10:12 AM, Ian Rogers <irogers@google.com> wrote:
> >
> > On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
> > <atrajeev@linux.vnet.ibm.com> wrote:
> >>
> >> 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.
> >
> > For ARM and x86 in the perf tool this is normally done through a cpuid
> > like function, is there a reason to differ on Power?
> >
> > Thanks,
> > Ian
>
> Hi Ian,
>
> Thanks for review. The information from cpuid or cpuinfo will provide
> us the information of the platform/model/machine etc. In case of powerpc,
> we have one case where, though platform points to specific generation of the
> processor, say power9 or power10, the registered PMU could point to
> different one. To be specific, this is named as Generic Compat PMU which
> is a fallback PMU. This gets registered when the distro doesn't have support
> for platform specific PMU. In that case distro will have a Generic
> Compat PMU registered which supports basic features for performance monitoring.
> This information can't be fetched from the cpuid data since that will point
> to current platform.
>
> So the pmu_name exposed via "caps" will be useful to detect the PMU
> registered and also we target to use this information in some of our
> selftests.

Thanks, I've no problem with the change. Do we need to do a similar
discovery in the perf tool on old kernels? Perhaps then this
information could be exposed in the perf list command for self tests.

Thanks,
Ian

> Thanks
> Athira
> >
> >> 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>
> >> ---
> >> Changelog:
> >> v1 -> v2:
> >> Move the show function as generic in core-book3s
> >> and update show function using sysfs_emit and ppmu->name
> >> Added Documention for this ABI in patch 2.
> >> Notes: The caps directory is implemented in PMU for other
> >> architectures already. Reference commit for x86:
> >> commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
> >>
> >> arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
> >> arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
> >> arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
> >> arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
> >> arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
> >> 5 files changed, 71 insertions(+)
> >>
> >> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> >> index b5b42cf0a703..a208f502a80b 100644
> >> --- a/arch/powerpc/perf/core-book3s.c
> >> +++ b/arch/powerpc/perf/core-book3s.c
> >> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
> >>       return 0;
> >> }
> >>
> >> +static ssize_t pmu_name_show(struct device *cdev,
> >> +               struct device_attribute *attr,
> >> +               char *buf)
> >> +{
> >> +       if (ppmu)
> >> +               return sysfs_emit(buf, "%s\n", ppmu->name);
> >> +
> >> +       return 0;
> >> +}
> >> +
> >> +static DEVICE_ATTR_RO(pmu_name);
> >> +
> >> +static struct attribute *pmu_caps_attrs[] = {
> >> +       &dev_attr_pmu_name.attr,
> >> +       NULL
> >> +};
> >> +
> >> +static const struct attribute_group pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = pmu_caps_attrs,
> >> +};
> >> +
> >> +static const struct attribute_group *pmu_caps_groups[] = {
> >> +       &pmu_caps_group,
> >> +       NULL,
> >> +};
> >> +
> >> int __init register_power_pmu(struct power_pmu *pmu)
> >> {
> >>       if (ppmu)
> >> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
> >>               pmu->name);
> >>
> >>       power_pmu.attr_groups = ppmu->attr_groups;
> >> +
> >> +       if (ppmu->flags & PPMU_ARCH_207S)
> >> +               power_pmu.attr_update = pmu_caps_groups;
> >> +
> >>       power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
> >>
> >> #ifdef MSR_HV
> >> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
> >> index f3db88aee4dd..817c69863038 100644
> >> --- a/arch/powerpc/perf/generic-compat-pmu.c
> >> +++ b/arch/powerpc/perf/generic-compat-pmu.c
> >> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
> >>       .attrs = generic_compat_pmu_format_attr,
> >> };
> >>
> >> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group generic_compat_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = generic_compat_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
> >>       &generic_compat_pmu_format_group,
> >>       &generic_compat_pmu_events_group,
> >> +       &generic_compat_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
> >> index c6d51e7093cf..d1adcd9f52e2 100644
> >> --- a/arch/powerpc/perf/power10-pmu.c
> >> +++ b/arch/powerpc/perf/power10-pmu.c
> >> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
> >>       .attrs = power10_pmu_format_attr,
> >> };
> >>
> >> +static struct attribute *power10_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group power10_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = power10_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
> >>       &power10_pmu_format_group,
> >>       &power10_pmu_events_group_dd1,
> >> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
> >> static const struct attribute_group *power10_pmu_attr_groups[] = {
> >>       &power10_pmu_format_group,
> >>       &power10_pmu_events_group,
> >> +       &power10_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
> >> index e37b1e714d2b..2518f5375d4a 100644
> >> --- a/arch/powerpc/perf/power8-pmu.c
> >> +++ b/arch/powerpc/perf/power8-pmu.c
> >> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
> >>       .attrs = power8_events_attr,
> >> };
> >>
> >> +static struct attribute *power8_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group power8_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = power8_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *power8_pmu_attr_groups[] = {
> >>       &isa207_pmu_format_group,
> >>       &power8_pmu_events_group,
> >> +       &power8_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
> >> index c393e837648e..5c654ce1a417 100644
> >> --- a/arch/powerpc/perf/power9-pmu.c
> >> +++ b/arch/powerpc/perf/power9-pmu.c
> >> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
> >>       .attrs = power9_pmu_format_attr,
> >> };
> >>
> >> +static struct attribute *power9_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group power9_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = power9_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *power9_pmu_attr_groups[] = {
> >>       &power9_pmu_format_group,
> >>       &power9_pmu_events_group,
> >> +       &power9_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> --
> >> 2.31.1
>

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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
@ 2022-05-19 21:36       ` Ian Rogers
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2022-05-19 21:36 UTC (permalink / raw)
  To: Athira Rajeev
  Cc: maddy, Nageswara Sastry, Kajol Jain, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, linux-perf-users, Jiri Olsa, disgoel,
	linuxppc-dev

On Thu, May 19, 2022 at 4:29 AM Athira Rajeev
<atrajeev@linux.vnet.ibm.com> wrote:
>
> > On 19-May-2022, at 10:12 AM, Ian Rogers <irogers@google.com> wrote:
> >
> > On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
> > <atrajeev@linux.vnet.ibm.com> wrote:
> >>
> >> 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.
> >
> > For ARM and x86 in the perf tool this is normally done through a cpuid
> > like function, is there a reason to differ on Power?
> >
> > Thanks,
> > Ian
>
> Hi Ian,
>
> Thanks for review. The information from cpuid or cpuinfo will provide
> us the information of the platform/model/machine etc. In case of powerpc,
> we have one case where, though platform points to specific generation of the
> processor, say power9 or power10, the registered PMU could point to
> different one. To be specific, this is named as Generic Compat PMU which
> is a fallback PMU. This gets registered when the distro doesn't have support
> for platform specific PMU. In that case distro will have a Generic
> Compat PMU registered which supports basic features for performance monitoring.
> This information can't be fetched from the cpuid data since that will point
> to current platform.
>
> So the pmu_name exposed via "caps" will be useful to detect the PMU
> registered and also we target to use this information in some of our
> selftests.

Thanks, I've no problem with the change. Do we need to do a similar
discovery in the perf tool on old kernels? Perhaps then this
information could be exposed in the perf list command for self tests.

Thanks,
Ian

> Thanks
> Athira
> >
> >> 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>
> >> ---
> >> Changelog:
> >> v1 -> v2:
> >> Move the show function as generic in core-book3s
> >> and update show function using sysfs_emit and ppmu->name
> >> Added Documention for this ABI in patch 2.
> >> Notes: The caps directory is implemented in PMU for other
> >> architectures already. Reference commit for x86:
> >> commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
> >>
> >> arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
> >> arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
> >> arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
> >> arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
> >> arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
> >> 5 files changed, 71 insertions(+)
> >>
> >> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> >> index b5b42cf0a703..a208f502a80b 100644
> >> --- a/arch/powerpc/perf/core-book3s.c
> >> +++ b/arch/powerpc/perf/core-book3s.c
> >> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
> >>       return 0;
> >> }
> >>
> >> +static ssize_t pmu_name_show(struct device *cdev,
> >> +               struct device_attribute *attr,
> >> +               char *buf)
> >> +{
> >> +       if (ppmu)
> >> +               return sysfs_emit(buf, "%s\n", ppmu->name);
> >> +
> >> +       return 0;
> >> +}
> >> +
> >> +static DEVICE_ATTR_RO(pmu_name);
> >> +
> >> +static struct attribute *pmu_caps_attrs[] = {
> >> +       &dev_attr_pmu_name.attr,
> >> +       NULL
> >> +};
> >> +
> >> +static const struct attribute_group pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = pmu_caps_attrs,
> >> +};
> >> +
> >> +static const struct attribute_group *pmu_caps_groups[] = {
> >> +       &pmu_caps_group,
> >> +       NULL,
> >> +};
> >> +
> >> int __init register_power_pmu(struct power_pmu *pmu)
> >> {
> >>       if (ppmu)
> >> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
> >>               pmu->name);
> >>
> >>       power_pmu.attr_groups = ppmu->attr_groups;
> >> +
> >> +       if (ppmu->flags & PPMU_ARCH_207S)
> >> +               power_pmu.attr_update = pmu_caps_groups;
> >> +
> >>       power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
> >>
> >> #ifdef MSR_HV
> >> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
> >> index f3db88aee4dd..817c69863038 100644
> >> --- a/arch/powerpc/perf/generic-compat-pmu.c
> >> +++ b/arch/powerpc/perf/generic-compat-pmu.c
> >> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
> >>       .attrs = generic_compat_pmu_format_attr,
> >> };
> >>
> >> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group generic_compat_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = generic_compat_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
> >>       &generic_compat_pmu_format_group,
> >>       &generic_compat_pmu_events_group,
> >> +       &generic_compat_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
> >> index c6d51e7093cf..d1adcd9f52e2 100644
> >> --- a/arch/powerpc/perf/power10-pmu.c
> >> +++ b/arch/powerpc/perf/power10-pmu.c
> >> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
> >>       .attrs = power10_pmu_format_attr,
> >> };
> >>
> >> +static struct attribute *power10_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group power10_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = power10_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
> >>       &power10_pmu_format_group,
> >>       &power10_pmu_events_group_dd1,
> >> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
> >> static const struct attribute_group *power10_pmu_attr_groups[] = {
> >>       &power10_pmu_format_group,
> >>       &power10_pmu_events_group,
> >> +       &power10_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
> >> index e37b1e714d2b..2518f5375d4a 100644
> >> --- a/arch/powerpc/perf/power8-pmu.c
> >> +++ b/arch/powerpc/perf/power8-pmu.c
> >> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
> >>       .attrs = power8_events_attr,
> >> };
> >>
> >> +static struct attribute *power8_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group power8_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = power8_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *power8_pmu_attr_groups[] = {
> >>       &isa207_pmu_format_group,
> >>       &power8_pmu_events_group,
> >> +       &power8_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
> >> index c393e837648e..5c654ce1a417 100644
> >> --- a/arch/powerpc/perf/power9-pmu.c
> >> +++ b/arch/powerpc/perf/power9-pmu.c
> >> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
> >>       .attrs = power9_pmu_format_attr,
> >> };
> >>
> >> +static struct attribute *power9_pmu_caps_attrs[] = {
> >> +       NULL
> >> +};
> >> +
> >> +static struct attribute_group power9_pmu_caps_group = {
> >> +       .name  = "caps",
> >> +       .attrs = power9_pmu_caps_attrs,
> >> +};
> >> +
> >> static const struct attribute_group *power9_pmu_attr_groups[] = {
> >>       &power9_pmu_format_group,
> >>       &power9_pmu_events_group,
> >> +       &power9_pmu_caps_group,
> >>       NULL,
> >> };
> >>
> >> --
> >> 2.31.1
>

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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
  2022-05-19 21:36       ` Ian Rogers
@ 2022-05-20  6:14         ` Athira Rajeev
  -1 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-20  6:14 UTC (permalink / raw)
  To: Ian Rogers
  Cc: maddy, Nageswara Sastry, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, linux-perf-users, Jiri Olsa,
	Kajol Jain, disgoel, linuxppc-dev



> On 20-May-2022, at 3:06 AM, Ian Rogers <irogers@google.com> wrote:
> 
> On Thu, May 19, 2022 at 4:29 AM Athira Rajeev
> <atrajeev@linux.vnet.ibm.com> wrote:
>> 
>>> On 19-May-2022, at 10:12 AM, Ian Rogers <irogers@google.com> wrote:
>>> 
>>> On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
>>> <atrajeev@linux.vnet.ibm.com> wrote:
>>>> 
>>>> 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.
>>> 
>>> For ARM and x86 in the perf tool this is normally done through a cpuid
>>> like function, is there a reason to differ on Power?
>>> 
>>> Thanks,
>>> Ian
>> 
>> Hi Ian,
>> 
>> Thanks for review. The information from cpuid or cpuinfo will provide
>> us the information of the platform/model/machine etc. In case of powerpc,
>> we have one case where, though platform points to specific generation of the
>> processor, say power9 or power10, the registered PMU could point to
>> different one. To be specific, this is named as Generic Compat PMU which
>> is a fallback PMU. This gets registered when the distro doesn't have support
>> for platform specific PMU. In that case distro will have a Generic
>> Compat PMU registered which supports basic features for performance monitoring.
>> This information can't be fetched from the cpuid data since that will point
>> to current platform.
>> 
>> So the pmu_name exposed via "caps" will be useful to detect the PMU
>> registered and also we target to use this information in some of our
>> selftests.
> 
> Thanks, I've no problem with the change. Do we need to do a similar
> discovery in the perf tool on old kernels? Perhaps then this
> information could be exposed in the perf list command for self tests.


Hi Ian,

Thanks for review. Thats good one to have. I see in perf tools, we are parsing caps data : "env->cpu_pmu_caps" already.
I will check on how this is used and option of having in perf list.
After checking, I will send a follow up patch for the same.

Thanks
Athira
> 
> Thanks,
> Ian
> 
>> Thanks
>> Athira
>>> 
>>>> 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>
>>>> ---
>>>> Changelog:
>>>> v1 -> v2:
>>>> Move the show function as generic in core-book3s
>>>> and update show function using sysfs_emit and ppmu->name
>>>> Added Documention for this ABI in patch 2.
>>>> Notes: The caps directory is implemented in PMU for other
>>>> architectures already. Reference commit for x86:
>>>> commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
>>>> 
>>>> arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
>>>> arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
>>>> arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
>>>> arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
>>>> arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
>>>> 5 files changed, 71 insertions(+)
>>>> 
>>>> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
>>>> index b5b42cf0a703..a208f502a80b 100644
>>>> --- a/arch/powerpc/perf/core-book3s.c
>>>> +++ b/arch/powerpc/perf/core-book3s.c
>>>> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
>>>>      return 0;
>>>> }
>>>> 
>>>> +static ssize_t pmu_name_show(struct device *cdev,
>>>> +               struct device_attribute *attr,
>>>> +               char *buf)
>>>> +{
>>>> +       if (ppmu)
>>>> +               return sysfs_emit(buf, "%s\n", ppmu->name);
>>>> +
>>>> +       return 0;
>>>> +}
>>>> +
>>>> +static DEVICE_ATTR_RO(pmu_name);
>>>> +
>>>> +static struct attribute *pmu_caps_attrs[] = {
>>>> +       &dev_attr_pmu_name.attr,
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static const struct attribute_group pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = pmu_caps_attrs,
>>>> +};
>>>> +
>>>> +static const struct attribute_group *pmu_caps_groups[] = {
>>>> +       &pmu_caps_group,
>>>> +       NULL,
>>>> +};
>>>> +
>>>> int __init register_power_pmu(struct power_pmu *pmu)
>>>> {
>>>>      if (ppmu)
>>>> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
>>>>              pmu->name);
>>>> 
>>>>      power_pmu.attr_groups = ppmu->attr_groups;
>>>> +
>>>> +       if (ppmu->flags & PPMU_ARCH_207S)
>>>> +               power_pmu.attr_update = pmu_caps_groups;
>>>> +
>>>>      power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
>>>> 
>>>> #ifdef MSR_HV
>>>> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
>>>> index f3db88aee4dd..817c69863038 100644
>>>> --- a/arch/powerpc/perf/generic-compat-pmu.c
>>>> +++ b/arch/powerpc/perf/generic-compat-pmu.c
>>>> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
>>>>      .attrs = generic_compat_pmu_format_attr,
>>>> };
>>>> 
>>>> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group generic_compat_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = generic_compat_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
>>>>      &generic_compat_pmu_format_group,
>>>>      &generic_compat_pmu_events_group,
>>>> +       &generic_compat_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
>>>> index c6d51e7093cf..d1adcd9f52e2 100644
>>>> --- a/arch/powerpc/perf/power10-pmu.c
>>>> +++ b/arch/powerpc/perf/power10-pmu.c
>>>> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
>>>>      .attrs = power10_pmu_format_attr,
>>>> };
>>>> 
>>>> +static struct attribute *power10_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group power10_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = power10_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>>>>      &power10_pmu_format_group,
>>>>      &power10_pmu_events_group_dd1,
>>>> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>>>> static const struct attribute_group *power10_pmu_attr_groups[] = {
>>>>      &power10_pmu_format_group,
>>>>      &power10_pmu_events_group,
>>>> +       &power10_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
>>>> index e37b1e714d2b..2518f5375d4a 100644
>>>> --- a/arch/powerpc/perf/power8-pmu.c
>>>> +++ b/arch/powerpc/perf/power8-pmu.c
>>>> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
>>>>      .attrs = power8_events_attr,
>>>> };
>>>> 
>>>> +static struct attribute *power8_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group power8_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = power8_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *power8_pmu_attr_groups[] = {
>>>>      &isa207_pmu_format_group,
>>>>      &power8_pmu_events_group,
>>>> +       &power8_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
>>>> index c393e837648e..5c654ce1a417 100644
>>>> --- a/arch/powerpc/perf/power9-pmu.c
>>>> +++ b/arch/powerpc/perf/power9-pmu.c
>>>> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
>>>>      .attrs = power9_pmu_format_attr,
>>>> };
>>>> 
>>>> +static struct attribute *power9_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group power9_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = power9_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *power9_pmu_attr_groups[] = {
>>>>      &power9_pmu_format_group,
>>>>      &power9_pmu_events_group,
>>>> +       &power9_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> --
>>>> 2.31.1


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

* Re: [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc
@ 2022-05-20  6:14         ` Athira Rajeev
  0 siblings, 0 replies; 12+ messages in thread
From: Athira Rajeev @ 2022-05-20  6:14 UTC (permalink / raw)
  To: Ian Rogers
  Cc: maddy, Nageswara Sastry, Kajol Jain, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, linux-perf-users, Jiri Olsa, disgoel,
	linuxppc-dev



> On 20-May-2022, at 3:06 AM, Ian Rogers <irogers@google.com> wrote:
> 
> On Thu, May 19, 2022 at 4:29 AM Athira Rajeev
> <atrajeev@linux.vnet.ibm.com> wrote:
>> 
>>> On 19-May-2022, at 10:12 AM, Ian Rogers <irogers@google.com> wrote:
>>> 
>>> On Wed, May 18, 2022 at 1:55 AM Athira Rajeev
>>> <atrajeev@linux.vnet.ibm.com> wrote:
>>>> 
>>>> 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.
>>> 
>>> For ARM and x86 in the perf tool this is normally done through a cpuid
>>> like function, is there a reason to differ on Power?
>>> 
>>> Thanks,
>>> Ian
>> 
>> Hi Ian,
>> 
>> Thanks for review. The information from cpuid or cpuinfo will provide
>> us the information of the platform/model/machine etc. In case of powerpc,
>> we have one case where, though platform points to specific generation of the
>> processor, say power9 or power10, the registered PMU could point to
>> different one. To be specific, this is named as Generic Compat PMU which
>> is a fallback PMU. This gets registered when the distro doesn't have support
>> for platform specific PMU. In that case distro will have a Generic
>> Compat PMU registered which supports basic features for performance monitoring.
>> This information can't be fetched from the cpuid data since that will point
>> to current platform.
>> 
>> So the pmu_name exposed via "caps" will be useful to detect the PMU
>> registered and also we target to use this information in some of our
>> selftests.
> 
> Thanks, I've no problem with the change. Do we need to do a similar
> discovery in the perf tool on old kernels? Perhaps then this
> information could be exposed in the perf list command for self tests.


Hi Ian,

Thanks for review. Thats good one to have. I see in perf tools, we are parsing caps data : "env->cpu_pmu_caps" already.
I will check on how this is used and option of having in perf list.
After checking, I will send a follow up patch for the same.

Thanks
Athira
> 
> Thanks,
> Ian
> 
>> Thanks
>> Athira
>>> 
>>>> 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>
>>>> ---
>>>> Changelog:
>>>> v1 -> v2:
>>>> Move the show function as generic in core-book3s
>>>> and update show function using sysfs_emit and ppmu->name
>>>> Added Documention for this ABI in patch 2.
>>>> Notes: The caps directory is implemented in PMU for other
>>>> architectures already. Reference commit for x86:
>>>> commit b00233b53065 ("perf/x86: Export some PMU attributes in caps/ directory")
>>>> 
>>>> arch/powerpc/perf/core-book3s.c        | 31 ++++++++++++++++++++++++++
>>>> arch/powerpc/perf/generic-compat-pmu.c | 10 +++++++++
>>>> arch/powerpc/perf/power10-pmu.c        | 10 +++++++++
>>>> arch/powerpc/perf/power8-pmu.c         | 10 +++++++++
>>>> arch/powerpc/perf/power9-pmu.c         | 10 +++++++++
>>>> 5 files changed, 71 insertions(+)
>>>> 
>>>> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
>>>> index b5b42cf0a703..a208f502a80b 100644
>>>> --- a/arch/powerpc/perf/core-book3s.c
>>>> +++ b/arch/powerpc/perf/core-book3s.c
>>>> @@ -2488,6 +2488,33 @@ static int power_pmu_prepare_cpu(unsigned int cpu)
>>>>      return 0;
>>>> }
>>>> 
>>>> +static ssize_t pmu_name_show(struct device *cdev,
>>>> +               struct device_attribute *attr,
>>>> +               char *buf)
>>>> +{
>>>> +       if (ppmu)
>>>> +               return sysfs_emit(buf, "%s\n", ppmu->name);
>>>> +
>>>> +       return 0;
>>>> +}
>>>> +
>>>> +static DEVICE_ATTR_RO(pmu_name);
>>>> +
>>>> +static struct attribute *pmu_caps_attrs[] = {
>>>> +       &dev_attr_pmu_name.attr,
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static const struct attribute_group pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = pmu_caps_attrs,
>>>> +};
>>>> +
>>>> +static const struct attribute_group *pmu_caps_groups[] = {
>>>> +       &pmu_caps_group,
>>>> +       NULL,
>>>> +};
>>>> +
>>>> int __init register_power_pmu(struct power_pmu *pmu)
>>>> {
>>>>      if (ppmu)
>>>> @@ -2498,6 +2525,10 @@ int __init register_power_pmu(struct power_pmu *pmu)
>>>>              pmu->name);
>>>> 
>>>>      power_pmu.attr_groups = ppmu->attr_groups;
>>>> +
>>>> +       if (ppmu->flags & PPMU_ARCH_207S)
>>>> +               power_pmu.attr_update = pmu_caps_groups;
>>>> +
>>>>      power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
>>>> 
>>>> #ifdef MSR_HV
>>>> diff --git a/arch/powerpc/perf/generic-compat-pmu.c b/arch/powerpc/perf/generic-compat-pmu.c
>>>> index f3db88aee4dd..817c69863038 100644
>>>> --- a/arch/powerpc/perf/generic-compat-pmu.c
>>>> +++ b/arch/powerpc/perf/generic-compat-pmu.c
>>>> @@ -151,9 +151,19 @@ static const struct attribute_group generic_compat_pmu_format_group = {
>>>>      .attrs = generic_compat_pmu_format_attr,
>>>> };
>>>> 
>>>> +static struct attribute *generic_compat_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group generic_compat_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = generic_compat_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *generic_compat_pmu_attr_groups[] = {
>>>>      &generic_compat_pmu_format_group,
>>>>      &generic_compat_pmu_events_group,
>>>> +       &generic_compat_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> diff --git a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
>>>> index c6d51e7093cf..d1adcd9f52e2 100644
>>>> --- a/arch/powerpc/perf/power10-pmu.c
>>>> +++ b/arch/powerpc/perf/power10-pmu.c
>>>> @@ -258,6 +258,15 @@ static const struct attribute_group power10_pmu_format_group = {
>>>>      .attrs = power10_pmu_format_attr,
>>>> };
>>>> 
>>>> +static struct attribute *power10_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group power10_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = power10_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>>>>      &power10_pmu_format_group,
>>>>      &power10_pmu_events_group_dd1,
>>>> @@ -267,6 +276,7 @@ static const struct attribute_group *power10_pmu_attr_groups_dd1[] = {
>>>> static const struct attribute_group *power10_pmu_attr_groups[] = {
>>>>      &power10_pmu_format_group,
>>>>      &power10_pmu_events_group,
>>>> +       &power10_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
>>>> index e37b1e714d2b..2518f5375d4a 100644
>>>> --- a/arch/powerpc/perf/power8-pmu.c
>>>> +++ b/arch/powerpc/perf/power8-pmu.c
>>>> @@ -187,9 +187,19 @@ static const struct attribute_group power8_pmu_events_group = {
>>>>      .attrs = power8_events_attr,
>>>> };
>>>> 
>>>> +static struct attribute *power8_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group power8_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = power8_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *power8_pmu_attr_groups[] = {
>>>>      &isa207_pmu_format_group,
>>>>      &power8_pmu_events_group,
>>>> +       &power8_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
>>>> index c393e837648e..5c654ce1a417 100644
>>>> --- a/arch/powerpc/perf/power9-pmu.c
>>>> +++ b/arch/powerpc/perf/power9-pmu.c
>>>> @@ -258,9 +258,19 @@ static const struct attribute_group power9_pmu_format_group = {
>>>>      .attrs = power9_pmu_format_attr,
>>>> };
>>>> 
>>>> +static struct attribute *power9_pmu_caps_attrs[] = {
>>>> +       NULL
>>>> +};
>>>> +
>>>> +static struct attribute_group power9_pmu_caps_group = {
>>>> +       .name  = "caps",
>>>> +       .attrs = power9_pmu_caps_attrs,
>>>> +};
>>>> +
>>>> static const struct attribute_group *power9_pmu_attr_groups[] = {
>>>>      &power9_pmu_format_group,
>>>>      &power9_pmu_events_group,
>>>> +       &power9_pmu_caps_group,
>>>>      NULL,
>>>> };
>>>> 
>>>> --
>>>> 2.31.1


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

end of thread, other threads:[~2022-05-20  6:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18  8:55 [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc Athira Rajeev
2022-05-18  8:55 ` Athira Rajeev
2022-05-18  8:55 ` [PATCH V2 2/2] docs: ABI: sysfs-bus-event_source-devices: Document sysfs caps entry for PMU Athira Rajeev
2022-05-18  8:55   ` Athira Rajeev
2022-05-19  4:42 ` [PATCH V2 1/2] powerpc/perf: Add support for caps under sysfs in powerpc Ian Rogers
2022-05-19  4:42   ` Ian Rogers
2022-05-19 11:28   ` Athira Rajeev
2022-05-19 11:28     ` Athira Rajeev
2022-05-19 21:36     ` Ian Rogers
2022-05-19 21:36       ` Ian Rogers
2022-05-20  6:14       ` Athira Rajeev
2022-05-20  6:14         ` Athira Rajeev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.