Netdev List
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Jeff Xu <jeffxu@chromium.org>,
	Andrew Morton <akpm@linux-foundation.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>,
	"Evgenii Stepanov" <eugenis@google.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>,
	"Ryan Roberts" <ryan.roberts@arm.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 v1 0/7] mm: kasan: skip KASAN for GFP_HIGHUSER
Date: Tue, 17 Nov 2026 11:10:37 +0100	[thread overview]
Message-ID: <2066d131-f999-4747-beb8-520d5e0ce1db@kernel.org> (raw)
In-Reply-To: <20261116230627.3537051-1-jeffxu@chromium.org>

On 11/17/26 00:06, Jeff Xu wrote:
> Hi all,
> 
> Currently, GFP_HIGHUSER_MOVABLE includes __GFP_SKIP_KASAN (commits
> c275c5c6d50a, 70c248aca9e7, and 0a54864f8dfb), allowing movable
> userspace page allocations to skip KASAN page unpoisoning on allocation
> and poisoning on free under CONFIG_KASAN_HW_TAGS (ARM64 MTE). However,
> GFP_HIGHUSER does not include __GFP_SKIP_KASAN, even though it shares
> the same kernel-accessibility contract in include/linux/gfp_types.h
> ("for userspace allocations that may be mapped to userspace, do not need
> to be directly accessible by the kernel but that cannot move once in
> use") and differs only by !__GFP_MOVABLE.
> 
> Moving __GFP_SKIP_KASAN to GFP_HIGHUSER addresses the performance issue
> below (following up on the earlier drm/panthor discussion [1, 2]). The
> swap issue from that discussion is not addressed by this series:
> 
> 1. Performance: For every 4 KB page without __GFP_SKIP_KASAN,
>    mte_set_mem_tag_range() tags all 256 16-byte MTE granules (via
>    STG/STZG and DC GVA/GZVA) on allocation and again on free. In
>    graphics and UI workloads, DMA-BUF (system_heap) and DRM/GPU
>    (shmem/TTM) buffers use GFP_HIGHUSER; while steady-state rendering
>    reuses buffers, window resizes, surface transitions, and app launches
>    synchronously allocate and free tens to hundreds of megabytes (~32 MB
>    per 4K RGBA frame) on UI/compositor/render threads. That takes a
>    significant share of the 8.3 ms (120 Hz) / 16.7 ms (60 Hz) frame
>    budget and thrashes CPU data/MTE tag caches (especially on
>    cold-cache free). On Armv9.2-A, skipping KASAN cuts ~32 MB DMA-BUF
>    alloc+free latency by ~80% (~98% faster close()) and improves the
>    OpenGL score of an app-loading benchmark by 15-23%.
> 
> 2. False-positive KASAN report after shmem swap-in readahead [1] (not
>    addressed here): when a shmem page is swapped in,
>    swap_cluster_readahead() also reads the neighboring swap slots and
>    allocates their swap-cache folios with the gfp mask of that shmem
>    mapping. A neighboring slot can hold an unrelated page that
>    userspace maps with PROT_MTE. If the mask lacks __GFP_SKIP_KASAN,
>    that page's folio gets a KASAN tag in page->flags. When its owner
>    faults it in, arch_swap_restore() writes the saved userspace tags to
>    the memory, but page->flags keeps the KASAN tag. Later kernel
>    accesses through page_address() then use a tag that does not match
>    the memory and are reported by KASAN.
> 
>    This series does not fix the readahead path. It only removes one
>    way to hit it: shmem mappings that use GFP_HIGHUSER (e.g.
>    drm_gem_shmem_helper / panthor) now pass __GFP_SKIP_KASAN to
>    readahead, so the neighboring folios no longer get a KASAN tag.
>    Shmem mappings with other gfp masks that lack __GFP_SKIP_KASAN
>    (e.g. GFP_KERNEL) can still trigger the report. That issue should
>    be followed up separately, for example in [1].
> 
> What changes for users of GFP_HIGHUSER pages under CONFIG_KASAN_HW_TAGS
> (other KASAN modes are not affected):
> 
> - Access through vmap(): nothing changes. Those pointers already carry
>   the match-all tag and are not checked today.
> - Access through kmap_local_page() or page_address() (for example
>   ramfs): accesses are no longer checked by KASAN, as is already the
>   case for GFP_HIGHUSER_MOVABLE pages.
> - Buffers that the kernel itself fills (pipe, FUSE, kexec, RDS) keep
>   KASAN checking by using the new GFP_HIGHUSER_KASAN (patches 1-4).
> 
> GFP_KERNEL, GFP_USER, slab and vmalloc() allocations are not affected.
> 
> Patch 1 adds GFP_HIGHUSER_KASAN

I really don't want us to spread KASAN-related GFP flags in the kernel.

There must be a proper way to abstract this.

Why is GFP_HIGHUSER not sufficient? We were already told that this is memory to
be mapped into user space. Placing data structure on it and handing out pointers
to that would already be a bit questionable.

So what are the ways to avoid GFP_HIGHUSER_KASAN?

-- 
Cheers,

David

      parent reply	other threads:[~2026-11-17 10:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 23:06 [PATCH v1 0/7] mm: kasan: skip KASAN for GFP_HIGHUSER Jeff Xu
2026-11-16 23:06 ` [PATCH v1 1/7] mm: add GFP_HIGHUSER_KASAN Jeff Xu
2026-11-16 23:06 ` [PATCH v1 2/7] pipe, fuse: use GFP_HIGHUSER_KASAN for pipe buffer pages Jeff Xu
2026-11-16 23:06 ` [PATCH v1 3/7] kexec: use GFP_HIGHUSER_KASAN for segment pages Jeff Xu
2026-11-16 23:06 ` [PATCH v1 4/7] net/rds: use GFP_HIGHUSER_KASAN for message pages Jeff Xu
2026-11-16 23:06 ` [PATCH v1 5/7] mm: kasan: skip KASAN for GFP_HIGHUSER Jeff Xu
2026-11-17 10:21   ` Lorenzo Stoakes (ARM)
2026-11-16 23:06 ` [PATCH v1 6/7] mm/kasan/kunit: add page_alloc_skip_kasan test Jeff Xu
2026-11-16 23:06 ` [PATCH v1 7/7] mm/kasan/kunit: add page_alloc_highuser_kasan test Jeff Xu
2026-11-17 10:10 ` David Hildenbrand (Arm) [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=2066d131-f999-4747-beb8-520d5e0ce1db@kernel.org \
    --to=david@kernel.org \
    --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=dev.jain@arm.com \
    --cc=dvyukov@google.com \
    --cc=edumazet@kernel.org \
    --cc=elver@google.com \
    --cc=eugenis@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=ryan.roberts@arm.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