On Mon, Apr 27, 2026 at 08:33:30PM +0800, Lance Yang wrote:
> 
> On Fri, Apr 24, 2026 at 05:23:59AM -0700, Breno Leitao wrote:
> >When get_hwpoison_page() returns a negative value, distinguish
> >reserved pages from other failure cases by reporting MF_MSG_KERNEL
> >instead of MF_MSG_GET_HWPOISON. Reserved pages belong to the kernel
> >and should be classified accordingly for proper handling.
> >
> >Acked-by: Miaohe Lin <[email protected]>
> >Signed-off-by: Breno Leitao <[email protected]>
> >---
> > mm/memory-failure.c | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> >diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> >index ee42d43613097..7b67e43dafbd1 100644
> >--- a/mm/memory-failure.c
> >+++ b/mm/memory-failure.c
> >@@ -2432,7 +2432,16 @@ int memory_failure(unsigned long pfn, int flags)
> >             }
> >             goto unlock_mutex;
> >     } else if (res < 0) {
> >-            res = action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED);
> >+            /*
> >+             * PageReserved is stable here: reserved pages have
> >+             * PG_reserved set at boot or by drivers and are never
> >+             * freed through the page allocator.
> >+             */
> 
> Not necessarily. PG_reserved is not a permanent lifetime property for
> every page that has carried it.
> 
> page-flags.h says early reserved pages may later have PG_reserved
> cleared and then be given to the page allocator :)
> 
> At least some drivers also clear PG_reserved when releasing pages they
> marked reserved.
> 
> Would it be clearer to say that pages with PG_reserved set are not
> currently managed by the page allocator, rather than saying reserved
> pages are never freed through the page allocator?

Would a comment like the following look better?

  /*
   * Pages with PG_reserved set are not currently managed by the
   * page allocator (memblock-reserved memory, driver reservations,
   * etc.), so classify them as kernel-owned for reporting.
   */
  if (PageReserved(p))
      res = action_result(pfn, MF_MSG_KERNEL, MF_IGNORED);

Thanks for the review,
--breno

Reply via email to