Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Jeff Xu <jeffxu@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: "Lorenzo Stoakes" <ljs@kernel.org>,
	"Liam R . Howlett" <liam@infradead.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>,
	"Brendan Jackman" <brendan.jackman@linux.dev>,
	"Zi Yan" <ziy@nvidia.com>,
	"Alexander Potapenko" <glider@google.com>,
	"Andrey Konovalov" <andreyknvl@gmail.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
	"Marco Elver" <elver@google.com>,
	"Boris Brezillon" <boris.brezillon@collabora.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Chia-I Wu" <olvaffe@gmail.com>, "Dev Jain" <dev.jain@arm.com>,
	"Ian Rickards" <ian.rickards@arm.com>,
	"Jann Horn" <jannh@google.com>,
	"Jeff Vander Stoep" <jeffv@google.com>,
	"Jeff Xu" <jeffxu@google.com>, "Kees Cook" <kees@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Peter Collingbourne" <peter@pcc.me.uk>,
	"Pierre-Clément Tosi" <ptosi@google.com>,
	"Tomasz Figa" <tfiga@chromium.org>,
	"Will Deacon" <will@kernel.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Jan Kara" <jack@suse.cz>, "Miklos Szeredi" <miklos@szeredi.hu>,
	"Baoquan He" <baoquan.he@linux.dev>,
	"Pasha Tatashin" <pasha.tatashin@soleen.com>,
	"Pratyush Yadav" <pratyush@kernel.org>,
	"Allison Henderson" <achender@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	linux-mm@kvack.org, kasan-dev@googlegroups.com,
	linux-arm-kernel@lists.infradead.org,
	linux-fsdevel@vger.kernel.org, fuse-devel@lists.linux.dev,
	kexec@lists.infradead.org, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mm: kasan: skip KASAN for GFP_HIGHUSER
Date: Mon, 23 Nov 2026 08:54:11 +0000	[thread overview]
Message-ID: <d7dae0fd-a4bd-404b-954e-99236dfca560@arm.com> (raw)
In-Reply-To: <20261123033111.2349160-2-jeffxu@chromium.org>

On 23/11/2026 03:31, Jeff Xu wrote:
> Move __GFP_SKIP_KASAN from GFP_HIGHUSER_MOVABLE to GFP_HIGHUSER so
> non-movable userspace page allocations also skip KASAN tagging on
> allocation and poisoning on free under CONFIG_KASAN_HW_TAGS.
> 
> GFP_HIGHUSER_MOVABLE already skips KASAN because user pages do not hold
> kernel data structures and tagging every 16-byte MTE granule on
> allocation and free is expensive. GFP_HIGHUSER has the same contract and
> differs only in being non-movable, used mainly by DMA-BUF, DRM/GPU
> buffers, and non-movable HugeTLB.
> 
> On an Armv9.2-A device (6.12 kernel, kasan.mode=sync), this reduces
> 32 MB /dev/dma_heap/system alloc+free latency by ~80% (~59% alloc, ~98%
> close) and improves an app-loading OpenGL benchmark by 15-23%.
> 
> Callers that access GFP_HIGHUSER pages through kmap_local_page() or
> page_address() (such as ramfs, pipe/FUSE buffers, kexec, and RDS) lose
> HW_TAGS checking on those pages. None of them store kernel structs
> there; this matches the trade-off already made for GFP_HIGHUSER_MOVABLE.
> Generic and SW_TAGS KASAN are unaffected.
> 
> Signed-off-by: Jeff Xu <jeffxu@chromium.org>

LGTM; I agree with your assessment of the risk.

We have seen poisoning pages at free-time being a performance bottleneck because
the tags are kept inline with data in the cache, and setting the tags therefore
causes hot data to be evicted to bring in the cold data just to set the tags. We
had been experimenting with the concept of "elide poison on free" for "in-kernel
MTE enabled in production" use cases to solve this. But the security analysis is
a bit complex.

I anticipate that your change is probably solving most of the same performance
cost in a much more straightforward manner. I'm guessing these DMA/DRM/GPU
buffers are the largest in-kernel memory allocators for the Android app start
use case.

Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>

> ---
>  include/linux/gfp_types.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h
> index c1331bf0b239..bb54c7abfb02 100644
> --- a/include/linux/gfp_types.h
> +++ b/include/linux/gfp_types.h
> @@ -376,8 +376,8 @@ enum {
>  #define GFP_USER	(__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
>  #define GFP_DMA		__GFP_DMA
>  #define GFP_DMA32	__GFP_DMA32
> -#define GFP_HIGHUSER	(GFP_USER | __GFP_HIGHMEM)
> -#define GFP_HIGHUSER_MOVABLE	(GFP_HIGHUSER | __GFP_MOVABLE | __GFP_SKIP_KASAN)
> +#define GFP_HIGHUSER	(GFP_USER | __GFP_HIGHMEM | __GFP_SKIP_KASAN)
> +#define GFP_HIGHUSER_MOVABLE	(GFP_HIGHUSER | __GFP_MOVABLE)
>  #define GFP_TRANSHUGE_LIGHT	((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
>  			 __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
>  #define GFP_TRANSHUGE	(GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)
> 
> base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859



  reply	other threads:[~2026-11-23  8:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  3:31 [PATCH v2 0/2] mm: kasan: skip KASAN for GFP_HIGHUSER Jeff Xu
2026-11-23  3:31 ` [PATCH v2 1/2] " Jeff Xu
2026-11-23  8:54   ` Ryan Roberts [this message]
2026-11-23  3:31 ` [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test Jeff Xu
2026-11-23  8:58   ` Ryan Roberts

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=d7dae0fd-a4bd-404b-954e-99236dfca560@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=achender@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=baoquan.he@linux.dev \
    --cc=boris.brezillon@collabora.com \
    --cc=brauner@kernel.org \
    --cc=brendan.jackman@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=dvyukov@google.com \
    --cc=edumazet@kernel.org \
    --cc=elver@google.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=glider@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=horms@kernel.org \
    --cc=ian.rickards@arm.com \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=jeffv@google.com \
    --cc=jeffxu@chromium.org \
    --cc=jeffxu@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kees@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=kuba@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhocko@suse.com \
    --cc=miklos@szeredi.hu \
    --cc=netdev@vger.kernel.org \
    --cc=olvaffe@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=peter@pcc.me.uk \
    --cc=pratyush@kernel.org \
    --cc=ptosi@google.com \
    --cc=rds-devel@oss.oracle.com \
    --cc=rppt@kernel.org \
    --cc=ryabinin.a.a@gmail.com \
    --cc=surenb@google.com \
    --cc=tfiga@chromium.org \
    --cc=vbabka@kernel.org \
    --cc=vincenzo.frascino@arm.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will@kernel.org \
    --cc=ziy@nvidia.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