From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>,
"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Kees Cook <kees@kernel.org>, kernel test robot <lkp@intel.com>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] mm: Fix kernel stack tagging for certain configs
Date: Thu, 4 Sep 2025 08:42:17 +0200 [thread overview]
Message-ID: <239ecae6-2fc0-43be-bc63-08f52b39a524@redhat.com> (raw)
In-Reply-To: <aLdFxtVpOX-qf0qc@casper.infradead.org>
On 02.09.25 21:30, Matthew Wilcox wrote:
> On Tue, Sep 02, 2025 at 10:59:03AM -0700, Vishal Moola (Oracle) wrote:
>> There are 3 cases where kernel pages are allocated for kernel stacks:
>> CONFIG_VMAP_STACK, THREAD_SIZE >= PAGE_SIZE, THREAD_SIZE < PAGE_SIZE.
>> These cases use vmalloc(), alloc_pages() and kmem_cache_alloc()
>> respectively.
>
> I missed that the third case existed ...
>
>> In the first 2 cases, THREAD_SIZE / PAGE_SIZE will always be greater
>> than 0, and pages are tagged as expected. In the third case,
>> THREAD_SIZE / PAGE_SIZE evaluates to 0 and doesn't tag any pages at all.
>> This meant that in those configs, the stack tagging was a no-op, and led
>> to smatch build warnings.
>
> I didn't see those smatch warnings. Were they cc'd to the mailing list?
>
>> We definitely have at least 1 page we want tagged at this point, so fix
>> it by using a do {} while loop instead of a for loop.
>
> We can't do this. Pages can only have one type at a time. Since
> they're allocated from slab, they have PGTY_slab. This will lead to
> a warning at runtime:
>
> VM_BUG_ON_PAGE(data_race(page->page_type) != UINT_MAX, page); \
>
> But for our purposes (trying to figure out how fragmented the vmap
> stack is making the memmap), we don't need to do this accounting.
> These pages are already being allocated from slab, and slab allocates
> naturally aligned, so we can skip all of this for these configurations.
IIUC what you mean, I am not a fan of having PGTY_stack being properly
set or not based on a kernel config.
I much rather prefer this being done cleanly for all cases, or not at
all (OOT for research/debugging purposes).
--
Cheers
David / dhildenb
prev parent reply other threads:[~2025-09-04 6:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 17:59 Vishal Moola (Oracle)
2025-09-02 18:23 ` David Hildenbrand
2025-09-02 20:06 ` Vishal Moola (Oracle)
2025-09-03 7:46 ` David Hildenbrand
2025-09-03 18:12 ` Vishal Moola (Oracle)
2025-09-04 6:38 ` David Hildenbrand
2025-09-02 19:30 ` Matthew Wilcox
2025-09-02 20:09 ` Dan Carpenter
2025-09-04 6:42 ` David Hildenbrand [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=239ecae6-2fc0-43be-bc63-08f52b39a524@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dan.carpenter@linaro.org \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
--cc=vishal.moola@gmail.com \
--cc=willy@infradead.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