From: sashiko-bot@kernel.org
To: "Gregory Price (Meta)" <gourry@gourry.net>, linux-mm@kvack.org
Cc: linux-cxl@vger.kernel.org, kernel-team@meta.com,
akpm@linux-foundation.org, vbabka@kernel.org, surenb@google.com,
mhocko@suse.com, brendan.jackman@linux.dev, hannes@cmpxchg.org,
ziy@nvidia.com, linmiaohe@huawei.com, nao.horiguchi@gmail.com,
david@kernel.org, ljs@kernel.org, liam@infradead.org,
rppt@kernel.org, osalvador@suse.de, muchun.song@linux.dev,
iamjoonsoo.kim@lge.com, anshuman.khandual@arm.com
Subject: Re: [PATCH 2/6] mm/page_owner: hold off memory offline while a page is read
Date: Wed, 28 Oct 2026 04:22:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-187474@kernel.org> (raw)
In-Reply-To: <20261027042204.3741307-3-gourry@gourry.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm/page_owner: read_page_owner() mixes guard(pfn_walk) with goto cleanup
--
commit b2d3acd01e2d83565fff990fcda39fb4ee08ffa7
Author: Gregory Price (Meta) <gourry@gourry.net>
mm/page_owner: hold off memory offline while a page is read
This commit prevents page faults during concurrent memory offlining or removal
when reading /sys/kernel/debug/page_owner by checking PFNs with
pfn_to_online_page() inside a pfn_walk read section and moving kmalloc() and
copy_to_user() outside that section.
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index cfc31c92d7657..d2c0b831fcd3b 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
[ ... ]
> @@ -766,7 +760,12 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> continue;
> }
>
> - page = pfn_to_page(pfn);
> + /* Offline waits for us before it poisons the memmap */
> + guard(pfn_walk)();
> + page = pfn_to_online_page(pfn);
> + if (!page)
> + continue;
> +
> if (skip_buddy_pages(&pfn, page))
> continue;
>
> @@ -825,14 +824,18 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
>
> page_owner_tmp = *page_owner;
> page_ext_put(page_ext);
> - return print_page_owner(buf, count, pfn, page,
> + ret = print_page_owner(kbuf, count, pfn, page,
> &page_owner_tmp, handle, state);
> + break;
> ext_put_continue:
> page_ext_put(page_ext);
> cond_resched();
> }
[Severity: Medium]
In read_page_owner(), guard(pfn_walk)() is declared inside the for-loop body,
so its scope extends to the closing brace of the loop after cond_resched().
When a PFN is skipped via goto ext_put_continue (for example on an unallocated
page, tail page, missing handle, or filtered node ID):
mm/page_owner.c:read_page_owner() {
for (; pfn < max_pfn; pfn++) {
...
guard(pfn_walk)();
...
if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags))
goto ext_put_continue;
...
ext_put_continue:
page_ext_put(page_ext);
cond_resched();
}
}
First, include/linux/cleanup.h notes that goto-based cleanup and scope-based
cleanup helpers should not be mixed in the same function.
Second, because the guard(pfn_walk) scope only ends at the closing brace of
the loop, cond_resched() is called while the pfn_walk SRCU read lock is still
held, even though all accesses to struct page and page_ext for that PFN have
already completed. If the task is scheduled out in cond_resched(), concurrent
memory offlining in offline_pages() -> remove_pfn_range_from_zone() ->
pfn_walk_synchronize() has to wait for the reader to be scheduled back in
while holding the memory hotplug locks.
Should the pfn_walk guard and page_ext cleanup be scoped so that the pfn_walk
read section ends before cond_resched(), and without mixing guard() with
goto-based cleanup?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027042204.3741307-1-gourry@gourry.net?part=2
next prev parent reply other threads:[~2026-10-28 4:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 4:21 [PATCH 0/6] mm: fix pfn walker races with memory offline Gregory Price (Meta)
2026-10-27 4:21 ` [PATCH 1/6] mm/compaction: wait for pfn walkers before poisoning offlined memmap Gregory Price (Meta)
2026-10-27 13:38 ` David Hildenbrand (Arm)
2026-10-28 4:22 ` sashiko-bot
2026-10-27 4:22 ` [PATCH 2/6] mm/page_owner: hold off memory offline while a page is read Gregory Price (Meta)
2026-10-28 4:22 ` sashiko-bot [this message]
2026-10-27 4:22 ` [PATCH 3/6] mm/memory-failure: keep the page online while handling it Gregory Price (Meta)
2026-10-27 4:22 ` [PATCH 4/6] mm/page_alloc: don't undo another isolation in alloc_contig_range Gregory Price (Meta)
2026-10-27 13:37 ` David Hildenbrand (Arm)
2026-10-27 14:06 ` Gregory Price (Meta)
2026-10-27 14:13 ` David Hildenbrand (Arm)
2026-10-27 18:53 ` Zi Yan
2026-10-27 18:58 ` David Hildenbrand (Arm)
2026-10-27 19:38 ` Gregory Price
2026-10-27 4:22 ` [PATCH 5/6] mm/page_alloc: keep the range online while alloc_contig isolates it Gregory Price (Meta)
2026-10-27 4:22 ` [PATCH 6/6] mm/hwpoison-inject: keep the page online while filtering it Gregory Price (Meta)
2026-10-27 8:57 ` [PATCH 0/6] mm: fix pfn walker races with memory offline David Hildenbrand (Arm)
2026-10-27 11:31 ` Gregory Price (Meta)
2026-10-27 12:51 ` David Hildenbrand (Arm)
2026-10-27 13:49 ` Gregory Price (Meta)
2026-10-27 14:25 ` David Hildenbrand (Arm)
2026-10-27 15:49 ` Gregory Price (Meta)
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=sashiko-outbox-187474@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=brendan.jackman@linux.dev \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--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