Re: [PATCH 2/2] mm: remove extra ZONE_DEVICE struct page refcount
From: Bharata B Rao
Date: Mon Sep 28 2020 - 23:00:16 EST
On Fri, Sep 25, 2020 at 01:44:42PM -0700, Ralph Campbell wrote:
> 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@xxxxxxxxxx>
> ---
> arch/powerpc/kvm/book3s_hv_uvmem.c | 2 +-
> drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +-
> include/linux/dax.h | 2 +-
> include/linux/memremap.h | 7 ++-
> include/linux/mm.h | 44 --------------
> lib/test_hmm.c | 2 +-
> mm/gup.c | 44 --------------
> mm/internal.h | 8 +++
> mm/memremap.c | 82 ++++++--------------------
> mm/migrate.c | 5 --
> mm/page_alloc.c | 3 +
> mm/swap.c | 46 +++------------
> 12 files changed, 44 insertions(+), 203 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c
> index 7705d5557239..e6ec98325fab 100644
> --- a/arch/powerpc/kvm/book3s_hv_uvmem.c
> +++ b/arch/powerpc/kvm/book3s_hv_uvmem.c
> @@ -711,7 +711,7 @@ static struct page *kvmppc_uvmem_get_page(unsigned long gpa, struct kvm *kvm)
>
> dpage = pfn_to_page(uvmem_pfn);
> dpage->zone_device_data = pvt;
> - get_page(dpage);
> + init_page_count(dpage);
The powerpc change looks good. Passes a quick sanity test of
booting/rebooting a secure guest on Power.
Tested-by: Bharata B Rao <bharata@xxxxxxxxxxxxx>
Regards,
Bharata.