drivers/perf: hisi: Add driver for HNS3 PMU
Subsystems (5)
v7 cover drivers/perf: hisi: Add driver for HNS3 PMU
Resend this patch-set for adding reviewed-by of John Garry and Shaokun Zhang.
This patch-set adds driver for HNS3(HiSilicon network system version 3) PMU and doc to descript it.
Change logs:
V6 -> V7:
modify the comments of Will Deacon:
- Modify format of event number shown for user.
- Add a trailing space for func-intr when show filter mode.
- Format the bdf number as the way "b:d.f" when show bdf_min and bdf_max.
- Add subevent, event_type, ext_counter_used and real_event for hns3_pmu_format_attr[].
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
V5 -> V6:
- Modify prefix hns3_get into hns3_pmu_get.
- Some switch cases return directly.
- Modify failed log when io remap failed.
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
V4 -> V5:
- Add COMPILE_TEST and include io-64-nonatomic-hi-lo.h as suggestion of
John Garry.
V3 -> V4:
- Modify the comments of John Garry.
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
V2 -> V3:
- Modify the comments of John Garry.
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
V1 -> V2:
- Modify the comments of John Garry.
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
Guangbin Huang (2):
drivers/perf: hisi: Add description for HNS3 PMU driver drivers/perf: hisi: add driver for HNS3 PMU
Documentation/admin-guide/perf/hns3-pmu.rst | 136 ++ MAINTAINERS | 6 + drivers/perf/hisilicon/Kconfig | 10 + drivers/perf/hisilicon/Makefile | 1 + drivers/perf/hisilicon/hns3_pmu.c | 1662 +++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 6 files changed, 1816 insertions(+) create mode 100644 Documentation/admin-guide/perf/hns3-pmu.rst create mode 100644 drivers/perf/hisilicon/hns3_pmu.c
Signature · 1 line
2.33.0
PATCH RESEND v7 1/2 drivers/perf: hisi: Add description for HNS3 PMU driver
HNS3 PMU End Point device is supported on HiSilicon HIP09 platform, so add document hns3-pmu.rst to provide guidance on how to use it.
--- Documentation/admin-guide/perf/hns3-pmu.rst | 136 ++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Documentation/admin-guide/perf/hns3-pmu.rst
Documentation/admin-guide/perf/hns3-pmu.rst new file +136 -0
@@ -0,0 +1,136 @@ +====================================== +HNS3 Performance Monitoring Unit (PMU) +====================================== + +HNS3(HiSilicon network system 3) Performance Monitoring Unit (PMU) is an +End Point device to collect performance statistics of HiSilicon SoC NIC. +On Hip09, each SICL(Super I/O cluster) has one PMU device. + +HNS3 PMU supports collection of performance statistics such as bandwidth, +latency, packet rate and interrupt rate. + +Each HNS3 PMU supports 8 hardware events. + +HNS3 PMU driver +=============== + +The HNS3 PMU driver registers a perf PMU with the name of its sicl id.:: + + /sys/devices/hns3_pmu_sicl_<sicl_id> + +PMU driver provides description of available events, filter modes, format, +identifier and cpumask in sysfs. + +The "events" directory describes the event code of all supported events +shown in perf list. + +The "filtermode" directory describes the supported filter modes of each +event. + +The "format" directory describes all formats of the config (events) and +config1 (filter options) fields of the perf_event_attr structure. + +The "identifier" file shows version of PMU hardware device. + +The "bdf_min" and "bdf_max" files show the supported bdf range of each +pmu device. + +The "hw_clk_freq" file shows the hardware clock frequency of each pmu +device. + +Example usage of checking event code and subevent code:: + + $# cat /sys/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_time + config=0x00204 + $# cat /sys/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_packet_num + config=0x10204 + +Each performance statistic has a pair of events to get two values to +calculate real performance data in userspace. + +The bits 0~15 of config (here 0x0204) are the true hardware event code. If +two events have same value of bits 0~15 of config, that means they are +event pair. And the bit 16 of config indicates getting counter 0 or +counter 1 of hardware event. + +After getting two values of event pair in usersapce, the formula of +computation to calculate real performance data is::: + + counter 0 / counter 1 + +Example usage of checking supported filter mode:: + + $# cat /sys/devices/hns3_pmu_sicl_0/filtermode/bw_ssu_rpu_byte_num + filter mode supported: global/port/port-tc/func/func-queue/ + +Example usage of perf:: + + $# perf list + hns3_pmu_sicl_0/bw_ssu_rpu_byte_num/ [kernel PMU event] + hns3_pmu_sicl_0/bw_ssu_rpu_time/ [kernel PMU event] + ------------------------------------------ + + $# perf stat -g -e hns3_pmu_sicl_0/bw_ssu_rpu_byte_num,global=1/ -e hns3_pmu_sicl_0/bw_ssu_rpu_time,global=1/ -I 1000 + or + $# perf stat -g -e hns3_pmu_sicl_0/config=0x00002,global=1/ -e hns3_pmu_sicl_0/config=0x10002,global=1/ -I 1000 + + +Filter modes +-------------- + +1. global mode +PMU collect performance statistics for all HNS3 PCIe functions of IO DIE. +Set the "global" filter option to 1 will enable this mode. +Example usage of perf:: + + $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,global=1/ -I 1000 + +2. port mode +PMU collect performance statistic of one whole physical port. The port id +is same as mac id. The "tc" filter option must be set to 0xF in this mode, +here tc stands for traffic class. + +Example usage of perf:: + + $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0xF/ -I 1000 + +3. port-tc mode +PMU collect performance statistic of one tc of physical port. The port id +is same as mac id. The "tc" filter option must be set to 0 ~ 7 in this +mode. +Example usage of perf:: + + $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0/ -I 1000 + +4. func mode +PMU collect performance statistic of one PF/VF. The function id is BDF of +PF/VF, its conversion formula:: + + func = (bus << 8) + (device << 3) + (function) + +for example: + BDF func + 35:00.0 0x3500 + 35:00.1 0x3501 + 35:01.0 0x3508 + +In this mode, the "queue" filter option must be set to 0xFFFF. +Example usage of perf:: + + $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0xFFFF/ -I 1000 + +5. func-queue mode +PMU collect performance statistic of one queue of PF/VF. The function id +is BDF of PF/VF, the "queue" filter option must be set to the exact queue +id of function. +Example usage of perf:: + + $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0/ -I 1000 + +6. func-intr mode +PMU collect performance statistic of one interrupt of PF/VF. The function +id is BDF of PF/VF, the "intr" filter option must be set to the exact +interrupt id of function. +Example usage of perf:: + + $# perf stat -a -e hns3_pmu_sicl_0/config=0x00301,bdf=0x3500,intr=0/ -I 1000
Signature · 1 line
2.33.0
PATCH RESEND v7 2/2 drivers/perf: hisi: add driver for HNS3 PMU
In reply to Guangbin HuangHNS3(HiSilicon Network System 3) PMU is RCiEP device in HiSilicon SoC NIC, supports collection of performance statistics such as bandwidth, latency, packet rate and interrupt rate.
NIC of each SICL has one PMU device for it. Driver registers each PMU device to perf, and exports information of supported events, filter mode of each event, bdf range, hardware clock frequency, identifier and so on via sysfs.
Each PMU device has its own registers of control, counters and interrupt, and it supports 8 hardware events, each hardward event has its own registers for configuration, counters and interrupt.
Filter options contains:
event - select event port - select physical port of nic tc - select tc(must be used with port) func - select PF/VF queue - select queue of PF/VF(must be used with func) intr - select interrupt number(must be used with func) global - select all functions of IO DIE
--- MAINTAINERS | 6 + drivers/perf/hisilicon/Kconfig | 10 + drivers/perf/hisilicon/Makefile | 1 + drivers/perf/hisilicon/hns3_pmu.c | 1662 +++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 5 files changed, 1680 insertions(+) create mode 100644 drivers/perf/hisilicon/hns3_pmu.c
MAINTAINERS +6 -0
@@ -8691,6 +8691,12 @@ F: Documentation/admin-guide/perf/hisi-pcie-pmu.rst F: Documentation/admin-guide/perf/hisi-pmu.rst F: drivers/perf/hisilicon +HISILICON HNS3 PMU DRIVER +M: Guangbin Huang <[email protected]> +S: Supported +F: Documentation/admin-guide/perf/hns3-pmu.rst +F: drivers/perf/hisilicon/hns3_pmu.c + HISILICON QM AND ZIP Controller DRIVER M: Zhou Wang <[email protected]> L: [email protected]
drivers/perf/hisilicon/Kconfig +10 -0
@@ -14,3 +14,13 @@ config HISI_PCIE_PMU RCiEP devices. Adds the PCIe PMU into perf events system for monitoring latency, bandwidth etc. + +config HNS3_PMU + tristate "HNS3 PERF PMU" + depends on ARM64 || COMPILE_TEST + depends on PCI + help + Provide support for HNS3 performance monitoring unit (PMU) RCiEP + devices. + Adds the HNS3 PMU into perf events system for monitoring latency, + bandwidth etc.
drivers/perf/hisilicon/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_HISI_PMU) += hisi_uncore_pmu.o hisi_uncore_l3c_pmu.o \ hisi_uncore_pa_pmu.o obj-$(CONFIG_HISI_PCIE_PMU) += hisi_pcie_pmu.o +obj-$(CONFIG_HNS3_PMU) += hns3_pmu.o
drivers/perf/hisilicon/hns3_pmu.c new file +1662 -0
1,662 lines not on this page · raw message
include/linux/cpuhotplug.h +1 -0
@@ -226,6 +226,7 @@ enum cpuhp_state {CPUHP_AP_PERF_ARM_HISI_PA_ONLINE ,CPUHP_AP_PERF_ARM_HISI_SLLC_ONLINE ,CPUHP_AP_PERF_ARM_HISI_PCIE_PMU_ONLINE , +CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE ,CPUHP_AP_PERF_ARM_L2X0_ONLINE ,CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE , CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE,
Signature · 1 line
2.33.0
Will Deacon
maintainerRe: [RESEND PATCH V7 2/2] drivers/perf: hisi: add driver for HNS3 PMU
Quoted 25 lines · Guangbin Huang
HNS3(HiSilicon Network System 3) PMU is RCiEP device in HiSilicon SoC NIC, supports collection of performance statistics such as bandwidth, latency, packet rate and interrupt rate.
NIC of each SICL has one PMU device for it. Driver registers each PMU device to perf, and exports information of supported events, filter mode of each event, bdf range, hardware clock frequency, identifier and so on via sysfs.
Each PMU device has its own registers of control, counters and interrupt, and it supports 8 hardware events, each hardward event has its own registers for configuration, counters and interrupt.
Filter options contains:
event - select event port - select physical port of nic tc - select tc(must be used with port) func - select PF/VF queue - select queue of PF/VF(must be used with func) intr - select interrupt number(must be used with func) global - select all functions of IO DIESigned-off-by Guangbin Huang <[email protected]>Reviewed-by John Garry <[email protected]>Reviewed-by Shaokun Zhang <[email protected]>
Quoted 8 lines
--- MAINTAINERS | 6 + drivers/perf/hisilicon/Kconfig | 10 + drivers/perf/hisilicon/Makefile | 1 + drivers/perf/hisilicon/hns3_pmu.c | 1662 +++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 5 files changed, 1680 insertions(+) create mode 100644 drivers/perf/hisilicon/hns3_pmu.c
This mostly looks good to me, but I have one niggling concern with the ABI:
drivers/perf/hisilicon/hns3_pmu.c line 335
Quoted 12 lines
drivers/perf/hisilicon/hns3_pmu.c new file +12
-0+#define HNS3_PMU_FILTER_ATTR (_name, _config, _start, _end) \ + static inline u64 hns3_pmu_get_##_name(struct perf_event *event) \ + { \ + return FIELD_GET(GENMASK_ULL(_end, _start), \ + event->attr._config); \ + } + +HNS3_PMU_FILTER_ATTR (event, config,0 ,16 ); +HNS3_PMU_FILTER_ATTR (subevent, config,0 ,7 ); +HNS3_PMU_FILTER_ATTR (event_type, config,8 ,15 ); +HNS3_PMU_FILTER_ATTR (ext_counter_used, config,16 ,16 ); +HNS3_PMU_FILTER_ATTR (real_event, config,0 ,15 );
How does perf tool deal with overlapping fields like this? It seems like quite a bad idea to allow things like "event=0xffff,subevent=0" when they are no longer distinct and I don't _think_ any other drivers do this.
Can you remove 'event' and 'real_event' for now, or are they needed?
Will
Re: [RESEND PATCH V7 2/2] drivers/perf: hisi: add driver for HNS3 PMU
Quoted 54 lines · Will Deacon
Quoted 25 lines · Guangbin Huang
HNS3(HiSilicon Network System 3) PMU is RCiEP device in HiSilicon SoC NIC, supports collection of performance statistics such as bandwidth, latency, packet rate and interrupt rate.
NIC of each SICL has one PMU device for it. Driver registers each PMU device to perf, and exports information of supported events, filter mode of each event, bdf range, hardware clock frequency, identifier and so on via sysfs.
Each PMU device has its own registers of control, counters and interrupt, and it supports 8 hardware events, each hardward event has its own registers for configuration, counters and interrupt.
Filter options contains:
event - select event port - select physical port of nic tc - select tc(must be used with port) func - select PF/VF queue - select queue of PF/VF(must be used with func) intr - select interrupt number(must be used with func) global - select all functions of IO DIESigned-off-by Guangbin Huang <[email protected]>Reviewed-by John Garry <[email protected]>Reviewed-by Shaokun Zhang <[email protected]>Quoted 8 lines
--- MAINTAINERS | 6 + drivers/perf/hisilicon/Kconfig | 10 + drivers/perf/hisilicon/Makefile | 1 + drivers/perf/hisilicon/hns3_pmu.c | 1662 +++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 5 files changed, 1680 insertions(+)create mode 100644
drivers/perf/hisilicon/hns3_pmu.cThis mostly looks good to me, but I have one niggling concern with the ABI:
drivers/perf/hisilicon/hns3_pmu.c line 335
Quoted 12 lines
drivers/perf/hisilicon/hns3_pmu.c new file +12
-0+#define HNS3_PMU_FILTER_ATTR (_name, _config, _start, _end) \ + static inline u64 hns3_pmu_get_##_name(struct perf_event *event) \ + { \ + return FIELD_GET(GENMASK_ULL(_end, _start), \ + event->attr._config); \ + } + +HNS3_PMU_FILTER_ATTR (event, config,0 ,16 ); +HNS3_PMU_FILTER_ATTR (subevent, config,0 ,7 ); +HNS3_PMU_FILTER_ATTR (event_type, config,8 ,15 ); +HNS3_PMU_FILTER_ATTR (ext_counter_used, config,16 ,16 ); +HNS3_PMU_FILTER_ATTR (real_event, config,0 ,15 );How does perf tool deal with overlapping fields like this? It seems like quite a bad idea to allow things like "event=0xffff,subevent=0" when they are no longer distinct and I don't _think_ any other drivers do this.
Quoted 5 lines
Can you remove 'event' and '
real_event' for now, or are they needed?Will
.
Ok, I will modify this part.
Gentle ping. Any comment or suggestion is appreciated. Thanks!