[PATCH v2 02/12] mm: remove extra ZONE_DEVICE struct page refcount

Ralph Campbell rcampbell at nvidia.com
Wed Sep 15 05:32:37 UTC 2021


On 9/13/21 9:15 AM, Alex Sierra wrote:
> From: Ralph Campbell <rcampbell at nvidia.com>
>
> ZONE_DEVICE struct pages have an extra reference count that complicates the
> code for put_page() and several places in the kernel that need to check the
> reference count to see that a page is not being used (gup, compaction,
> migration, etc.). Clean up the code so the reference count doesn't need to
> be treated specially for ZONE_DEVICE.
>
> Signed-off-by: Ralph Campbell <rcampbell at nvidia.com>
> Signed-off-by: Alex Sierra <alex.sierra at amd.com>
> Reviewed-by: Christoph Hellwig <hch at lst.de>
> ---
> v2:
> AS: merged this patch in linux 5.11 version
>
> v5:
> AS: add condition at try_grab_page to check for the zone device type, while
> page ref counter is checked less/equal to zero. In case of device zone, pages
> ref counter are initialized to zero.
>
> v7:
> AS: fix condition at try_grab_page added at v5, is invalid. It supposed
> to fix xfstests/generic/413 test, however, there's a known issue on
> this test where DAX mapped area DIO to non-DAX expect to fail.
> https://patchwork.kernel.org/project/fstests/patch/1489463960-3579-1-git-send-email-xzhou@redhat.com
> This condition was removed after rebase over patch series
> https://lore.kernel.org/r/20210813044133.1536842-4-jhubbard@nvidia.com
> ---
>   arch/powerpc/kvm/book3s_hv_uvmem.c     |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_dmem.c |  2 +-
>   fs/dax.c                               |  4 +-
>   include/linux/dax.h                    |  2 +-
>   include/linux/memremap.h               |  7 +--
>   include/linux/mm.h                     | 11 ----
>   lib/test_hmm.c                         |  2 +-
>   mm/internal.h                          |  8 +++
>   mm/memremap.c                          | 69 +++++++-------------------
>   mm/migrate.c                           |  5 --
>   mm/page_alloc.c                        |  3 ++
>   mm/swap.c                              | 45 ++---------------
>   12 files changed, 45 insertions(+), 115 deletions(-)
>
I don't see mm/memcontrol.c listed here so I think you will need this fragment too:

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 389b5766e74f..0cc9c7c71e79 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5541,11 +5541,7 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
  	 */
  	if (is_device_private_entry(ent)) {
  		page = pfn_swap_entry_to_page(ent);
-		/*
-		 * MEMORY_DEVICE_PRIVATE means ZONE_DEVICE page and which have
-		 * a refcount of 1 when free (unlike normal page)
-		 */
-		if (!page_ref_add_unless(page, 1, 1))
+		if (!get_page_unless_zero(page))
  			return NULL;
  		return page;
  	}




More information about the dri-devel mailing list