Re: [PATCH] drm/pagemap: Reset migration page count on eviction retry

Matthew Brost <[email protected]>
Newsgroups org.freedesktop.lists.intel-xe,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Tue, Jul 28, 2026 at 02:33:04PM +0530, Arvind Yadav wrote:
> drm_pagemap_evict_to_ram() may retry eviction, but mpages retains
> the count from the previous attempt. A retry can therefore continue
> to the copy path even when no RAM pages were populated.
> 
> Reset mpages at the retry label so it reflects only the current
> attempt.
> 
> Fixes: 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual Memory")

I think you also want the patch which moved drm_pagemap to its own file:

f86ad0ed620c drm/gpusvm, drm/pagemap: Move migration functionality to drm_pagemap

> Cc: Matthew Brost <[email protected]>

Fix itself LGTM:
Reviewed-by: Matthew Brost <[email protected]>

> Cc: Thomas Hellström <[email protected]>
> Cc: Himal Prasad Ghimiray <[email protected]>
> Cc: Maarten Lankhorst <[email protected]>
> Cc: Maxime Ripard <[email protected]>
> Cc: Thomas Zimmermann <[email protected]>
> Cc: David Airlie <[email protected]>
> Cc: Simona Vetter <[email protected]>
> Signed-off-by: Arvind Yadav <[email protected]>
> ---
>  drivers/gpu/drm/drm_pagemap.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c
> index 4a794544b7dc..7faba4acd59f 100644
> --- a/drivers/gpu/drm/drm_pagemap.c
> +++ b/drivers/gpu/drm/drm_pagemap.c
> @@ -1122,7 +1122,7 @@ int drm_pagemap_evict_to_ram(struct drm_pagemap_devmem *devmem_allocation)
>  {
>  	const struct drm_pagemap_devmem_ops *ops = devmem_allocation->ops;
>  	struct drm_pagemap_iova_state state = {};
> -	unsigned long npages, mpages = 0;
> +	unsigned long npages, mpages;
>  	struct page **pages;
>  	unsigned long *src, *dst;
>  	struct drm_pagemap_addr *pagemap_addr;
> @@ -1133,6 +1133,7 @@ int drm_pagemap_evict_to_ram(struct drm_pagemap_devmem *devmem_allocation)
>  	npages = devmem_allocation->size >> PAGE_SHIFT;
>  
>  retry:
> +	mpages = 0;
>  	if (!mmget_not_zero(devmem_allocation->mm))
>  		return -EFAULT;
>  
> -- 
> 2.43.0
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.