Re: [PATCH] mm/huge_memory: fix dereferencing invalid pmd migration entry

From: Hugh Dickins
Date: Thu Apr 17 2025 - 01:36:35 EST


On Wed, 16 Apr 2025, David Hildenbrand wrote:
>
> Why not something like
>
> struct folio *entry_folio;
>
> if (folio) {
> if (is_pmd_migration_entry(*pmd))
> entry_folio = pfn_swap_entry_folio(pmd_to_swp_entry(*pmd)));
> else
> entry_folio = pmd_folio(*pmd));
>
> if (folio != entry_folio)
> return;
> }

My own preference is to not add unnecessary code:
if folio and pmd_migration entry, we're not interested in entry_folio.
But yes it could be written in lots of other ways.

Hugh