Re: [PATCH v2] mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all()

From: Michal Hocko
Date: Thu Sep 08 2022 - 12:48:57 EST

On Thu 08-09-22 15:23:03, Kirill A. Shutemov wrote:
> But it makes me think if there's other similar cases. "page is offline" is
> rather obscure case that rarely covered by routine testing. Otherwise the
> bug would not survive for 6 years.
> After quick look, kvm_pfn_to_refcounted_page() looks suspicious.

this one is hard to judge for me. Is this ever used for something that
could be offlined?

> kdb_getphys() too.

this one looks it needs a fix

> Maybe we should make pfn_valid() false for offline pages and introduce
> other check that allows offline pages which can be used in codepaths that
> deal with offline pages explicitly.

Back when pfn_to_online page was introduced altering pfn_valid was
considered but the semantic is not the same. offline pages could be
still pfn_valid. The discussion should be in archives. Sorry do not have
the link handy. We have also considered changing pfn_to_page but that
would add an overhead for unlikely case to everybody. So the conclusion
was that only pfn walkers should care. Most other users just translate
pfn to page when the page cannot be offlined (e.g. because it is

I do realize this is fragile but we couldn't come up with something more
clever without introducing overhead all over the place.
Michal Hocko