]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - kernel/memremap.c
Merge remote-tracking branch 'origin/master' into drm-misc-fixes
[linux.git] / kernel / memremap.c
index f1d1e0dfe8b4f693db64668c46873a56ab8995d7..6bcbfbf1a8fdfd2f1008cde707db9a798a68cdc6 100644 (file)
@@ -11,7 +11,6 @@
  * General Public License for more details.
  */
 #include <linux/radix-tree.h>
-#include <linux/memremap.h>
 #include <linux/device.h>
 #include <linux/types.h>
 #include <linux/pfn_t.h>
@@ -500,3 +499,28 @@ struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)
        return pgmap ? pgmap->altmap : NULL;
 }
 #endif /* CONFIG_ZONE_DEVICE */
+
+
+#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) ||  IS_ENABLED(CONFIG_DEVICE_PUBLIC)
+void put_zone_device_private_or_public_page(struct page *page)
+{
+       int count = page_ref_dec_return(page);
+
+       /*
+        * If refcount is 1 then page is freed and refcount is stable as nobody
+        * holds a reference on the page.
+        */
+       if (count == 1) {
+               /* Clear Active bit in case of parallel mark_page_accessed */
+               __ClearPageActive(page);
+               __ClearPageWaiters(page);
+
+               page->mapping = NULL;
+               mem_cgroup_uncharge(page);
+
+               page->pgmap->page_free(page, page->pgmap->data);
+       } else if (!count)
+               __put_page(page);
+}
+EXPORT_SYMBOL(put_zone_device_private_or_public_page);
+#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */