powerpc/hv-gpci: Fix starting index value
Subsystems (2)
PATCH 1/5 powerpc/hv-gpci: Fix starting index value
Commit 9e9f60108423f ("powerpc/perf/{hv-gpci, hv-common}: generate requests with counters annotated") adds a framework for defining gpci counters.
In this patch, they adds starting_index value as '0xffffffffffffffff'. which is wrong as starting_index is of size 32 bits.
Because of this, incase we try to run hv-gpci event we get error.
In power9 machine:
command#: perf stat -e hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/
-C 0 -I 1000
event syntax error: '..bie_count_and_time_tlbie_instructions_issued/'
\___ value too big for format, maximum is 4294967295This patch fix this issue and changes starting_index value to '0xffffffff'
After this patch:
command#: perf stat -e hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ -C 0 -I 1000
1.000085786 1,024 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/
2.000287818 1,024 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/^C 2.439113909 17,408 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/
requests with counters annotated")
--- arch/powerpc/perf/hv-gpci-requests.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/perf/hv-gpci-requests.h +3 -3
@@ -95,7 +95,7 @@ REQUEST(__field(0, 8, partition_id)#define REQUEST_NAME system_performance_capabilities#define REQUEST_NUM 0x40 -#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" +#define REQUEST_IDX_KIND "starting_index=0xffffffff"#include I (REQUEST_BEGIN ) REQUEST(__field(0, 1, perf_collect_privileged) __field(0x1, 1, capability_mask)
@@ -223,7 +223,7 @@ REQUEST(__field(0, 2, partition_id)#define REQUEST_NAME system_hypervisor_times#define REQUEST_NUM 0xF0 -#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" +#define REQUEST_IDX_KIND "starting_index=0xffffffff"#include I (REQUEST_BEGIN ) REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors) __count(0x8, 8, time_spent_processing_virtual_processor_timers)
@@ -234,7 +234,7 @@ REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors)#define REQUEST_NAME system_tlbie_count_and_time#define REQUEST_NUM 0xF4 -#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" +#define REQUEST_IDX_KIND "starting_index=0xffffffff"#include I (REQUEST_BEGIN )REQUEST (__count (0 ,8 , tlbie_instructions_issued)/*
Signature · 1 line
2.26.2
PATCH 2/5 Documentation/ABI: Add ABI documentation for hv-24x7 format
This patch adds ABI documentation for hv-24x7 format.
--- .../sysfs-bus-event_source-devices-hv_24x7 | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+)
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +25 -0
@@ -1,3 +1,28 @@ +What: /sys/bus/event_source/devices/hv_24x7/format +Date: September 2020 +Contact: Linux on PowerPC Developer List <[email protected]> +Description: Read-only. Attribute group to describe the magic bits + that go into perf_event_attr.config for a particular pmu. + (See ABI/testing/sysfs-bus-event_source-devices-format). + + Each attribute under this group defines a bit range of the + perf_event_attr.config. All supported attributes are listed + below. + + chip = "config:16-31" + core = "config:16-31" + domain = "config:0-3" + lpar = "config:0-15" + offset = "config:32-63" + vcpu = "config:16-31" + + For example, + + PM_PB_CYC = "domain=1,offset=0x80,chip=?,lpar=0x0" + + In this event, '?' after chip specifies that + this value will be provided by user while running this event. + What: /sys/bus/event_source/devices/hv_24x7/interface/catalog Date: February 2014 Contact: Linux on PowerPC Developer List <[email protected]>
Signature · 1 line
2.26.2
PATCH 3/5 Documentation/ABI: Add ABI documentation for hv-gpci format
In reply to Kajol JainThis patch adds ABI documentation for hv-gpci event format.
--- .../sysfs-bus-event_source-devices-hv_gpci | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci +31 -0
@@ -1,3 +1,34 @@ +What: /sys/bus/event_source/devices/hv_gpci/format +Date: September 2020 +Contact: Linux on PowerPC Developer List <[email protected]> +Description: Read-only. Attribute group to describe the magic bits + that go into perf_event_attr.config for a particular pmu. + (See ABI/testing/sysfs-bus-event_source-devices-format). + + Each attribute under this group defines a bit range of the + perf_event_attr.config. All supported attributes are listed + below. + + counter_info_version = "config:16-23" + length = "config:24-31" + partition_id = "config:32-63" + request = "config:0-31" + sibling_part_id = "config:32-63" + hw_chip_id = "config:32-63" + offset = "config:32-63" + phys_processor_idx = "config:32-63" + secondary_index = "config:0-15" + starting_index = "config:32-63" + + For example, + + processor_core_utilization_instructions_completed = "request=0x94, + phys_processor_idx=?,counter_info_version=0x8, + length=8,offset=0x18" + + In this event, '?' after phys_processor_idx specifies this value + this value will be provided by user while running this event. + What: /sys/bus/event_source/devices/hv_gpci/interface/collect_privileged Date: February 2014 Contact: Linux on PowerPC Developer List <[email protected]>
Signature · 1 line
2.26.2
PATCH 4/5 powerpc/perf/hv-gpci: Add cpu hotplug support
In reply to Kajol JainPatch here adds cpu hotplug functions to hv_gpci pmu. A new cpuhp_state "CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE" enum is added.
The online callback function updates the cpumask only if its empty. As the primary intention of adding hotplug support is to designate a CPU to make HCALL to collect the counter data.
The offline function test and clear corresponding cpu in a cpumask and update cpumask to any other active cpu.
--- arch/powerpc/perf/hv-gpci.c | 46 +++++++++++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 2 files changed, 47 insertions(+)
arch/powerpc/perf/hv-gpci.c +46 -0
@@ -48,6 +48,8 @@ EVENT_DEFINE_RANGE_FORMAT(length, config1, 24, 31);/* u32, byte offset */ EVENT_DEFINE_RANGE_FORMAT (offset, config1,32 ,63 ); +static cpumask_t hv_gpci_cpumask; +static struct attribute *format_attrs[] = { &format_attr_request.attr, &format_attr_starting_index.attr,
@@ -275,6 +277,45 @@ static struct pmu h_gpci_pmu = { .capabilities = PERF_PMU_CAP_NO_EXCLUDE, }; +static int ppc_hv_gpci_cpu_online (unsigned int cpu) +{ +if (cpumask_empty (&hv_gpci_cpumask)) +cpumask_set_cpu (cpu, &hv_gpci_cpumask); + +return 0 ; +} + +static int ppc_hv_gpci_cpu_offline (unsigned int cpu) +{ +int target; + +/* Check if exiting cpu is used for collecting gpci events */ +if (!cpumask_test_and_clear_cpu (cpu, &hv_gpci_cpumask)) +return 0 ; + +/* Find a new cpu to collect gpci events */ + target =cpumask_last (cpu_active_mask); + +if (target <0 || target >= nr_cpu_ids) { +pr_err ("hv_gpci: CPU hotplug init failed\n" ); +return -1 ; + } + +/* Migrate gpci events to the new target */ +cpumask_set_cpu (target, &hv_gpci_cpumask); +perf_pmu_migrate_context (&h_gpci_pmu, cpu, target); + +return 0 ; +} + +static int hv_gpci_cpu_hotplug_init (void ) +{ +return cpuhp_setup_state (CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE , +"perf/powerpc/hv_gcpi:online" , + ppc_hv_gpci_cpu_online, + ppc_hv_gpci_cpu_offline); +} +static int hv_gpci_init (void ) {int r;
@@ -295,6 +336,11 @@ static int hv_gpci_init(void)return -ENODEV ; } +/* init cpuhotplug */ + r =hv_gpci_cpu_hotplug_init (); +if (r) +return r; +/* sampling not supported */ h_gpci_pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ;
include/linux/cpuhotplug.h +1 -0
@@ -182,6 +182,7 @@ enum cpuhp_state {CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE ,CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE , CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE, +CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE ,CPUHP_AP_WATCHDOG_ONLINE ,CPUHP_AP_WORKQUEUE_ONLINE , CPUHP_AP_RCUTREE_ONLINE,
Signature · 1 line
2.26.2
PATCH 5/5 powerpc/hv-gpci: Add sysfs files inside hv-gpci device to show cpumask
In reply to Kajol JainPatch here adds a cpumask attr to hv_gpci pmu along with ABI documentation.
Primary use to expose the cpumask is for the perf tool which has the capability to parse the driver sysfs folder and understand the cpumask file. Having cpumask file will reduce the number of perf command line parameters (will avoid "-C" option in the perf tool command line). It can also notify the user which is
the current cpu used to retrieve the counter data.
command:# cat /sys/devices/hv_gpci/cpumask
0
--- .../sysfs-bus-event_source-devices-hv_gpci | 7 +++++++ arch/powerpc/perf/hv-gpci.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+)
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci +7 -0
@@ -72,3 +72,10 @@ Contact: Linux on PowerPC Developer List <[email protected]> Description: A number indicating the latest version of the gpci interface that the kernel is aware of. + +What: /sys/devices/hv_gpci/cpumask +Date: October 2020 +Contact: Linux on PowerPC Developer List <[email protected]> +Description: read only + This sysfs file exposes the cpumask which is designated to make + HCALLs to retrieve hv-gpci pmu event counter data.
arch/powerpc/perf/hv-gpci.c +18 -0
@@ -96,7 +96,15 @@ static ssize_t kernel_version_show(struct device *dev,return sprintf (page,"0x%x\n" ,COUNTER_INFO_VERSION_CURRENT ); } +static ssize_t cpumask_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +return cpumap_print_to_pagebuf (true, buf, &hv_gpci_cpumask); +} +static DEVICE_ATTR_RO (kernel_version); +static DEVICE_ATTR_RO (cpumask); +HV_CAPS_ATTR (version,"0x%x\n" );HV_CAPS_ATTR (ga,"%d\n" );HV_CAPS_ATTR (expanded,"%d\n" );
@@ -113,6 +121,15 @@ static struct attribute *interface_attrs[] = { NULL, }; +static struct attribute *cpumask_attrs[] = { + &dev_attr_cpumask.attr, +NULL , +}; + +static struct attribute_group cpumask_attr_group = { + .attrs = cpumask_attrs, +}; +static struct attribute_group interface_group = { .name ="interface" , .attrs = interface_attrs,
@@ -122,6 +139,7 @@ static const struct attribute_group *attr_groups[] = { &format_group, &event_group, &interface_group, + &cpumask_attr_group, NULL, };
Signature · 1 line
2.26.2
Michael Ellerman
AppliedQuoted 9 lines · Kajol Jain
Commit
9e9f60108423f("powerpc/perf/{hv-gpci, hv-common}: generate requests with counters annotated") adds a framework for defining gpci counters.
In this patch, they addsstarting_indexvalue as '0xffffffffffffffff'. which is wrong asstarting_indexis of size 32 bits.Because of this, incase we try to run hv-gpci event we get error.
[...]
Applied to powerpc/next.
[1/5] powerpc/perf/hv-gpci: Fix starting index value
https://git.kernel.org/powerpc/c/0f9866f7e85765bbda86666df56c92f377c3bc10 [2/5] Documentation/ABI: Add ABI documentation for hv-24x7 format https://git.kernel.org/powerpc/c/264a034099b6e3c76fae85e75329373f3652a033 [3/5] Documentation/ABI: Add ABI documentation for hv-gpci format https://git.kernel.org/powerpc/c/435387dd1f6fc03c64e3fdb4cc8737904c08a4db [4/5] powerpc/perf/hv-gpci: Add cpu hotplug support https://git.kernel.org/powerpc/c/dcb5cdf60a1fbbdb3b4dd2abc562206481f09ef1 [5/5] powerpc/hv-gpci: Add sysfs files inside hv-gpci device to show cpumask https://git.kernel.org/powerpc/c/09b791d95559ef82542063333ecaa2ac9d57118e
cheers