drivers: perf: Add Marvell CN10K LLC-TAD pmu driver
Subsystems (2)
v7 cover drivers: perf: Add Marvell CN10K LLC-TAD pmu driver
This series introduces performance monitor driver to Last-level-cache tag-and-data (LLC-TAD) PMU which is an integral part of Marvell CN10K SoCs. The configuration and functionality of the TAD PMU is covered in patch 1. The device tree bindings are dealt in patch 2.
v7:
- use braces around a multi-line conditional statement (Will Deacon)
- remove mask doesn't do anything (Will Deacon)
- restrict compile test dependency to aarch64
v6:
- add COMPILE_TEST dependency (Bharat Bhushan)
- replace sprintf with sysfs_emit (Bharat Bhushan)
v5:
- add prefix, type, description for vendor specific properties in DT bindings (Rob Herring)
v4:
- rebased on kernel v5.14-rc7
- eliminate yamllint errors (Rob Herring)
v3:
- rebased on kernel v5.14-rc5
- disable sampling events via PERF_PMU_CAP_NO_INTERRUPT (Will Deacon)
- convert tad pmu bindings to schema (Will Deacon)
- replace tighter semantics with *_relaxed() accesses (Will Deacon)
- use PMU_EVENT_ATTR_ID generic macro (Will Deacon)
- allow cleanup of allocations through devm_kcalloc() (Will Deacon)
v2:
- rebased on kernel v5.13-rc3
Bhaskara Budiredla (2):
drivers: perf: Add LLC-TAD perf counter support
dt-bindings: perf: Add YAML schemas for Marvell CN10K LLC-TAD pmu
bindings
.../bindings/perf/marvell-cn10k-tad.yaml | 63 +++ drivers/perf/Kconfig | 7 + drivers/perf/Makefile | 1 + drivers/perf/marvell_cn10k_tad_pmu.c | 429 ++++++++++++++++++ 4 files changed, 500 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/marvell-cn10k-tad.yaml create mode 100644 drivers/perf/marvell_cn10k_tad_pmu.c
Signature · 1 line
2.17.1
PATCH v7 1/2 drivers: perf: Add LLC-TAD perf counter support
This driver adds support for Last-level cache tag-and-data unit (LLC-TAD) PMU that is featured in some of the Marvell's CN10K infrastructure silicons.
The LLC is divided into 2N slices distributed across N Mesh tiles in a single-socket configuration. The driver always configures the same counter for all of the TADs. The user would end up effectively reserving one of eight counters in every TAD to look across all TADs. The occurrences of events are aggregated and presented to the user at the end of an application run. The driver does not provide a way for the user to partition TADs so that different TADs are used for different applications.
The event counters are zeroed to start event counting to avoid any rollover issues. TAD perf counters are 64-bit, so it's not currently possible to overflow event counters at current mesh and core frequencies.
To measure tad pmu events use perf tool stat command. For instance:
perf stat -e tad_dat_msh_in_dss,tad_req_msh_out_any <application> perf stat -e tad_alloc_any,tad_hit_any,tad_tag_rd <application>
--- drivers/perf/Kconfig | 7 + drivers/perf/Makefile | 1 + drivers/perf/marvell_cn10k_tad_pmu.c | 429 +++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/perf/marvell_cn10k_tad_pmu.c
drivers/perf/Kconfig +7 -0
@@ -137,6 +137,13 @@ config ARM_DMC620_PMU Support for PMU events monitoring on the ARM DMC-620 memory controller. +config MARVELL_CN10K_TAD_PMU + tristate "Marvell CN10K LLC-TAD PMU" + depends on ARM64 || (COMPILE_TEST && 64BIT) + help + Provides support for Last-Level cache Tag-and-data Units (LLC-TAD) + performance monitors on CN10K family silicons. + source "drivers/perf/hisilicon/Kconfig" endmenu
drivers/perf/Makefile +1 -0
@@ -14,3 +14,4 @@ obj-$(CONFIG_THUNDERX2_PMU) += thunderx2_pmu.o obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o obj-$(CONFIG_ARM_SPE_PMU) += arm_spe_pmu.o obj-$(CONFIG_ARM_DMC620_PMU) += arm_dmc620_pmu.o +obj-$(CONFIG_MARVELL_CN10K_TAD_PMU) += marvell_cn10k_tad_pmu.o
drivers/perf/marvell_cn10k_tad_pmu.c new file +429 -0
429 lines not on this page · raw message
Signature · 1 line
2.17.1
Will Deacon
maintainerRe: [PATCH v7 1/2] drivers: perf: Add LLC-TAD perf counter support
Quoted 113 lines · Bhaskara Budiredla
This driver adds support for Last-level cache tag-and-data unit (LLC-TAD) PMU that is featured in some of the Marvell's CN10K infrastructure silicons.
The LLC is divided into 2N slices distributed across N Mesh tiles in a single-socket configuration. The driver always configures the same counter for all of the TADs. The user would end up effectively reserving one of eight counters in every TAD to look across all TADs. The occurrences of events are aggregated and presented to the user at the end of an application run. The driver does not provide a way for the user to partition TADs so that different TADs are used for different applications.
The event counters are zeroed to start event counting to avoid any rollover issues. TAD perf counters are 64-bit, so it's not currently possible to overflow event counters at current mesh and core frequencies.
To measure tad pmu events use perf tool stat command. For instance:
perf stat -e tad_dat_msh_in_dss,tad_req_msh_out_any <application> perf stat -e tad_alloc_any,tad_hit_any,tad_tag_rd <application>
Signed-off-by Bhaskara Budiredla <[email protected]>--- drivers/perf/Kconfig | 7 + drivers/perf/Makefile | 1 + drivers/perf/marvell_cn10k_tad_pmu.c | 429 +++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/perf/marvell_cn10k_tad_pmu.cdrivers/perf/Kconfig +7
-0@@ -137,6 +137,13 @@ config ARM_DMC620_PMU Support for PMU events monitoring on the ARM DMC-620 memory controller. +config MARVELL_CN10K_TAD_PMU + tristate "Marvell CN10K LLC-TAD PMU" + depends on ARM64 || (COMPILE_TEST && 64BIT) + help + Provides support for Last-Level cache Tag-and-data Units (LLC-TAD) + performance monitors on CN10K family silicons. + source "drivers/perf/hisilicon/Kconfig" endmenudrivers/perf/Makefile +1
-0@@ -14,3 +14,4 @@ obj-$(CONFIG_THUNDERX2_PMU) += thunderx2_pmu.o obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o obj-$(CONFIG_ARM_SPE_PMU) += arm_spe_pmu.o obj-$(CONFIG_ARM_DMC620_PMU) += arm_dmc620_pmu.o +obj-$(CONFIG_MARVELL_CN10K_TAD_PMU) += marvell_cn10k_tad_pmu.odrivers/perf/marvell_cn10k_tad_pmu.c new file +49
-0@@ -0,0 +1,429 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell CN10K LLC-TAD perf driver +* +* Copyright (C) 2021 Marvell +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#define pr_fmt (fmt) "tad_pmu: " fmt + +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_device.h> +#include <linux/cpuhotplug.h> +#include <linux/perf_event.h> +#include <linux/platform_device.h> + +#define TAD_PFC_OFFSET 0x0 +#define TAD_PFC (counter) (TAD_PFC_OFFSET | (counter << 3)) +#define TAD_PRF_OFFSET 0x100 +#define TAD_PRF (counter) (TAD_PRF_OFFSET | (counter << 3)) +#define TAD_PRF_CNTSEL_MASK 0xFF +#define TAD_MAX_COUNTERS 8 + +#define to_tad_pmu (p) (container_of(p, struct tad_pmu, pmu)) + +struct tad_region { +void __iomem *base; +}; + +struct tad_pmu { +struct pmu pmu; +struct tad_region *regions; +u32 region_cnt; +unsigned int cpu; +struct hlist_node node; +struct perf_event *events[TAD_MAX_COUNTERS ]; + DECLARE_BITMAP(counters_map, TAD_MAX_COUNTERS); +}; + +static int tad_pmu_cpuhp_state; + +static void tad_pmu_event_counter_read (struct perf_event *event) +{ +struct tad_pmu *tad_pmu =to_tad_pmu (event->pmu); +struct hw_perf_event *hwc = &event->hw;
drivers/perf/marvell_cn10k_tad_pmu.c line 59
Quoted 10 lines
drivers/perf/marvell_cn10k_tad_pmu.c new file +10
-0+u32 counter_idx = hwc->idx; +u64 prev, new; +int i; + +do { + prev =local64_read (&hwc->prev_count); +for (i =0 , new =0 ; i < tad_pmu->region_cnt; i++) + new +=readq (tad_pmu->regions[i].base + +TAD_PFC (counter_idx)); + }while (local64_cmpxchg (&hwc->prev_count, prev, new) != prev);
I plan to queue this as-is, but I did remark on the previous version that this loop is needlessly expensive. Why are you not using readq_relaxed() and why are you doing that _inside_ the cmpxchg() loop?
Will
PATCH v7 2/2 dt-bindings: perf: Add YAML schemas for Marvell CN10K LLC-TAD pmu bindings
In reply to Bhaskara BudiredlaAdd device tree bindings for Last-level-cache Tag-and-data (LLC-TAD) unit PMU for Marvell CN10K SoCs.
--- .../bindings/perf/marvell-cn10k-tad.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/marvell-cn10k-tad.yaml
Documentation/devicetree/bindings/perf/marvell-cn10k-tad.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/perf/marvell-cn10k-tad.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Marvell CN10K LLC-TAD performance monitor + +maintainers: + - Bhaskara Budiredla <[email protected]> + +description: | + The Tag-and-Data units (TADs) maintain coherence and contain CN10K + shared on-chip last level cache (LLC). The tad pmu measures the + performance of last-level cache. Each tad pmu supports up to eight + counters. + + The DT setup comprises of number of tad blocks, the sizes of pmu + regions, tad blocks and overall base address of the HW. + +properties: + compatible: + const: marvell,cn10k-tad-pmu + + reg: + maxItems: 1 + + marvell,tad-cnt: + description: specifies the number of tads on the soc + $ref: /schemas/types.yaml#/definitions/uint32 + + marvell,tad-page-size: + description: specifies the size of each tad page + $ref: /schemas/types.yaml#/definitions/uint32 + + marvell,tad-pmu-page-size: + description: specifies the size of page that the pmu uses + $ref: /schemas/types.yaml#/definitions/uint32 + +required: + - compatible + - reg + - marvell,tad-cnt + - marvell,tad-page-size + - marvell,tad-pmu-page-size + +additionalProperties: false + +examples: + - | + + tad { + #address-cells = <2>; + #size-cells = <2>; + + tad_pmu@80000000 { + compatible = "marvell,cn10k-tad-pmu"; + reg = <0x87e2 0x80000000 0x0 0x1000>; + marvell,tad-cnt = <1>; + marvell,tad-page-size = <0x1000>; + marvell,tad-pmu-page-size = <0x1000>; + }; + };
Signature · 1 line
2.17.1
Quoted 11 lines · Bhaskara Budiredla
This series introduces performance monitor driver to Last-level-cache tag-and-data (LLC-TAD) PMU which is an integral part of Marvell CN10K SoCs. The configuration and functionality of the TAD PMU is covered in patch 1. The device tree bindings are dealt in patch 2.
v7:
- use braces around a multi-line conditional statement (Will Deacon)
- remove mask doesn't do anything (Will Deacon)
- restrict compile test dependency to aarch64[...]
Applied to arm64 (for-next/perf-cn10k), thanks!
[1/2] drivers: perf: Add LLC-TAD perf counter support
https://git.kernel.org/arm64/c/036a7584bede [2/2] dt-bindings: perf: Add YAML schemas for Marvell CN10K LLC-TAD pmu bindings https://git.kernel.org/arm64/c/4cbf47728f8d
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev