From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Qiqi Liu <liuqiqi@kylinos.cn>, akpm@linux-foundation.org
Cc: surenb@google.com, mhocko@suse.com, brendan.jackman@linux.dev,
hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, rostedt@goodmis.org,
gourry@gourry.net
Subject: Re: [PATCH v3] mm: page_alloc: add missing hooks to bulk allocation path
Date: Tue, 8 Sep 2026 10:38:46 +0200 [thread overview]
Message-ID: <c4c29830-ad49-4ca1-b4d5-6f40d30cdcdc@kernel.org> (raw)
In-Reply-To: <20260908065043.217569-1-liuqiqi@kylinos.cn>
On 9/8/26 08:50, Qiqi Liu wrote:
> The bulk allocation path in alloc_pages_bulk_noprof() currently misses
> trace_mm_page_alloc() and kmsan_alloc_page() calls, leaving bulk-allocated
> pages invisible to ftrace/BPF/perf and leaving KMSAN shadow memory stale.
>
> Add both calls after set_page_refcounted() in the bulk loop to match
> the standard allocation path. The gfp mask passed to kmsan_alloc_page()
> is stripped of __GFP_RECLAIM because the bulk loop runs under the PCP
> spinlock, and KMSAN's stack depot allocation must not sleep.
>
> Both are no-ops when their respective features are disabled, so there
> is no overhead in production kernels.
>
> Suggested-by: Gregory Price <gourry@gourry.net>
> Signed-off-by: Qiqi Liu <liuqiqi@kylinos.cn>
> ---
> mm/page_alloc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 12fac9084c48..73c73499a051 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5280,6 +5280,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
>
> prep_new_page(page, 0, gfp, ALLOC_DEFAULT);
> set_page_refcounted(page);
> + trace_mm_page_alloc(page, 0, gfp, ac.migratetype);
> + kmsan_alloc_page(page, 0, gfp & ~__GFP_RECLAIM);
With normal page allocation the set_page_refcounted() happens after
trace+kmsan. While it currently shouldn't matter, it could be more future
proof to keep the same order.
> page_array[nr_populated++] = page;
> }
>
next prev parent reply other threads:[~2026-09-08 8:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 12:09 [PATCH] mm: page_alloc: add trace_mm_page_alloc to bulk allocation path liuqiqi
2026-09-07 14:53 ` Gregory Price
2026-09-08 9:56 ` Qiqi Liu
2026-09-08 3:19 ` [PATCH v2] mm: page_alloc: add missing hooks " Qiqi Liu
2026-09-08 6:50 ` [PATCH v3] " Qiqi Liu
2026-09-08 8:38 ` Vlastimil Babka (SUSE) [this message]
2026-09-08 10:04 ` Qiqi Liu
2026-09-08 10:23 ` [PATCH v4] " Qiqi Liu
2026-09-08 12:23 ` Vlastimil Babka (SUSE)
2026-09-08 15:08 ` Gregory Price
2026-09-09 2:20 ` Zi Yan
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=c4c29830-ad49-4ca1-b4d5-6f40d30cdcdc@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brendan.jackman@linux.dev \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuqiqi@kylinos.cn \
--cc=mhocko@suse.com \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.