mm: generalize the pgmap based page_free infrastructure
authorChristoph Hellwig <hch@lst.de>
Wed, 16 Feb 2022 04:31:37 +0000 (15:31 +1100)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 3 Mar 2022 17:47:33 +0000 (12:47 -0500)
Key off on the existence of ->page_free to prepare for adding support for
more pgmap types that are device managed and thus need the free callback.

Link: https://lkml.kernel.org/r/20220210072828.2930359-10-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: "Sierra Guiza, Alejandro (Alex)" <alex.sierra@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Chaitanya Kulkarni <kch@nvidia.com>
Cc: Christian Knig <christian.koenig@amd.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Karol Herbst <kherbst@redhat.com>
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/memremap.c

index fef5734..e00ffcd 100644 (file)
@@ -452,7 +452,7 @@ EXPORT_SYMBOL_GPL(get_dev_pagemap);
 
 void free_zone_device_page(struct page *page)
 {
-       if (WARN_ON_ONCE(!is_device_private_page(page)))
+       if (WARN_ON_ONCE(!page->pgmap->ops || !page->pgmap->ops->page_free))
                return;
 
        __ClearPageWaiters(page);
@@ -460,7 +460,7 @@ void free_zone_device_page(struct page *page)
        mem_cgroup_uncharge(page_folio(page));
 
        /*
-        * When a device_private page is freed, the page->mapping field
+        * When a device managed page is freed, the page->mapping field
         * may still contain a (stale) mapping value. For example, the
         * lower bits of page->mapping may still identify the page as an
         * anonymous page. Ultimately, this entire field is just stale