Re: [PATCH 2/4] mm/huge_memory: skip zone device folios in madvise_free_huge_pmd()

From: Gregory Price

Date: Thu Aug 06 2026 - 13:12:09 EST


On Thu, Aug 06, 2026 at 02:59:22PM +0100, Lorenzo Stoakes (ARM) wrote:
> I kinda wish he had some generalised folio handler like:
>
> struct folio_ops {
> int (*handle_empty_entry)(void *priv);
> int (*handle_normal_folio)(void *priv, struct folio *folio);
> int (*handle_softleaf_pte_entry)(void *priv, const pte_t *ptep);
> int (*handle_zone_folio)(void *priv, struct folio *folio);
> ...
> };
>
> Or I don't know an equivalent type of thing, as we keep having these same
> patterns emerge in mm that are duplicated in a million places with slight
> variations... :)
>
> I wonder if C is expressive enough to get us to something sane though.
>

This is functionally folio->pgmap except it's not generalized and it
causes us pain :[

I briefly took a forray into moving pgmap to be node-scope, and that
works decently, but first i'm just trying to clena up what i can for
zone device.

Anyway, i get what you're getting at here, and that would be nice.

> > Fixes: 368076f52ebe ("mm/huge_memory: add device-private THP support to PMD operations")
> > Cc: <stable@xxxxxxxxxxxxxxx>
> > Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
>
> Anyway LGTM so:
>
> Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
>

many thanks :]