mm,thp,rmap: simplify compound page mapcount handling
[linux-2.6-block.git] / mm / util.c
index 12984e76767ebd2b8e488a00d485fb4b82c20e41..b56c92fb910fc6d82d18fd6d8f30f4c8f45cb65b 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -717,32 +717,6 @@ void *page_rmapping(struct page *page)
        return folio_raw_mapping(page_folio(page));
 }
 
-/**
- * folio_mapped - Is this folio mapped into userspace?
- * @folio: The folio.
- *
- * Return: True if any page in this folio is referenced by user page tables.
- */
-bool folio_mapped(struct folio *folio)
-{
-       long i, nr;
-
-       if (!folio_test_large(folio))
-               return atomic_read(&folio->_mapcount) >= 0;
-       if (atomic_read(folio_mapcount_ptr(folio)) >= 0)
-               return true;
-       if (folio_test_hugetlb(folio))
-               return false;
-
-       nr = folio_nr_pages(folio);
-       for (i = 0; i < nr; i++) {
-               if (atomic_read(&folio_page(folio, i)->_mapcount) >= 0)
-                       return true;
-       }
-       return false;
-}
-EXPORT_SYMBOL(folio_mapped);
-
 struct anon_vma *folio_anon_vma(struct folio *folio)
 {
        unsigned long mapping = (unsigned long)folio->mapping;
@@ -783,59 +757,6 @@ struct address_space *folio_mapping(struct folio *folio)
 }
 EXPORT_SYMBOL(folio_mapping);
 
-/* Slow path of page_mapcount() for compound pages */
-int __page_mapcount(struct page *page)
-{
-       int ret;
-
-       ret = atomic_read(&page->_mapcount) + 1;
-       /*
-        * For file THP page->_mapcount contains total number of mapping
-        * of the page: no need to look into compound_mapcount.
-        */
-       if (!PageAnon(page) && !PageHuge(page))
-               return ret;
-       page = compound_head(page);
-       ret += atomic_read(compound_mapcount_ptr(page)) + 1;
-       if (PageDoubleMap(page))
-               ret--;
-       return ret;
-}
-EXPORT_SYMBOL_GPL(__page_mapcount);
-
-/**
- * folio_mapcount() - Calculate the number of mappings of this folio.
- * @folio: The folio.
- *
- * A large folio tracks both how many times the entire folio is mapped,
- * and how many times each individual page in the folio is mapped.
- * This function calculates the total number of times the folio is
- * mapped.
- *
- * Return: The number of times this folio is mapped.
- */
-int folio_mapcount(struct folio *folio)
-{
-       int i, compound, nr, ret;
-
-       if (likely(!folio_test_large(folio)))
-               return atomic_read(&folio->_mapcount) + 1;
-
-       compound = folio_entire_mapcount(folio);
-       if (folio_test_hugetlb(folio))
-               return compound;
-       ret = compound;
-       nr = folio_nr_pages(folio);
-       for (i = 0; i < nr; i++)
-               ret += atomic_read(&folio_page(folio, i)->_mapcount) + 1;
-       /* File pages has compound_mapcount included in _mapcount */
-       if (!folio_test_anon(folio))
-               return ret - compound * nr;
-       if (folio_test_double_map(folio))
-               ret -= nr;
-       return ret;
-}
-
 /**
  * folio_copy - Copy the contents of one folio to another.
  * @dst: Folio to copy to.