From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796127160; b=UGi0Ayy1MfJmg/69o4B91Vh2jrXcjLQAR5bgR8E2hgrJ1QZ1LrKyJEXJkF9ML1FDxNvu 9Og3EH4IO79CVq6c82vVBr+i49qHjJ0Q/TbVHEAajD3YxJ+rrHFD+I4q9BGs5Do45OtdR m+3dDyYY7xL/8CT2NT/pMl15mYecw+e1uPnY5J0PEQLZCHd3nekYEignMI9TKKVat0ORp Z1tc5aPzB2GyrTgv7v03nB0xcX8yIC5woqBDCyROmAVSMo67u0OKT1V7kDCGISQhq3qtO 3cEbBho3h3rTsFR9MxF4Bj4YWK2nIUUkjl3A+9ZAnxjldyulehqGS3ZgXvooLwrxBRw== 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=VoJlSZke2NpUVpy8wALGBtmBQlS7cniPk54n/TNpMiUFdHebo0bmshwf1/p+b7ExfTDW sFgCbLpJe6p5/6m+Fw1x2HvVa97kqh9uFxHjC/J0u1CFtQtU+bpSWVQto5l+YrkjyzA22 t8g6cZ7LbhljWwPGBtjz80iG4y0DLUw5rRDu9TIk92Velqn2ess2OdvSCN9S8x9WfymLO Qi00Jn7AXxRTan/xNYMlVCCUncu70i3Pb9CK4rr06BpsKFTYec/70sYzhK4ee5I4gFZuD fr7gURefSgDIlgz5jP8S4JYhVLnDoAyShqL4P8mOHjTYvnVhTHJiZyGVeDU4bFMIdtg== 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.69 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (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 D7870606A69A for ; Tue, 1 Dec 2026 12:12:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7870606A69A 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-f69.google.com with SMTP id a640c23a62f3a-c49df8fe86eso830017166b.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=yl1X0iiOkEC4kSzWBNldcEBzcDo21pEtR0MfL6QRNASrF0atJBiguAKHNXIb8zUlL8 FuaOt53hqyfmTALNVD4humtWikL+ldILJ2d+J0p5VDFnrtkoyj83wgoUIo7nLydSl/3p r3eA50jshd+OUpCCjc5skBemYwo4DBPihFBJzlt/6P3u0pOGvdZfOn/Dg0vvLQDMa0FK 28jqCOuotPOIk85MSeunpHdPR3dIiY0VDFUBoDHM0iJ4/Z9N/VxDfHj4KemxniE3wik+ 6JH2fwWnInx2Es6LYi/phxeripysvAUDA0lgkxS/9MsZj8pCTcbGoa6lG1BOdEYyDVi3 r6Ag== X-Forwarded-Encrypted: i=1; AL+hErEr4J/utkrdKS8etpxKSTHy6H51aa5VEhB4/FlhCNG5Iw7Z5tr+k9Wkxk1FaBTou9y3G+yjLqQuS6KV0PI=@vger.kernel.org X-Gm-Message-State: APuU4Z9tN1ulOnHdVmQoXnPQwP0mQszmFP36ksBBenK8cOcMfW/34sAW la8rOkCHg5Hu72H90HoosJyzV/RpKH/d/Y0+2KxZuskVOpv3CKgzwTfLAchvC1ZmTLhWf0gn965 DmQ== 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-kernel@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