From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796127160; b=O4opi4aWCyKb5E5aeLPxHSxeGIn5Q57uJcs6CXbn6n9GsTvSN58WZJf+Jr8MZ3hn8M2m aXwXUNv1u73sThC4ZW1vZa/6G+XmGF7jtZCj1CTBNYkI1czvcIfwRJqi89TKt2ZDk0uKB 2+VoA1CGPs2bPnbrfUo9+U0vZ/24c6c1f0MOExL7Q0s0F3J968LK6MEmuXcE0KOJWBBI+ aITBAf6heAtiOipl24hmBVEjLMlVICf4rmCGCQ03ihmqYwGwtno1+09Gnh1kvP7Qk7uFw uTnYWcCnncYYPIV1eaP9IRNA33jhHlrOWL1uIY6H7DXy7q5KxoYz58FNtIZJC4pwymA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796127160; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type:Content-Transfer-Encoding; bh=+I9c9zLqLG1RWzaX2uoW+dRlYIdSgxzQvhXMSOW9nnw=; b=hHtfbR4yEKli/41s6SeeD0p319spEnXiT/HnxIn1faCk6ly9qulNnEjVXaUn0zdvDDUO fWv5CLA9sdlJdMrhc1tJtz9Xrp6szaLRzI3ZA5hjMLZuhvpQuyDx9a3e+7GZiQwd1LYZl JQg+FxqGm/pgF8znvuGgAj7Y66IaqjgD5NVm0ax1urNqv+GH2pURfNCc8SIb5TIMlZrM1 dQcsFUPOR59ysOy0sTfcz8dXqnBCGeFheC0CcaP8P2rAjWkelQqNIL57+6ytou8ykr1OT +65u9thjDJVb4YZqOQcnnqrACtkncF+qf6Kxqv+qIfUJtzHV+Y5WW7w2XlXSSfme9Kg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--ptosi.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=UeOTTHmr; arc=none smtp.remote-ip=209.85.218.70 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD742606A32E for ; Tue, 1 Dec 2026 12:12:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BD742606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ptosi.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=UeOTTHmr Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c49df8fe86eso830017266b.2 for ; Tue, 01 Dec 2026 04:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796127158; x=1796731958; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=+I9c9zLqLG1RWzaX2uoW+dRlYIdSgxzQvhXMSOW9nnw=; b=UeOTTHmrMH/AkV0G6ZIkM5bsFuvUiltDv3YW2S0jOXBNqHxNdiWlUSBr+JpARbFs8j jcXsm6/lGNKGJTYunH2ITJjj23QBMskNU9HOTCAaMMOhycwoTC65c6H73I+Rpxlza6xd e5xvftz+lpCOgHl6TpIrYqUvoHYbOeV57lB+r89XfBRfxupB0n7Hf3y8IsUmDevOElst PrT74lNpKmGBJG4j9j+GG8CoksdTc6mqZyPoAPA23Z4rhKgjkXF+Kyy5OGW+oWetfqb2 nVhFH00Q9swJxqMwBHVeqKTbYZSvxC3FbXC7VbQWhXhPXkYO9nlD9IjoVjvRpZqu3Y4S Rn+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796127158; x=1796731958; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+I9c9zLqLG1RWzaX2uoW+dRlYIdSgxzQvhXMSOW9nnw=; b=Ol5ljFIDACxarkrTFcLl8lotyEQpNQHxW4JlHo8HdUFQ4AP1tJOoSCkVd4+E2aSYFE Nvatek9bHBnsQLCGA41sM3seXNsrWkOU2bTJe4EMOltfL27vCxZtRSSbEE9+coRmGONL scJcshqT4HrE5iTig4/kzEzJxmhSZu+7LJ70J9uE6zyCy6Iwk9q1r61LBdKr+85mwLwb f6Q5DZVzlcvvSuHhSs1UHQO1UFzpRYSuwyW10XsIeLWOwPKHPz2olyxjP58bhaihlWd3 v88kZ8rn6yY8gaqi/CzrrF/yaXVn9Lsi5Y7FeLw+hH9jLnoxS25oQtaSIL+6A6rYJG+b KgjQ== X-Forwarded-Encrypted: i=1; AL+hErHDMpc0gfkfQevCvSwZ373zR+2qnIRwRxU3HdLCps8nyq8TU8Gh1V9IHGK/KOFkBPEvAhrsp93UJpJl/RnxI0fH@vger.kernel.org X-Gm-Message-State: APuU4Z80r2TZhtZeLolzSia1LHEkB56tPVLKTAgJxSFNQdn9ti3OrOY3 Ac6J+mLEPAuc5fq7cpNgo0+N2P56ZjKcp6ggtgSMLXi51iAVkJwE0Tcvnh8aXD/88ymGpIaJmm0 9nw== X-Received: from edcns3-n2.prod.google.com ([2002:a05:6402:c6c3:20b0:6b8:9a3c:9b74]) (user=ptosi job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:608c:b0:c2e:6a4f:a88b with SMTP id a640c23a62f3a-c513a1f5c8cmr2939511566b.0.1796127157970; Tue, 01 Dec 2026 04:12:37 -0800 (PST) Date: Tue, 01 Dec 2026 13:11:53 +0100 In-Reply-To: <20261201-perf-prot-mte-v1-0-4dc4e1da7460@google.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261201-perf-prot-mte-v1-0-4dc4e1da7460@google.com> X-Mailer: b4 0.14.3 Message-ID: <20261201-perf-prot-mte-v1-4-4dc4e1da7460@google.com> Subject: [PATCH 4/4] perf bench mem: Support PROT_MTE on arm64 From: "=?utf-8?q?Pierre-Cl=C3=A9ment_Tosi?=" To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark Cc: Ankur Arora , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, "=?utf-8?q?Pierre-Cl=C3=A9ment_Tosi?=" , Catalin Marinas , Ryan Roberts , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add support for '--prot mte,...' to benchmark PROT_MTE mappings. Cc: Catalin Marinas Cc: Ryan Roberts Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Pierre-Cl=C3=A9ment Tosi --- 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/Documenta= tion/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 concurren= tly. =20 --prot=3D:: 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. =20 SUITES FOR 'numa' ~~~~~~~~~~~~~~~~~ diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functi= ons.c index 84247f83da59..722aa4189737 100644 --- a/tools/perf/bench/mem-functions.c +++ b/tools/perf/bench/mem-functions.c @@ -29,6 +29,11 @@ #include #include =20 +/* 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 =20 #define PAGE_SHIFT_4KB 12 @@ -65,7 +70,7 @@ static const struct option bench_common_options[] =3D { "Use a cycles event instead of gettimeofday() to measure performance= "), =20 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-separ= ated)"), =20 OPT_END() }; @@ -285,6 +290,10 @@ static int parse_arg_prot(const char *str) prot |=3D PROT_WRITE; else if (len =3D=3D strlen("exec") && !strncmp(str, "exec", len)) prot |=3D PROT_EXEC; +#ifdef PROT_MTE + else if (len =3D=3D strlen("mte") && !strncmp(str, "mte", len)) + prot |=3D PROT_MTE; +#endif else return -1; =20 --=20 2.56.1.839.g22a8290db9-goog