History

mm: move free_devmap_managed_page to memremap.c

free_devmap_managed_page has nothing to do with the code in swap.c, move it to live with the rest of the code for devmap handling. Link: https://lkml.kernel.org/r/20220210072828.2930359-5-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Tested-by: "Sierra Guiza, Alejandro (Alex)" <alex.sierra@amd.com>

Christoph Hellwig committed 4 years ago

Commit 75e55d81 parent 730ff523 files · +21 −24Browse files

Unified · Split

3 files
  1. include/linux/mm.h +0 −1
  2. mm/memremap.c +21 −0
  3. mm/swap.c +0 −23
include/linux/mm.h+0−1
@@ -1092,7 +1092,6 @@ static inline bool is_zone_movable_page(const struct page *page) · 1091 unmodified lines
10921092 }
10931093
10941094 #ifdef CONFIG_DEV_PAGEMAP_OPS
1095−void free_devmap_managed_page(struct page *page);
10961095 DECLARE_STATIC_KEY_FALSE(devmap_managed_key);
10971096
10981097 static inline bool page_is_devmap_managed(struct page *page)
mm/memremap.c+21−0
@@ -501,4 +501,25 @@ void free_devmap_managed_page(struct page *page) · 500 unmodified lines
501501 page->mapping = NULL;
502502 page->pgmap->ops->page_free(page);
503503 }
504+
505+void put_devmap_managed_page(struct page *page)
506+{
507+ int count;
508+
509+ if (WARN_ON_ONCE(!page_is_devmap_managed(page)))
510+ return;
511+
512+ count = page_ref_dec_return(page);
513+
514+ /*
515+ * devmap page refcounts are 1-based, rather than 0-based: if
516+ * refcount is 1, then the page is free and the refcount is
517+ * stable because nobody holds a reference on the page.
518+ */
519+ if (count == 1)
520+ free_devmap_managed_page(page);
521+ else if (!count)
522+ __put_page(page);
523+}
524+EXPORT_SYMBOL(put_devmap_managed_page);
504525 #endif /* CONFIG_DEV_PAGEMAP_OPS */
mm/swap.c+0−23
@@ -1154,26 +1154,3 @@ void __init swap_setup(void) · 1153 unmodified lines
11541154 * _really_ don't want to cluster much more
11551155 */
11561156 }
1157−
1158−#ifdef CONFIG_DEV_PAGEMAP_OPS
1159−void put_devmap_managed_page(struct page *page)
1160−{
1161− int count;
1162−
1163− if (WARN_ON_ONCE(!page_is_devmap_managed(page)))
1164− return;
1165−
1166− count = page_ref_dec_return(page);
1167−
1168− /*
1169− * devmap page refcounts are 1-based, rather than 0-based: if
1170− * refcount is 1, then the page is free and the refcount is
1171− * stable because nobody holds a reference on the page.
1172− */
1173− if (count == 1)
1174− free_devmap_managed_page(page);
1175− else if (!count)
1176− __put_page(page);
1177−}
1178−EXPORT_SYMBOL(put_devmap_managed_page);
1179−#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t