From: "Salunke, Hrushikesh" <hsalunke@amd.com>
To: Ankur Arora <ankur.a.arora@oracle.com>,
"David Hildenbrand (Arm)" <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>, <ljs@kernel.org>,
<Liam.Howlett@oracle.com>, <vbabka@kernel.org>, <rppt@kernel.org>,
<surenb@google.com>, <mhocko@suse.com>, <jackmanb@google.com>,
<hannes@cmpxchg.org>, <ziy@nvidia.com>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <rkodsara@amd.com>,
<bharata@amd.com>, <shivankg@amd.com>, <hsalunke@amd.com>
Subject: Re: [PATCH v3] mm/page_alloc: replace kernel_init_pages() with batch page clearing
Date: Thu, 30 Apr 2026 11:38:30 +0530 [thread overview]
Message-ID: <0179f4b1-a22e-4686-be10-8fedf2ce7fad@amd.com> (raw)
In-Reply-To: <87pl3jmqog.fsf@oracle.com>
On 28-04-2026 14:01, Ankur Arora wrote:
> David Hildenbrand (Arm) <david@kernel.org> writes:
>
>> On 4/28/26 05:55, Salunke, Hrushikesh wrote:
>>> On 24-04-2026 14:22, David Hildenbrand (Arm) wrote:
>>>> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>>>>
>>>>
>>>> On 4/24/26 10:42, Salunke, Hrushikesh wrote:
>>>>> Hi Andrew,
>>>>>
>>>>> The idea was to keep it alongside clear_highpage_kasan_tagged() as its
>>>>> batch counterpart, but currently it is only used by page_alloc.c.
>>>> Right.
>>>>
>>>> Looking at init_vmalloc_pages(), I wonder if it could also benefit from batching
>>>> if we find that pages are actually contiguous.
>>>>
>>>> That would require looking up multiple pages at once. vmalloc_to_pages() or sth
>>>> like that. Surely, doing such an optimized page table walk could be beneficial
>>>> by itself.
>>> Interesting idea. For the general case where we only have struct page
>>> pointers, we'd need physical contiguity detection and a batched page
>>> table walk as you described. But looking at init_vmalloc_pages()
>>> specifically, it already has the vmalloc virtual address which is
>>> contiguous, so can we just do following and potentially skip the
>>> vmalloc_to_page() walk entirely:
>>>
>>> clear_pages(kasan_reset_tag((void *)start), size >> PAGE_SHIFT);
>>>
>>> What do you think? would this simpler approach work
>>> , or am I missing something?
>> Good question. :)
>>
>> That way you'd be operating on the vmalloc address range, not on the direct map.
> From my testing (including when using userspace VA) most of the speedup
> was from CPU prefetch. Which we should get when working with the
> vmalloc address range. Assuming it is writable and stable.
>
>> Is the vmalloc address range guaranteed to be writable at that point?
Hi David, Ankur
Yes. init_vmalloc_pages() is only reachable from
__kasan_unpoison_vmalloc() in hw_tags.c, and the only caller that
passes KASAN_VMALLOC_INIT is __vmalloc_node_range_noprof() in
vmalloc.c. The pages are mapped by the time init_vmalloc_pages()
runs, so the vmalloc range is writable at that point.
> What happens if we get preempted and migrated while clearing? Seems like
> the vmalloc lazy syncing should be able to handle that?
Good point. I haven't looked into the vmalloc lazy syncing behavior
in this context yet. I'll need to look into that to make sure there are
no surprises with pre-emption and migration during clearing. Will
follow up on this.
Regards,
Hrushikesh.
>
prev parent reply other threads:[~2026-04-30 6:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 10:26 [PATCH v3] mm/page_alloc: replace kernel_init_pages() with batch page clearing Hrushikesh Salunke
2026-04-22 18:25 ` David Hildenbrand (Arm)
2026-04-23 5:09 ` Salunke, Hrushikesh
2026-04-23 10:13 ` David Hildenbrand (Arm)
2026-04-23 11:12 ` Andrew Morton
2026-04-24 8:42 ` Salunke, Hrushikesh
2026-04-24 8:52 ` David Hildenbrand (Arm)
2026-04-28 3:55 ` Salunke, Hrushikesh
2026-04-28 7:06 ` David Hildenbrand (Arm)
2026-04-28 8:31 ` Ankur Arora
2026-04-30 6:08 ` Salunke, Hrushikesh [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=0179f4b1-a22e-4686-be10-8fedf2ce7fad@amd.com \
--to=hsalunke@amd.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=ankur.a.arora@oracle.com \
--cc=bharata@amd.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rkodsara@amd.com \
--cc=rppt@kernel.org \
--cc=shivankg@amd.com \
--cc=surenb@google.com \
--cc=vbabka@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