* [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list
@ 2022-10-28 15:48 Kajol Jain
2022-11-03 6:47 ` Athira Rajeev
2022-11-24 11:48 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Kajol Jain @ 2022-10-28 15:48 UTC (permalink / raw)
To: mpe; +Cc: kjain, atrajeev, maddy, linuxppc-dev, disgoel
Based on getPerfCountInfo v1.018 documentation, some of the
hv_gpci events got deprecated for platforms firmware that
supports counter_info_version 0x8 or above.
Patch fixes the hv_gpci event list by adding a new attribute
group called "hv_gpci_event_attrs_v6" and a "EVENT_ENABLE"
macro to enable these events for platform firmware
that supports counter_info_version 0x6 or below. And assigning
the hv_gpci event list based on output counter info version
of underlying plaform.
Fixes: 97bf2640184f ("powerpc/perf/hv-gpci: add the remaining gpci requests")
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
---
Changelog:
v1 -> v2
- As suggested by Michael Ellerman, using counter_info_version value
rather then cpu_has_feature() to assign hv-gpci event list.
arch/powerpc/perf/hv-gpci-requests.h | 4 ++++
arch/powerpc/perf/hv-gpci.c | 35 ++++++++++++++++++++++++++--
arch/powerpc/perf/hv-gpci.h | 1 +
arch/powerpc/perf/req-gen/perf.h | 17 ++++++++++++++
4 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h
index 8965b4463d43..baef3d082de9 100644
--- a/arch/powerpc/perf/hv-gpci-requests.h
+++ b/arch/powerpc/perf/hv-gpci-requests.h
@@ -79,6 +79,7 @@ REQUEST(__field(0, 8, partition_id)
)
#include I(REQUEST_END)
+#ifdef EVENT_ENABLE
/*
* Not available for counter_info_version >= 0x8, use
* run_instruction_cycles_by_partition(0x100) instead.
@@ -92,6 +93,7 @@ REQUEST(__field(0, 8, partition_id)
__count(0x10, 8, cycles)
)
#include I(REQUEST_END)
+#endif
#define REQUEST_NAME system_performance_capabilities
#define REQUEST_NUM 0x40
@@ -103,6 +105,7 @@ REQUEST(__field(0, 1, perf_collect_privileged)
)
#include I(REQUEST_END)
+#ifdef EVENT_ENABLE
#define REQUEST_NAME processor_bus_utilization_abc_links
#define REQUEST_NUM 0x50
#define REQUEST_IDX_KIND "hw_chip_id=?"
@@ -194,6 +197,7 @@ REQUEST(__field(0, 4, phys_processor_idx)
__count(0x28, 8, instructions_completed)
)
#include I(REQUEST_END)
+#endif
/* Processor_core_power_mode (0x95) skipped, no counters */
/* Affinity_domain_information_by_virtual_processor (0xA0) skipped,
diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 5eb60ed5b5e8..6eeabf3975e5 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -70,9 +70,9 @@ static const struct attribute_group format_group = {
.attrs = format_attrs,
};
-static const struct attribute_group event_group = {
+static struct attribute_group event_group = {
.name = "events",
- .attrs = hv_gpci_event_attrs,
+ /* .attrs is set in init */
};
#define HV_CAPS_ATTR(_name, _format) \
@@ -330,6 +330,7 @@ static int hv_gpci_init(void)
int r;
unsigned long hret;
struct hv_perf_caps caps;
+ struct hv_gpci_request_buffer *arg;
hv_gpci_assert_offsets_correct();
@@ -353,6 +354,36 @@ static int hv_gpci_init(void)
/* sampling not supported */
h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
+ arg = (void *)get_cpu_var(hv_gpci_reqb);
+ memset(arg, 0, HGPCI_REQ_BUFFER_SIZE);
+
+ /*
+ * hcall H_GET_PERF_COUNTER_INFO populates the output
+ * counter_info_version value based on the system hypervisor.
+ * Pass the counter request 0x10 corresponds to request type
+ * 'Dispatch_timebase_by_processor', to get the supported
+ * counter_info_version.
+ */
+ arg->params.counter_request = cpu_to_be32(0x10);
+
+ r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
+ virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE);
+ if (r) {
+ pr_devel("hcall failed, can't get supported counter_info_version: 0x%x\n", r);
+ arg->params.counter_info_version_out = 0x8;
+ }
+
+ /*
+ * Use counter_info_version_out value to assign
+ * required hv-gpci event list.
+ */
+ if (arg->params.counter_info_version_out >= 0x8)
+ event_group.attrs = hv_gpci_event_attrs;
+ else
+ event_group.attrs = hv_gpci_event_attrs_v6;
+
+ put_cpu_var(hv_gpci_reqb);
+
r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1);
if (r)
return r;
diff --git a/arch/powerpc/perf/hv-gpci.h b/arch/powerpc/perf/hv-gpci.h
index 4d108262bed7..10aba0ccb434 100644
--- a/arch/powerpc/perf/hv-gpci.h
+++ b/arch/powerpc/perf/hv-gpci.h
@@ -26,6 +26,7 @@ enum {
#define REQUEST_FILE "../hv-gpci-requests.h"
#define NAME_LOWER hv_gpci
#define NAME_UPPER HV_GPCI
+#define EVENT_ENABLE
#include "req-gen/perf.h"
#undef REQUEST_FILE
#undef NAME_LOWER
diff --git a/arch/powerpc/perf/req-gen/perf.h b/arch/powerpc/perf/req-gen/perf.h
index fa9bc804e67a..e0b355931271 100644
--- a/arch/powerpc/perf/req-gen/perf.h
+++ b/arch/powerpc/perf/req-gen/perf.h
@@ -139,6 +139,23 @@ PMU_EVENT_ATTR_STRING( \
#define REQUEST_(r_name, r_value, r_idx_1, r_fields) \
r_fields
+/* Generate event list for platforms with counter_info_version 0x6 or below */
+static __maybe_unused struct attribute *hv_gpci_event_attrs_v6[] = {
+#include REQUEST_FILE
+ NULL
+};
+
+/*
+ * Based on getPerfCountInfo v1.018 documentation, some of the hv-gpci
+ * events got deprecated for platforms firmware that supports
+ * counter_info_version 0x8 or above.
+ * Undefining macro EVENT_ENABLE, to disable the addition of deprecated
+ * events in "hv_gpci_event_attrs" attribute group, for platforms that
+ * supports counter_info_version 0x8 or above.
+ */
+#undef EVENT_ENABLE
+
+/* Generate event list for platforms with counter_info_version 0x8 or above*/
static __maybe_unused struct attribute *hv_gpci_event_attrs[] = {
#include REQUEST_FILE
NULL
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list
2022-10-28 15:48 [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list Kajol Jain
@ 2022-11-03 6:47 ` Athira Rajeev
2022-11-24 11:48 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Athira Rajeev @ 2022-11-03 6:47 UTC (permalink / raw)
To: Kajol Jain; +Cc: Madhavan Srinivasan, linuxppc-dev, Disha Goel
> On 28-Oct-2022, at 9:18 PM, Kajol Jain <kjain@linux.ibm.com> wrote:
>
> Based on getPerfCountInfo v1.018 documentation, some of the
> hv_gpci events got deprecated for platforms firmware that
> supports counter_info_version 0x8 or above.
>
> Patch fixes the hv_gpci event list by adding a new attribute
> group called "hv_gpci_event_attrs_v6" and a "EVENT_ENABLE"
> macro to enable these events for platform firmware
> that supports counter_info_version 0x6 or below. And assigning
> the hv_gpci event list based on output counter info version
> of underlying plaform.
>
> Fixes: 97bf2640184f ("powerpc/perf/hv-gpci: add the remaining gpci requests")
> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Thanks
Athira
> ---
> Changelog:
>
> v1 -> v2
> - As suggested by Michael Ellerman, using counter_info_version value
> rather then cpu_has_feature() to assign hv-gpci event list.
>
> arch/powerpc/perf/hv-gpci-requests.h | 4 ++++
> arch/powerpc/perf/hv-gpci.c | 35 ++++++++++++++++++++++++++--
> arch/powerpc/perf/hv-gpci.h | 1 +
> arch/powerpc/perf/req-gen/perf.h | 17 ++++++++++++++
> 4 files changed, 55 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h
> index 8965b4463d43..baef3d082de9 100644
> --- a/arch/powerpc/perf/hv-gpci-requests.h
> +++ b/arch/powerpc/perf/hv-gpci-requests.h
> @@ -79,6 +79,7 @@ REQUEST(__field(0, 8, partition_id)
> )
> #include I(REQUEST_END)
>
> +#ifdef EVENT_ENABLE
> /*
> * Not available for counter_info_version >= 0x8, use
> * run_instruction_cycles_by_partition(0x100) instead.
> @@ -92,6 +93,7 @@ REQUEST(__field(0, 8, partition_id)
> __count(0x10, 8, cycles)
> )
> #include I(REQUEST_END)
> +#endif
>
> #define REQUEST_NAME system_performance_capabilities
> #define REQUEST_NUM 0x40
> @@ -103,6 +105,7 @@ REQUEST(__field(0, 1, perf_collect_privileged)
> )
> #include I(REQUEST_END)
>
> +#ifdef EVENT_ENABLE
> #define REQUEST_NAME processor_bus_utilization_abc_links
> #define REQUEST_NUM 0x50
> #define REQUEST_IDX_KIND "hw_chip_id=?"
> @@ -194,6 +197,7 @@ REQUEST(__field(0, 4, phys_processor_idx)
> __count(0x28, 8, instructions_completed)
> )
> #include I(REQUEST_END)
> +#endif
>
> /* Processor_core_power_mode (0x95) skipped, no counters */
> /* Affinity_domain_information_by_virtual_processor (0xA0) skipped,
> diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
> index 5eb60ed5b5e8..6eeabf3975e5 100644
> --- a/arch/powerpc/perf/hv-gpci.c
> +++ b/arch/powerpc/perf/hv-gpci.c
> @@ -70,9 +70,9 @@ static const struct attribute_group format_group = {
> .attrs = format_attrs,
> };
>
> -static const struct attribute_group event_group = {
> +static struct attribute_group event_group = {
> .name = "events",
> - .attrs = hv_gpci_event_attrs,
> + /* .attrs is set in init */
> };
>
> #define HV_CAPS_ATTR(_name, _format) \
> @@ -330,6 +330,7 @@ static int hv_gpci_init(void)
> int r;
> unsigned long hret;
> struct hv_perf_caps caps;
> + struct hv_gpci_request_buffer *arg;
>
> hv_gpci_assert_offsets_correct();
>
> @@ -353,6 +354,36 @@ static int hv_gpci_init(void)
> /* sampling not supported */
> h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
>
> + arg = (void *)get_cpu_var(hv_gpci_reqb);
> + memset(arg, 0, HGPCI_REQ_BUFFER_SIZE);
> +
> + /*
> + * hcall H_GET_PERF_COUNTER_INFO populates the output
> + * counter_info_version value based on the system hypervisor.
> + * Pass the counter request 0x10 corresponds to request type
> + * 'Dispatch_timebase_by_processor', to get the supported
> + * counter_info_version.
> + */
> + arg->params.counter_request = cpu_to_be32(0x10);
> +
> + r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
> + virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE);
> + if (r) {
> + pr_devel("hcall failed, can't get supported counter_info_version: 0x%x\n", r);
> + arg->params.counter_info_version_out = 0x8;
> + }
> +
> + /*
> + * Use counter_info_version_out value to assign
> + * required hv-gpci event list.
> + */
> + if (arg->params.counter_info_version_out >= 0x8)
> + event_group.attrs = hv_gpci_event_attrs;
> + else
> + event_group.attrs = hv_gpci_event_attrs_v6;
> +
> + put_cpu_var(hv_gpci_reqb);
> +
> r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1);
> if (r)
> return r;
> diff --git a/arch/powerpc/perf/hv-gpci.h b/arch/powerpc/perf/hv-gpci.h
> index 4d108262bed7..10aba0ccb434 100644
> --- a/arch/powerpc/perf/hv-gpci.h
> +++ b/arch/powerpc/perf/hv-gpci.h
> @@ -26,6 +26,7 @@ enum {
> #define REQUEST_FILE "../hv-gpci-requests.h"
> #define NAME_LOWER hv_gpci
> #define NAME_UPPER HV_GPCI
> +#define EVENT_ENABLE
> #include "req-gen/perf.h"
> #undef REQUEST_FILE
> #undef NAME_LOWER
> diff --git a/arch/powerpc/perf/req-gen/perf.h b/arch/powerpc/perf/req-gen/perf.h
> index fa9bc804e67a..e0b355931271 100644
> --- a/arch/powerpc/perf/req-gen/perf.h
> +++ b/arch/powerpc/perf/req-gen/perf.h
> @@ -139,6 +139,23 @@ PMU_EVENT_ATTR_STRING( \
> #define REQUEST_(r_name, r_value, r_idx_1, r_fields) \
> r_fields
>
> +/* Generate event list for platforms with counter_info_version 0x6 or below */
> +static __maybe_unused struct attribute *hv_gpci_event_attrs_v6[] = {
> +#include REQUEST_FILE
> + NULL
> +};
> +
> +/*
> + * Based on getPerfCountInfo v1.018 documentation, some of the hv-gpci
> + * events got deprecated for platforms firmware that supports
> + * counter_info_version 0x8 or above.
> + * Undefining macro EVENT_ENABLE, to disable the addition of deprecated
> + * events in "hv_gpci_event_attrs" attribute group, for platforms that
> + * supports counter_info_version 0x8 or above.
> + */
> +#undef EVENT_ENABLE
> +
> +/* Generate event list for platforms with counter_info_version 0x8 or above*/
> static __maybe_unused struct attribute *hv_gpci_event_attrs[] = {
> #include REQUEST_FILE
> NULL
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list
2022-10-28 15:48 [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list Kajol Jain
2022-11-03 6:47 ` Athira Rajeev
@ 2022-11-24 11:48 ` Michael Ellerman
2022-11-29 10:53 ` kajoljain
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2022-11-24 11:48 UTC (permalink / raw)
To: Kajol Jain; +Cc: kjain, atrajeev, maddy, linuxppc-dev, disgoel
Kajol Jain <kjain@linux.ibm.com> writes:
> Based on getPerfCountInfo v1.018 documentation, some of the
> hv_gpci events got deprecated for platforms firmware that
^ ^
were platform
> supports counter_info_version 0x8 or above.
>
> Patch fixes the hv_gpci event list by adding a new attribute
^
Fix the ...
> group called "hv_gpci_event_attrs_v6" and a "EVENT_ENABLE"
Can we please give that macro a more descriptive name?
EVENT_ENABLE implies it enables/disables all events, but it's only
certain ones.
> macro to enable these events for platform firmware
> that supports counter_info_version 0x6 or below. And assigning
> the hv_gpci event list based on output counter info version
> of underlying plaform.
>
> Fixes: 97bf2640184f ("powerpc/perf/hv-gpci: add the remaining gpci requests")
> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> ---
> Changelog:
>
> v1 -> v2
> - As suggested by Michael Ellerman, using counter_info_version value
> rather then cpu_has_feature() to assign hv-gpci event list.
>
> arch/powerpc/perf/hv-gpci-requests.h | 4 ++++
> arch/powerpc/perf/hv-gpci.c | 35 ++++++++++++++++++++++++++--
> arch/powerpc/perf/hv-gpci.h | 1 +
> arch/powerpc/perf/req-gen/perf.h | 17 ++++++++++++++
> 4 files changed, 55 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h
> index 8965b4463d43..baef3d082de9 100644
> --- a/arch/powerpc/perf/hv-gpci-requests.h
> +++ b/arch/powerpc/perf/hv-gpci-requests.h
> @@ -79,6 +79,7 @@ REQUEST(__field(0, 8, partition_id)
> )
> #include I(REQUEST_END)
>
> +#ifdef EVENT_ENABLE
> /*
> * Not available for counter_info_version >= 0x8, use
> * run_instruction_cycles_by_partition(0x100) instead.
> @@ -92,6 +93,7 @@ REQUEST(__field(0, 8, partition_id)
> __count(0x10, 8, cycles)
> )
> #include I(REQUEST_END)
> +#endif
>
> #define REQUEST_NAME system_performance_capabilities
> #define REQUEST_NUM 0x40
> @@ -103,6 +105,7 @@ REQUEST(__field(0, 1, perf_collect_privileged)
> )
> #include I(REQUEST_END)
>
> +#ifdef EVENT_ENABLE
> #define REQUEST_NAME processor_bus_utilization_abc_links
> #define REQUEST_NUM 0x50
> #define REQUEST_IDX_KIND "hw_chip_id=?"
> @@ -194,6 +197,7 @@ REQUEST(__field(0, 4, phys_processor_idx)
> __count(0x28, 8, instructions_completed)
> )
> #include I(REQUEST_END)
> +#endif
>
> /* Processor_core_power_mode (0x95) skipped, no counters */
> /* Affinity_domain_information_by_virtual_processor (0xA0) skipped,
> diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
> index 5eb60ed5b5e8..6eeabf3975e5 100644
> --- a/arch/powerpc/perf/hv-gpci.c
> +++ b/arch/powerpc/perf/hv-gpci.c
> @@ -70,9 +70,9 @@ static const struct attribute_group format_group = {
> .attrs = format_attrs,
> };
>
> -static const struct attribute_group event_group = {
> +static struct attribute_group event_group = {
> .name = "events",
> - .attrs = hv_gpci_event_attrs,
> + /* .attrs is set in init */
> };
>
> #define HV_CAPS_ATTR(_name, _format) \
> @@ -330,6 +330,7 @@ static int hv_gpci_init(void)
> int r;
> unsigned long hret;
> struct hv_perf_caps caps;
> + struct hv_gpci_request_buffer *arg;
>
> hv_gpci_assert_offsets_correct();
>
> @@ -353,6 +354,36 @@ static int hv_gpci_init(void)
> /* sampling not supported */
> h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
>
> + arg = (void *)get_cpu_var(hv_gpci_reqb);
> + memset(arg, 0, HGPCI_REQ_BUFFER_SIZE);
> +
> + /*
> + * hcall H_GET_PERF_COUNTER_INFO populates the output
> + * counter_info_version value based on the system hypervisor.
> + * Pass the counter request 0x10 corresponds to request type
^
which
> + * 'Dispatch_timebase_by_processor', to get the supported
> + * counter_info_version.
> + */
> + arg->params.counter_request = cpu_to_be32(0x10);
> +
> + r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
> + virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE);
> + if (r) {
> + pr_devel("hcall failed, can't get supported counter_info_version: 0x%x\n", r);
> + arg->params.counter_info_version_out = 0x8;
> + }
> +
> + /*
> + * Use counter_info_version_out value to assign
> + * required hv-gpci event list.
> + */
> + if (arg->params.counter_info_version_out >= 0x8)
> + event_group.attrs = hv_gpci_event_attrs;
> + else
> + event_group.attrs = hv_gpci_event_attrs_v6;
> +
> + put_cpu_var(hv_gpci_reqb);
> +
> r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1);
> if (r)
> return r;
> diff --git a/arch/powerpc/perf/hv-gpci.h b/arch/powerpc/perf/hv-gpci.h
> index 4d108262bed7..10aba0ccb434 100644
> --- a/arch/powerpc/perf/hv-gpci.h
> +++ b/arch/powerpc/perf/hv-gpci.h
> @@ -26,6 +26,7 @@ enum {
> #define REQUEST_FILE "../hv-gpci-requests.h"
> #define NAME_LOWER hv_gpci
> #define NAME_UPPER HV_GPCI
> +#define EVENT_ENABLE
> #include "req-gen/perf.h"
> #undef REQUEST_FILE
> #undef NAME_LOWER
> diff --git a/arch/powerpc/perf/req-gen/perf.h b/arch/powerpc/perf/req-gen/perf.h
> index fa9bc804e67a..e0b355931271 100644
> --- a/arch/powerpc/perf/req-gen/perf.h
> +++ b/arch/powerpc/perf/req-gen/perf.h
> @@ -139,6 +139,23 @@ PMU_EVENT_ATTR_STRING( \
> #define REQUEST_(r_name, r_value, r_idx_1, r_fields) \
> r_fields
>
> +/* Generate event list for platforms with counter_info_version 0x6 or below */
> +static __maybe_unused struct attribute *hv_gpci_event_attrs_v6[] = {
> +#include REQUEST_FILE
> + NULL
> +};
> +
> +/*
> + * Based on getPerfCountInfo v1.018 documentation, some of the hv-gpci
> + * events got deprecated for platforms firmware that supports
Same wording as in the change log.
> + * counter_info_version 0x8 or above.
> + * Undefining macro EVENT_ENABLE, to disable the addition of deprecated
> + * events in "hv_gpci_event_attrs" attribute group, for platforms that
> + * supports counter_info_version 0x8 or above.
> + */
> +#undef EVENT_ENABLE
> +
> +/* Generate event list for platforms with counter_info_version 0x8 or above*/
> static __maybe_unused struct attribute *hv_gpci_event_attrs[] = {
> #include REQUEST_FILE
> NULL
> --
> 2.31.1
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list
2022-11-24 11:48 ` Michael Ellerman
@ 2022-11-29 10:53 ` kajoljain
0 siblings, 0 replies; 4+ messages in thread
From: kajoljain @ 2022-11-29 10:53 UTC (permalink / raw)
To: Michael Ellerman; +Cc: atrajeev, linuxppc-dev, maddy, disgoel
On 11/24/22 17:18, Michael Ellerman wrote:
> Kajol Jain <kjain@linux.ibm.com> writes:
>> Based on getPerfCountInfo v1.018 documentation, some of the
>> hv_gpci events got deprecated for platforms firmware that
> ^ ^
> were platform
>
>> supports counter_info_version 0x8 or above.
>>
>> Patch fixes the hv_gpci event list by adding a new attribute
> ^
> Fix the ...
>
>> group called "hv_gpci_event_attrs_v6" and a "EVENT_ENABLE"
>
> Can we please give that macro a more descriptive name?
>
> EVENT_ENABLE implies it enables/disables all events, but it's only
> certain ones.
Hi Michael,
Thanks for the review comments, I will make these changes in next
version.
Thanks,
Kajol Jain
>
>> macro to enable these events for platform firmware
>> that supports counter_info_version 0x6 or below. And assigning
>> the hv_gpci event list based on output counter info version
>> of underlying plaform.
>>
>> Fixes: 97bf2640184f ("powerpc/perf/hv-gpci: add the remaining gpci requests")
>> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
>> Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
>> ---
>> Changelog:
>>
>> v1 -> v2
>> - As suggested by Michael Ellerman, using counter_info_version value
>> rather then cpu_has_feature() to assign hv-gpci event list.
>>
>> arch/powerpc/perf/hv-gpci-requests.h | 4 ++++
>> arch/powerpc/perf/hv-gpci.c | 35 ++++++++++++++++++++++++++--
>> arch/powerpc/perf/hv-gpci.h | 1 +
>> arch/powerpc/perf/req-gen/perf.h | 17 ++++++++++++++
>> 4 files changed, 55 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h
>> index 8965b4463d43..baef3d082de9 100644
>> --- a/arch/powerpc/perf/hv-gpci-requests.h
>> +++ b/arch/powerpc/perf/hv-gpci-requests.h
>> @@ -79,6 +79,7 @@ REQUEST(__field(0, 8, partition_id)
>> )
>> #include I(REQUEST_END)
>>
>> +#ifdef EVENT_ENABLE
>> /*
>> * Not available for counter_info_version >= 0x8, use
>> * run_instruction_cycles_by_partition(0x100) instead.
>> @@ -92,6 +93,7 @@ REQUEST(__field(0, 8, partition_id)
>> __count(0x10, 8, cycles)
>> )
>> #include I(REQUEST_END)
>> +#endif
>>
>> #define REQUEST_NAME system_performance_capabilities
>> #define REQUEST_NUM 0x40
>> @@ -103,6 +105,7 @@ REQUEST(__field(0, 1, perf_collect_privileged)
>> )
>> #include I(REQUEST_END)
>>
>> +#ifdef EVENT_ENABLE
>> #define REQUEST_NAME processor_bus_utilization_abc_links
>> #define REQUEST_NUM 0x50
>> #define REQUEST_IDX_KIND "hw_chip_id=?"
>> @@ -194,6 +197,7 @@ REQUEST(__field(0, 4, phys_processor_idx)
>> __count(0x28, 8, instructions_completed)
>> )
>> #include I(REQUEST_END)
>> +#endif
>>
>> /* Processor_core_power_mode (0x95) skipped, no counters */
>> /* Affinity_domain_information_by_virtual_processor (0xA0) skipped,
>> diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
>> index 5eb60ed5b5e8..6eeabf3975e5 100644
>> --- a/arch/powerpc/perf/hv-gpci.c
>> +++ b/arch/powerpc/perf/hv-gpci.c
>> @@ -70,9 +70,9 @@ static const struct attribute_group format_group = {
>> .attrs = format_attrs,
>> };
>>
>> -static const struct attribute_group event_group = {
>> +static struct attribute_group event_group = {
>> .name = "events",
>> - .attrs = hv_gpci_event_attrs,
>> + /* .attrs is set in init */
>> };
>>
>> #define HV_CAPS_ATTR(_name, _format) \
>> @@ -330,6 +330,7 @@ static int hv_gpci_init(void)
>> int r;
>> unsigned long hret;
>> struct hv_perf_caps caps;
>> + struct hv_gpci_request_buffer *arg;
>>
>> hv_gpci_assert_offsets_correct();
>>
>> @@ -353,6 +354,36 @@ static int hv_gpci_init(void)
>> /* sampling not supported */
>> h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
>>
>> + arg = (void *)get_cpu_var(hv_gpci_reqb);
>> + memset(arg, 0, HGPCI_REQ_BUFFER_SIZE);
>> +
>> + /*
>> + * hcall H_GET_PERF_COUNTER_INFO populates the output
>> + * counter_info_version value based on the system hypervisor.
>> + * Pass the counter request 0x10 corresponds to request type
> ^
> which
>> + * 'Dispatch_timebase_by_processor', to get the supported
>> + * counter_info_version.
>> + */
>> + arg->params.counter_request = cpu_to_be32(0x10);
>> +
>> + r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
>> + virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE);
>> + if (r) {
>> + pr_devel("hcall failed, can't get supported counter_info_version: 0x%x\n", r);
>> + arg->params.counter_info_version_out = 0x8;
>> + }
>> +
>> + /*
>> + * Use counter_info_version_out value to assign
>> + * required hv-gpci event list.
>> + */
>> + if (arg->params.counter_info_version_out >= 0x8)
>> + event_group.attrs = hv_gpci_event_attrs;
>> + else
>> + event_group.attrs = hv_gpci_event_attrs_v6;
>> +
>> + put_cpu_var(hv_gpci_reqb);
>> +
>> r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1);
>> if (r)
>> return r;
>> diff --git a/arch/powerpc/perf/hv-gpci.h b/arch/powerpc/perf/hv-gpci.h
>> index 4d108262bed7..10aba0ccb434 100644
>> --- a/arch/powerpc/perf/hv-gpci.h
>> +++ b/arch/powerpc/perf/hv-gpci.h
>> @@ -26,6 +26,7 @@ enum {
>> #define REQUEST_FILE "../hv-gpci-requests.h"
>> #define NAME_LOWER hv_gpci
>> #define NAME_UPPER HV_GPCI
>> +#define EVENT_ENABLE
>> #include "req-gen/perf.h"
>> #undef REQUEST_FILE
>> #undef NAME_LOWER
>> diff --git a/arch/powerpc/perf/req-gen/perf.h b/arch/powerpc/perf/req-gen/perf.h
>> index fa9bc804e67a..e0b355931271 100644
>> --- a/arch/powerpc/perf/req-gen/perf.h
>> +++ b/arch/powerpc/perf/req-gen/perf.h
>> @@ -139,6 +139,23 @@ PMU_EVENT_ATTR_STRING( \
>> #define REQUEST_(r_name, r_value, r_idx_1, r_fields) \
>> r_fields
>>
>> +/* Generate event list for platforms with counter_info_version 0x6 or below */
>> +static __maybe_unused struct attribute *hv_gpci_event_attrs_v6[] = {
>> +#include REQUEST_FILE
>> + NULL
>> +};
>> +
>> +/*
>> + * Based on getPerfCountInfo v1.018 documentation, some of the hv-gpci
>> + * events got deprecated for platforms firmware that supports
>
> Same wording as in the change log.
>
>> + * counter_info_version 0x8 or above.
>> + * Undefining macro EVENT_ENABLE, to disable the addition of deprecated
>> + * events in "hv_gpci_event_attrs" attribute group, for platforms that
>> + * supports counter_info_version 0x8 or above.
>> + */
>> +#undef EVENT_ENABLE
>> +
>> +/* Generate event list for platforms with counter_info_version 0x8 or above*/
>> static __maybe_unused struct attribute *hv_gpci_event_attrs[] = {
>> #include REQUEST_FILE
>> NULL
>> --
>> 2.31.1
>
> cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-29 10:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 15:48 [PATCH v2] powerpc/hv-gpci: Fix hv_gpci event list Kajol Jain
2022-11-03 6:47 ` Athira Rajeev
2022-11-24 11:48 ` Michael Ellerman
2022-11-29 10:53 ` kajoljain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).