mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Yuan Liu <yuan1.liu@intel.com>,
	Oscar Salvador <osalvador@suse.de>,
	Mike Rapoport <rppt@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Chen Yu <yu.c.chen@intel.com>, Jason Zeng <jason.zeng@intel.com>,
	Vlastimil Babka <vbabka@kernel.org>
Subject: Re: [BUG] mm/memory_hotplug: panic due to race between compaction and memory hot-unplug
Date: Wed, 16 Sep 2026 17:03:36 +0200	[thread overview]
Message-ID: <b41603e4-3ec7-4da5-b567-59ff16f93f65@kernel.org> (raw)
In-Reply-To: <20260912020624.tyu6gwj3tssxfjp3@master>

On 9/12/26 04:06, Wei Yang wrote:
> On Thu, Sep 10, 2026 at 09:40:32AM +0200, David Hildenbrand (Arm) wrote:
>> On 9/10/26 05:16, Wei Yang wrote:
>>>
>>> Does it mean, the combination of pfn_to_online_page() / PageBuddy(page) is not
>>> safe, when there is hot-remove, even for other users. Not only compaction.
>>
>> There is an inherent race between any
>>
>> pfn_to_online_page() user that then takes a look at the memmap (PageBuddy,
>> whatever).
>>
>> Usually, that's not really relevant, because for things to go terrible wrong
>> (instead of only being slightly suboptimal :) )
>>
>> You have to run both, memory offlining *and* memory removal.
>>
>> For things like
>>
>> page = pfn_to_online_page()
>> if (PageBuddy(page))
>>
>> That's unlikely to hit (no reports), and we could likely easily fix it with the
>> help of RCU.
>>
>> It gets more problematic when we do things like
>>
>> page = pfn_to_online_page()
>> ... do all other kind of stuff
>> if (PageBuddy(page))
>>
>> (what we have here)
>>
> 
> Thanks for the explanation. I still have one confusion.
> 
> What we have here is:
> 
> isolate_freepages(cc)
>     page = pageblock_pfn_to_page()
>         if (zone->contiguous)
> 	    return pfn_to_page(pfn)
>         return __pageblock_pfn_to_page()
>             start_page = pfn_to_online_page()                       (1)
>             ... check page_zone(start_page) and page_zone_id()
>             return start_page
>     suitable_migration_target(cc, page)
>         if (PageBuddy(page))                                        (2)
> 
> It looks the extra stuff between (1) and (2) is trivial and they still rely on
> page struct. 

Right, on that path there is indeed not a lot happening.

> 
> Do you think it could be caused by the data synchronization between CPUs?
> 
> Two possible points:
> 
>   a) zone->contiguous
>   b) section_mem_map's SECTION_IS_ONLINE bit

Hm, not sure. Given that we run in a VM, we might just be pausing one VCPU for a
bit longer and be able to trigger this :(

On the bright side, *maybe* RCU could be used to sync here. Well, we really have
to isolate the page to stop offlining to just make progress by taking the free
page ...


-- 
Cheers,

David

      reply	other threads:[~2026-09-16 15:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  9:55 Yuan Liu
2026-09-07 14:27 ` David Hildenbrand (Arm)
2026-09-10  3:16   ` Wei Yang
2026-09-10  7:40     ` David Hildenbrand (Arm)
2026-09-12  2:06       ` Wei Yang
2026-09-16 15:03         ` David Hildenbrand (Arm) [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=b41603e4-3ec7-4da5-b567-59ff16f93f65@kernel.org \
    --to=david@kernel.org \
    --cc=jason.zeng@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=richard.weiyang@gmail.com \
    --cc=rppt@kernel.org \
    --cc=vbabka@kernel.org \
    --cc=yu.c.chen@intel.com \
    --cc=yuan1.liu@intel.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

all inboxes | Powered by JetHome®