Re: [PATCH v4 3/3] perf alpha: Add perf mem support
From: Magnus Lindholm
Date: Mon Nov 09 2026 - 17:53:31 EST
Hi Matt,
On Wed, Nov 4, 2026 at 7:54 PM Matt Turner <mattst88@xxxxxxxxx> wrote:
>
> The Alpha kernel series "alpha/perf: add ProfileMe sampling" reports the
> data source of ProfileMe samples of loads and stores: whether they hit or
> missed the DTB, and whether they were loads, stores or prefetches.
>
> Give the Alpha core PMU a mem-ldst event, cpu/cycles,profileme/, as AMD
> does with IBS Op. cycles:p is not used, as precise events sample only
> retired instructions, and a load or store that misses the DTB is aborted
> and refetched. The profileme format bit only exists on the EV67 and
> later, which have ProfileMe.
>
> Suggested-by: Ian Rogers <irogers@xxxxxxxxxx>
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Matt Turner <mattst88@xxxxxxxxx>
> ---
> tools/perf/Documentation/perf-mem.txt | 3 +++
> tools/perf/arch/alpha/Build | 2 +-
> tools/perf/arch/alpha/util/Build | 2 ++
> tools/perf/arch/alpha/util/mem-events.c | 17 +++++++++++++++++
> tools/perf/arch/alpha/util/mem-events.h | 7 +++++++
> tools/perf/arch/alpha/util/pmu.c | 11 +++++++++++
> 6 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
> index fe51c5e3333d..cb439940ce90 100644
> --- a/tools/perf/Documentation/perf-mem.txt
> +++ b/tools/perf/Documentation/perf-mem.txt
> @@ -34,6 +34,9 @@ be sampled.
>
> On AMD this use IBS Op PMU to sample load-store operations.
>
> +On Alpha this uses ProfileMe, on the EV67 and later, to sample all
> +instructions. Loads and stores report whether they hit or missed the DTB.
> +
> COMMON OPTIONS
> --------------
> -f::
> diff --git a/tools/perf/arch/alpha/Build b/tools/perf/arch/alpha/Build
> index 1bb8bf6d7fd4..e63eabc2c8f4 100644
> --- a/tools/perf/arch/alpha/Build
> +++ b/tools/perf/arch/alpha/Build
> @@ -1 +1 @@
> -# empty
> +perf-util-y += util/
> diff --git a/tools/perf/arch/alpha/util/Build b/tools/perf/arch/alpha/util/Build
> new file mode 100644
> index 000000000000..8d924b229470
> --- /dev/null
> +++ b/tools/perf/arch/alpha/util/Build
> @@ -0,0 +1,2 @@
> +perf-util-y += mem-events.o
> +perf-util-y += pmu.o
> diff --git a/tools/perf/arch/alpha/util/mem-events.c b/tools/perf/arch/alpha/util/mem-events.c
> new file mode 100644
> index 000000000000..d3cbca1993b4
> --- /dev/null
> +++ b/tools/perf/arch/alpha/util/mem-events.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include "util/map_symbol.h"
> +#include "util/mem-events.h"
> +#include "mem-events.h"
> +
> +#define E(t, n, s, l, a) { .tag = t, .name = n, .event_name = s, .ldlat = l, .aux_event = a }
> +
> +/*
> + * ProfileMe samples loads and stores alike, and reports DTB hits and misses
> + * in the data source. A precise event would sample only retired
> + * instructions, which leaves out the DTB misses, so set the profileme bit.
> + */
> +struct perf_mem_event perf_mem_events_alpha[PERF_MEM_EVENTS__MAX] = {
> + E(NULL, NULL, NULL, false, 0),
> + E(NULL, NULL, NULL, false, 0),
> + E("mem-ldst", "%s/cycles,profileme/", "cycles", false, 0),
> +};
> diff --git a/tools/perf/arch/alpha/util/mem-events.h b/tools/perf/arch/alpha/util/mem-events.h
> new file mode 100644
> index 000000000000..311448cf1218
> --- /dev/null
> +++ b/tools/perf/arch/alpha/util/mem-events.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ALPHA_MEM_EVENTS_H
> +#define _ALPHA_MEM_EVENTS_H
> +
> +extern struct perf_mem_event perf_mem_events_alpha[PERF_MEM_EVENTS__MAX];
> +
> +#endif /* _ALPHA_MEM_EVENTS_H */
> diff --git a/tools/perf/arch/alpha/util/pmu.c b/tools/perf/arch/alpha/util/pmu.c
> new file mode 100644
> index 000000000000..d19dfc979b08
> --- /dev/null
> +++ b/tools/perf/arch/alpha/util/pmu.c
> @@ -0,0 +1,11 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include "../../../util/pmu.h"
> +#include "mem-events.h"
> +
> +void perf_pmu__arch_init(struct perf_pmu *pmu)
> +{
> + /* ProfileMe is only on the EV67 and later. */
> + if (pmu->is_core && perf_pmu__has_format(pmu, "profileme"))
> + pmu->mem_events = perf_mem_events_alpha;
> +}
>
> --
> 2.55.0
>
Tested on my EV67 AlphaServer ES40 with the v6 kernel series.
perf mem record selected cpu/cycles,profileme/ by default, and
perf mem report showed 6452 L1 DTB hits and 81 L1 DTB misses
on a page-stride workload.
Reviewed-by: Magnus Lindholm <linmag7@xxxxxxxxx>
Tested-by: Magnus Lindholm <linmag7@xxxxxxxxx>