Re: [PATCH v4 1/8] mm: fix stale ZONE_DEVICE refcount comment
From: Alistair Popple
Date: Mon Jul 06 2026 - 22:17:34 EST
On 2026-06-03 at 18:01 +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.
Correct, obviously I missed this comment when updating 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.
It would be nice to make MEMORY_DEVICE_GENERIC the same one day too. But this
change looks accurate to me:
Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx>
> No functional change intended.
>
> Signed-off-by: Li Zhe <lizhe.67@xxxxxxxxxxxxx>
> ---
> 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 f9f8e1af921c..35de3b6a186d 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1027,13 +1027,9 @@ static void __ref __init_zone_device_page(struct page *page, unsigned long pfn,
> }
>
> /*
> - * 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