From: Muhammad Usama Anjum <usama.anjum@arm.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: usama.anjum@arm.com, Arnd Bergmann <arnd@arndb.de>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Kees Cook <kees@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Uladzislau Rezki <urezki@gmail.com>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Andrey Konovalov <andreyknvl@gmail.com>,
Marco Elver <elver@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Peter Collingbourne <pcc@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
david.hildenbrand@arm.com
Subject: Re: [PATCH 2/3] fork: skip MTE tagging for kernel stacks
Date: Thu, 19 Mar 2026 12:29:59 +0000 [thread overview]
Message-ID: <6f9ee2d8-7906-4051-bc30-44823e2b2133@arm.com> (raw)
In-Reply-To: <dc85cda7-cf66-4bfa-92ab-af23f550562a@arm.com>
Hi Ryan,
Thank you for the review.
On 19/03/2026 12:09 pm, Ryan Roberts wrote:
> On 19/03/2026 11:49, Muhammad Usama Anjum wrote:
>> The stack pointer always uses the match-all tag, so MTE never checks
>> tags on stack accesses. Tagging stack memory on every thread creation
>> is pure overhead.
>>
>> - Pass __GFP_SKIP_KASAN in gfp_mask for vmalloc-backed stacks so the
>> vmalloc path skips HW tag setup (see previous patch).
>> - For the cached VMAP reuse path, skip kasan_unpoison_range() when HW
>> tags are enabled since the memory will only be accessed through the
>> match-all tagged SP.
>> - For the normal page allocator path, pass __GFP_SKIP_KASAN directly
>> to the page allocator.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com>
>> ---
>> kernel/fork.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index bb0c2613a5604..2baf4db39b5a4 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -345,7 +345,8 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
>> }
>>
>> /* Reset stack metadata. */
>> - kasan_unpoison_range(vm_area->addr, THREAD_SIZE);
>> + if (!kasan_hw_tags_enabled())
>> + kasan_unpoison_range(vm_area->addr, THREAD_SIZE);
>>
>> stack = kasan_reset_tag(vm_area->addr);
>>
>> @@ -358,7 +359,7 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
>> }
>>
>> stack = __vmalloc_node(THREAD_SIZE, THREAD_ALIGN,
>> - GFP_VMAP_STACK,
>> + GFP_VMAP_STACK | __GFP_SKIP_KASAN,
>
> Perhaps cleaner to include __GFP_SKIP_KASAN in GFP_VMAP_STACK ?
Yes, it would be much better and the correct way. I'll add it in the next version.
>
>> node, __builtin_return_address(0));
>> if (!stack)
>> return -ENOMEM;
>> @@ -410,7 +411,8 @@ static void thread_stack_delayed_free(struct task_struct *tsk)
>>
>> static int alloc_thread_stack_node(struct task_struct *tsk, int node)
>> {
>> - struct page *page = alloc_pages_node(node, THREADINFO_GFP,
>> + struct page *page = alloc_pages_node(node,
>> + THREADINFO_GFP | __GFP_SKIP_KASAN,
>
> I think there are some other places that could benefit from __GFP_SKIP_KASAN;
> see arm64's arch_alloc_vmap_stack(), which allocates stacks for efi, irq and
> sdei. I think these are allocated at boot, so not really performance sensitive,
> but we might as well be consistent?
>
> You've also missed the alloc_thread_stack_node() implementation for !VMAP when
> PAGE_SIZE > STACK_SIZE.
>
> All of these sites use THREADINFO_GFP so perhaps it is better to just define
> THREADINFO_GFP to include __GFP_SKIP_KASAN ?
Yes, it'll be the straight forward and clean approach. I'll update.
>
> Thanks,
> Ryan
>
>
>> THREAD_SIZE_ORDER);
>>
>> if (likely(page)) {
>
next prev parent reply other threads:[~2026-03-19 12:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 11:49 [PATCH 0/3] KASAN: HW_TAGS: Disable tagging for stack and page-tables Muhammad Usama Anjum
2026-03-19 11:49 ` [PATCH 1/3] vmalloc: add __GFP_SKIP_KASAN support Muhammad Usama Anjum
2026-03-19 12:22 ` Ryan Roberts
2026-03-19 12:57 ` Muhammad Usama Anjum
2026-03-19 11:49 ` [PATCH 2/3] fork: skip MTE tagging for kernel stacks Muhammad Usama Anjum
2026-03-19 12:09 ` Ryan Roberts
2026-03-19 12:29 ` Muhammad Usama Anjum [this message]
2026-03-19 11:49 ` [PATCH 3/3] mm: SKIP KASAN for page table allocations Muhammad Usama Anjum
2026-03-19 12:09 ` Ryan Roberts
2026-03-20 3:10 ` [PATCH 0/3] KASAN: HW_TAGS: Disable tagging for stack and page-tables Andrew Morton
2026-03-23 14:53 ` Muhammad Usama Anjum
2026-03-20 8:53 ` David Hildenbrand (Arm)
2026-03-23 15:06 ` Muhammad Usama Anjum
2026-03-26 13:40 ` David Hildenbrand (Arm)
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=6f9ee2d8-7906-4051-bc30-44823e2b2133@arm.com \
--to=usama.anjum@arm.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=arnd@arndb.de \
--cc=bsegall@google.com \
--cc=catalin.marinas@arm.com \
--cc=david.hildenbrand@arm.com \
--cc=david@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=elver@google.com \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=pcc@google.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=urezki@gmail.com \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vincenzo.frascino@arm.com \
--cc=vschneid@redhat.com \
--cc=will@kernel.org \
/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