All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH v2] mm: Fix memblock_free_late() when using deferred struct page
Date: Wed, 18 Feb 2026 10:05:24 +0200	[thread overview]
Message-ID: <aZVyxKVS8y-rqwrK@kernel.org> (raw)
In-Reply-To: <4d93284349178a783725539b66dca25725fa779d.camel@kernel.crashing.org>

On Wed, Feb 18, 2026 at 11:15:59AM +1100, Benjamin Herrenschmidt wrote:
> On Wed, 2026-02-18 at 08:47 +1100, Benjamin Herrenschmidt wrote:
> > There is definitely something fishy going on, though I don't know what,
> > as the page is reserved so it should *not* be touched by the deferred
> > initialization... Could there be an issue by which we incorrectly go
> > look at the head page (which hasn't been initialized) of a *potential*
> > compound/huge page ?
> 
> So ... not 100% certain but I see this in __free_one_page():
> 
> 
>   buddy = find_buddy_page_pfn(page, pfn, order, &buddy_pfn);
> 
> Then goes do things with the buddy. find_buddy_page_pfn() is
> (stripping comments):
> 
> static inline unsigned long
> __find_buddy_pfn(unsigned long page_pfn, unsigned int order)
> {
> 	return page_pfn ^ (1 << order);
> }
> 
> static inline struct page *find_buddy_page_pfn(struct page *page,
> 			unsigned long pfn, unsigned int order, unsigned long *buddy_pfn)
> {
> 	unsigned long __buddy_pfn = __find_buddy_pfn(pfn, order);
> 	struct page *buddy;
> 
> 	buddy = page + (__buddy_pfn - pfn);
> 	if (buddy_pfn)
> 		*buddy_pfn = __buddy_pfn;
> 
> 	if (page_is_buddy(page, buddy, order))
> 		return buddy;
> 	return NULL;
> }
> 
> Now what happens if order is 0, page_pfn is a reserved page whose
> "buddy" isn't reserved ... and whose struct page is not initialized
> yet due to deferral ?
> 
> Unless I'm mistaken, we are going to poke around at uninitialized
> struct pages and things can go anywhere from there, can't they ?

It's possible.
 
> Or am I missing a piece of the puzzle ?

Apparently we do miss some piece of the puzzle, otherwise you'd see no
crashes :)

I think an easy and backportable fix would be to make
efi_free_boot_services() an initcall, so that it will surely run after
deferred pages are initialized.
And since the boot services memory is not memblock_alloc()ed but rather
memblock_reserve()ed, it should be freed with free_reserved_area().

With the symptom fixed, we can audit memblock_free_late() and
free_reserved_area() callers and see how to make this all less messy and
more robust.
 
> Cheers,
> Ben.
> 

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2026-02-18  8:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03  8:02 [PATCH] mm: Fix memblock_free_late() when using deferred struct page Benjamin Herrenschmidt
2026-02-03 18:40 ` Mike Rapoport
2026-02-03 19:53   ` Benjamin Herrenschmidt
2026-02-04  7:39     ` Mike Rapoport
2026-02-04  9:02       ` Benjamin Herrenschmidt
2026-02-06 10:33         ` Mike Rapoport
2026-02-10  1:04           ` Benjamin Herrenschmidt
2026-02-10  2:10             ` Benjamin Herrenschmidt
2026-02-10  6:17               ` Benjamin Herrenschmidt
2026-02-10  8:34                 ` Benjamin Herrenschmidt
2026-02-10 14:32                   ` Mike Rapoport
2026-02-10 23:23                     ` Benjamin Herrenschmidt
2026-02-11  5:20                       ` Mike Rapoport
2026-02-16  5:34                       ` Benjamin Herrenschmidt
2026-02-16  6:51                         ` Benjamin Herrenschmidt
2026-02-16  4:53                     ` Benjamin Herrenschmidt
2026-02-16 15:28                       ` Mike Rapoport
2026-02-16 10:36           ` Alexander Potapenko
2026-02-17  8:28 ` [PATCH v2] " Benjamin Herrenschmidt
2026-02-17 12:32   ` Mike Rapoport
2026-02-17 22:00     ` Benjamin Herrenschmidt
2026-02-17 21:47   ` Benjamin Herrenschmidt
2026-02-18  0:15     ` Benjamin Herrenschmidt
2026-02-18  8:05       ` Mike Rapoport [this message]
2026-02-19  2:48         ` Benjamin Herrenschmidt
2026-02-19 10:16           ` Mike Rapoport
2026-02-19 22:46             ` Benjamin Herrenschmidt
2026-02-20  4:57               ` Benjamin Herrenschmidt
2026-02-20  9:09                 ` Mike Rapoport
2026-02-23  2:54                   ` Benjamin Herrenschmidt
2026-02-24  5:56                   ` Benjamin Herrenschmidt
2026-02-20  9:00               ` Mike Rapoport
2026-02-20  5:12             ` Benjamin Herrenschmidt
2026-02-20  5:15             ` Benjamin Herrenschmidt
2026-02-20  5:47             ` Benjamin Herrenschmidt

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=aZVyxKVS8y-rqwrK@kernel.org \
    --to=rppt@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-mm@kvack.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 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.