Linux Perf Users
 help / color / mirror / Atom feed
From: "Pierre-Clément Tosi" <ptosi@google.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Ian Rogers <irogers@google.com>,
	James Clark <james.clark@linaro.org>
Cc: "Ankur Arora" <ankur.a.arora@oracle.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Pierre-Clément Tosi" <ptosi@google.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] perf bench mem: Support PROT_MTE on arm64
Date: Tue, 01 Dec 2026 13:11:53 +0100	[thread overview]
Message-ID: <20261201-perf-prot-mte-v1-4-4dc4e1da7460@google.com> (raw)
In-Reply-To: <20261201-perf-prot-mte-v1-0-4dc4e1da7460@google.com>

Add support for '--prot mte,...' to benchmark PROT_MTE mappings.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
---
 tools/perf/Documentation/perf-bench.txt |  7 +++++--
 tools/perf/bench/mem-functions.c        | 11 ++++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-bench.txt b/tools/perf/Documentation/perf-bench.txt
index 0a3ad2284f19..fd09f3fc206b 100644
--- a/tools/perf/Documentation/perf-bench.txt
+++ b/tools/perf/Documentation/perf-bench.txt
@@ -291,13 +291,16 @@ Create multiple threads to call mmap/munmap concurrently.
 
 --prot=<PROT>::
 Specify memory protection for mapping memory buffers (default:
-read,write). Available values are none, read, write and exec, as a
-comma-separated list.
+read,write). Available values are none, read, write, exec and, on
+arm64, mte (PROT_MTE), as a comma-separated list.
 The benchmark loads from each page of a readable mapping and stores to
 each page of a writable one: 'read' maps the zero page, 'write' takes a
 single write fault per page, and 'read,write' maps the zero page before
 breaking copy-on-write. Mappings that are neither readable nor writable
 are not accessed.
+With mte, the kernel initialises the allocation tags of each page when
+it first maps it, unless the CPU doesn't support MTE, in which case
+mmap() ignores PROT_MTE.
 
 SUITES FOR 'numa'
 ~~~~~~~~~~~~~~~~~
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c
index 84247f83da59..722aa4189737 100644
--- a/tools/perf/bench/mem-functions.c
+++ b/tools/perf/bench/mem-functions.c
@@ -29,6 +29,11 @@
 #include <linux/log2.h>
 #include <pthread.h>
 
+/* arm64 only (asm/mman.h), but missing from older C libraries. */
+#if defined(__aarch64__) && !defined(PROT_MTE)
+#define PROT_MTE	0x20
+#endif
+
 #define K 1024
 
 #define PAGE_SHIFT_4KB		12
@@ -65,7 +70,7 @@ static const struct option bench_common_options[] = {
 		    "Use a cycles event instead of gettimeofday() to measure performance"),
 
 	OPT_STRING(0, "prot", &prot_str, "read,write",
-		   "Memory protection: none, read, write, exec (comma-separated)"),
+		   "Memory protection: none, read, write, exec, mte (arm64) (comma-separated)"),
 
 	OPT_END()
 };
@@ -285,6 +290,10 @@ static int parse_arg_prot(const char *str)
 			prot |= PROT_WRITE;
 		else if (len == strlen("exec") && !strncmp(str, "exec", len))
 			prot |= PROT_EXEC;
+#ifdef PROT_MTE
+		else if (len == strlen("mte") && !strncmp(str, "mte", len))
+			prot |= PROT_MTE;
+#endif
 		else
 			return -1;
 

-- 
2.56.1.839.g22a8290db9-goog


  parent reply	other threads:[~2026-12-01 12:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:11 [PATCH 0/4] perf bench mem: Add support for PROT_MTE Pierre-Clément Tosi
2026-12-01 12:11 ` [PATCH 1/4] perf bench mem: Report why mmap() failed Pierre-Clément Tosi
2026-12-01 12:11 ` [PATCH 2/4] perf bench mem: Pass bench_params to bench_mmap() Pierre-Clément Tosi
2026-12-01 12:11 ` [PATCH 3/4] perf bench mem: Add --prot option Pierre-Clément Tosi
2026-12-01 12:28   ` sashiko-bot
2026-12-01 12:11 ` Pierre-Clément Tosi [this message]
2026-12-01 12:28 ` [PATCH 0/4] perf bench mem: Add support for PROT_MTE sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201-perf-prot-mte-v1-4-4dc4e1da7460@google.com \
    --to=ptosi@google.com \
    --cc=acme@kernel.org \
    --cc=ankur.a.arora@oracle.com \
    --cc=catalin.marinas@arm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=ryan.roberts@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox