Re: [PATCH v5 1/8] mm: fix stale ZONE_DEVICE refcount comment
From: Alistair Popple
Date: Mon Jul 06 2026 - 22:28:44 EST
On 2026-07-01 at 19:05 +1000, Li Zhe <lizhe.67@xxxxxxxxxxxxx> wrote...
> The comment in __init_zone_device_page() still uses the old
> MEMORY_TYPE_* names and implies that FS_DAX pages regain a
> refcount of 1 in the free path. That no longer matches the code.
>
> Update the comment to describe the current policy correctly:
> MEMORY_DEVICE_GENERIC pages regain a refcount of 1 in the free path,
> while the remaining ZONE_DEVICE types start from 0 here and raise the
> count again when the allocator or driver hands the page out.
>
> No functional change intended.
>
> Signed-off-by: Li Zhe <lizhe.67@xxxxxxxxxxxxx>
Accidentally just sent my response on v4, but this looks correct to me:
Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx>
> ---
> mm/mm_init.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 0f64909e8d20..95808ab5cfdb 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1030,13 +1030,9 @@ static void __ref __init_zone_device_page(struct page *page, unsigned long pfn,
> page->zone_device_data = NULL;
>
> /*
> - * ZONE_DEVICE pages other than MEMORY_TYPE_GENERIC are released
> - * directly to the driver page allocator which will set the page count
> - * to 1 when allocating the page.
> - *
> - * MEMORY_TYPE_GENERIC and MEMORY_TYPE_FS_DAX pages automatically have
> - * their refcount reset to one whenever they are freed (ie. after
> - * their refcount drops to 0).
> + * MEMORY_DEVICE_GENERIC pages regain a refcount of 1 in the free
> + * path. The remaining ZONE_DEVICE types start from 0 here and raise
> + * the count again when the allocator or driver hands the page out.
> */
> switch (pgmap->type) {
> case MEMORY_DEVICE_FS_DAX:
> --
> 2.20.1