mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	"moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)"
	<linux-arm-kernel@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)"
	<bpf@vger.kernel.org>,
	"open list:MEMORY MANAGEMENT - CORE" <linux-mm@kvack.org>
Subject: Re: [PATCH 0/7] arm64: Batch PSTATE.TCO handling in kernel nofault loops
Date: Mon, 5 Oct 2026 15:16:38 +0100	[thread overview]
Message-ID: <asOxRkayznzX-K4c@arm.com> (raw)
In-Reply-To: <20260824160523.3907021-1-usama.anjum@arm.com>

On Mon, Aug 24, 2026 at 05:04:45PM +0100, Muhammad Usama Anjum wrote:
> With Hardware Tag-Based KASAN in asynchronous or asymmetric mode, kernel
> nofault loops currently set and clear PSTATE.TCO around every access.
> 
> Introduce bare nofault accessors, batching hooks, and an internal scope
> guard. Convert maccess page-fault cleanup to scoped form. Skip
> page-fault setup for zero-sized kernel nofault copies and zero-length
> BPF string operations. Then use bare primitives in the maccess and BPF
> loops. For non-empty operations, this reduces the code-derived dynamic
> MSR TCO execution count from 2N to 2. Two-string BPF comparisons fall
> from 4N to 2.
> 
> The BPF changes and an earlier maccess implementation with explicit
> cleanup were tested with QEMU arm64 using Hardware Tag-Based KASAN in
> synchronous, asynchronous, and asymmetric modes. All nine arm64 MTE
> kselftests passed in each mode, as did the 138 focused BPF string_kfuncs
> and varlen subtests. The focused BPF tests also passed with the default
> non-MTE arm64 CPU model. Both final maccess scoped-guard patches were
> arm64 cross-built. Runtime tests have not been rerun after that
> conversion.

TBH, I fail to see the benefit. There's a reduction in the number of
MSR instructions executed in async/asymm mode but does it result in any
improved benchmark numbers? Which workload hits these loops often enough
to matter? They are mostly used by tracing and debug code.

AFAIK, most people wanting to use KASAN in a non-debug environment want
to go for sync mode, where there is no MSR and this series only saves a
few NOPs. We might as well go for a config option to force sync mode (or
off) and remove the unnecessary NOPs, *if* you can show any performance
improvement.

-- 
Catalin

      parent reply	other threads:[~2026-10-05 14:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 16:04 Muhammad Usama Anjum
2026-08-24 16:04 ` [PATCH 1/7] arm64: uaccess: Add batched kernel nofault accessors Muhammad Usama Anjum
2026-08-24 17:02   ` bot+bpf-ci
2026-08-24 16:04 ` [PATCH 2/7] uaccess: Add scope guard for bare kernel nofault regions Muhammad Usama Anjum
2026-08-24 17:02   ` bot+bpf-ci
2026-08-24 16:04 ` [PATCH 3/7] maccess: Skip setup for zero-sized kernel nofault copies Muhammad Usama Anjum
2026-08-24 17:02   ` bot+bpf-ci
2026-10-01 11:34   ` David Hildenbrand (Arm)
2026-08-24 16:04 ` [PATCH 4/7] maccess: Use a scoped guard for page faults Muhammad Usama Anjum
2026-08-24 17:02   ` bot+bpf-ci
2026-08-25 10:36   ` David Hildenbrand (Arm)
2026-08-25 12:07     ` Muhammad Usama Anjum
2026-10-01 11:33       ` David Hildenbrand (Arm)
2026-10-01 12:32         ` Viktor Malik
2026-08-24 16:04 ` [PATCH 4/7] maccess: Use a scoped guard to re-enable " Muhammad Usama Anjum
2026-10-01 11:35   ` David Hildenbrand (Arm)
2026-08-24 16:04 ` [PATCH 5/7] maccess: Batch TCO handling in kernel nofault loops Muhammad Usama Anjum
2026-08-24 17:02   ` bot+bpf-ci
2026-10-01 11:36   ` David Hildenbrand (Arm)
2026-08-24 16:04 ` [PATCH 6/7] bpf: Skip setup for zero-length string kfunc operations Muhammad Usama Anjum
2026-08-24 16:04 ` [PATCH 7/7] bpf: Batch TCO handling in string kfuncs Muhammad Usama Anjum
2026-08-24 17:02   ` bot+bpf-ci
2026-09-14 11:27 ` [PATCH 0/7] arm64: Batch PSTATE.TCO handling in kernel nofault loops Muhammad Usama Anjum
2026-10-05 14:16 ` Catalin Marinas [this message]

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=asOxRkayznzX-K4c@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=david@kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=song@kernel.org \
    --cc=surenb@google.com \
    --cc=usama.anjum@arm.com \
    --cc=vbabka@kernel.org \
    --cc=will@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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

all inboxes | Powered by JetHome®