Re: [PATCH v2 2/8] mm/huge_memory: add a comment to the open-coded swap entry

From: David Hildenbrand (Arm)

Date: Wed Sep 09 2026 - 10:08:08 EST


On 9/8/26 17:16, Tal Zussman wrote:
> The swap entry of each new folio in __split_folio_to_order() is
> computed by hand from folio->swap rather than with folio_swap_entry(),
> because the folio's page count is not valid while it is being split.
> Add a comment explaining this.
>
> Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
> ---
> mm/huge_memory.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index d1ce061601bc..1fabdcbd8c8f 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -3763,6 +3763,10 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
> */
> VM_WARN_ON_ONCE_PAGE(new_folio->private, new_head);
>
> + /*
> + * Not all folio fields are valid during a split, so open-code
> + * the swap entry rather than using folio_swap_entry().
> + */
> if (folio_test_swapcache(folio))
> new_folio->swap.val = folio->swap.val + i;
>
>

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David