]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: Remove folio_pincount_ptr() and head_compound_pincount() for-sid
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 24 Jun 2022 16:48:10 +0000 (12:48 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 2 Jul 2022 18:29:18 +0000 (14:29 -0400)
We can use folio->_pincount directly, since all users are guarded by
tests of compound/large.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Documentation/core-api/pin_user_pages.rst
include/linux/mm.h
mm/gup.c

index b18416f4500feffb7b39407b0ca8fc4f4e08cb21..200a3b9c09e8efa21d4b68b2390a064f39e6cb7a 100644 (file)
@@ -55,18 +55,17 @@ flags the caller provides. The caller is required to pass in a non-null struct
 pages* array, and the function then pins pages by incrementing each by a special
 value: GUP_PIN_COUNTING_BIAS.
 
-For compound pages, the GUP_PIN_COUNTING_BIAS scheme is not used. Instead,
-an exact form of pin counting is achieved, by using the 2nd struct page
-in the compound page. A new struct page field, compound_pincount, has
-been added in order to support this.
+For large folios, the GUP_PIN_COUNTING_BIAS scheme is not used. Instead,
+an exact form of pin counting is achieved, by using the extra space in
+the folio to store the _pincount.
 
-This approach for compound pages avoids the counting upper limit problems that
+This approach for large folios avoids the counting upper limit problems that
 are discussed below. Those limitations would have been aggravated severely by
 huge pages, because each tail page adds a refcount to the head page. And in
-fact, testing revealed that, without a separate compound_pincount field,
+fact, testing revealed that, without a separate _pincount field,
 page overflows were seen in some huge page stress tests.
 
-This also means that huge pages and compound pages do not suffer
+This also means that huge pages and large folios do not suffer
 from the false positives problem that is mentioned below.::
 
  Function
index ffbdd7ea19ca2bca869a7f94862f73728e1e7cb3..cc98ab012a9b2ec7b5454a096dbf33ce081e5753 100644 (file)
@@ -902,11 +902,6 @@ static inline void destroy_large_folio(struct folio *folio)
        compound_page_dtors[dtor](&folio->page);
 }
 
-static inline int head_compound_pincount(struct page *head)
-{
-       return atomic_read(compound_pincount_ptr(head));
-}
-
 static inline void set_compound_order(struct page *page, unsigned int order)
 {
        page[1].compound_order = order;
@@ -1544,11 +1539,6 @@ static inline unsigned long folio_pfn(struct folio *folio)
        return page_to_pfn(&folio->page);
 }
 
-static inline atomic_t *folio_pincount_ptr(struct folio *folio)
-{
-       return &folio_page(folio, 1)->compound_pincount;
-}
-
 /**
  * folio_maybe_dma_pinned - Report if a folio may be pinned for DMA.
  * @folio: The folio.
@@ -1566,7 +1556,7 @@ static inline atomic_t *folio_pincount_ptr(struct folio *folio)
  * expected to be able to deal gracefully with a false positive.
  *
  * For large folios, the result will be exactly correct. That's because
- * we have more tracking data available: the compound_pincount is used
+ * we have more tracking data available: the _pincount field is used
  * instead of the GUP_PIN_COUNTING_BIAS scheme.
  *
  * For more information, please see Documentation/core-api/pin_user_pages.rst.
@@ -1577,7 +1567,7 @@ static inline atomic_t *folio_pincount_ptr(struct folio *folio)
 static inline bool folio_maybe_dma_pinned(struct folio *folio)
 {
        if (folio_test_large(folio))
-               return atomic_read(folio_pincount_ptr(folio)) > 0;
+               return atomic_read(&folio->_pincount) > 0;
 
        /*
         * folio_ref_count() is signed. If that refcount overflows, then
index 5512644076246d9baaa4873c9019cde4e17a2e37..76688f45ff2e8688f5491cc9ab04cc0e8c0a45d3 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -153,7 +153,7 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags)
                 * try_get_folio() is left intact.
                 */
                if (folio_test_large(folio))
-                       atomic_add(refs, folio_pincount_ptr(folio));
+                       atomic_add(refs, &folio->_pincount);
                else
                        folio_ref_add(folio,
                                        refs * (GUP_PIN_COUNTING_BIAS - 1));
@@ -171,7 +171,7 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags)
        if (flags & FOLL_PIN) {
                node_stat_mod_folio(folio, NR_FOLL_PIN_RELEASED, refs);
                if (folio_test_large(folio))
-                       atomic_sub(refs, folio_pincount_ptr(folio));
+                       atomic_sub(refs, &folio->_pincount);
                else
                        refs *= GUP_PIN_COUNTING_BIAS;
        }
@@ -215,7 +215,7 @@ bool __must_check try_grab_page(struct page *page, unsigned int flags)
                 */
                if (folio_test_large(folio)) {
                        folio_ref_add(folio, 1);
-                       atomic_add(1, folio_pincount_ptr(folio));
+                       atomic_add(1, &folio->_pincount);
                } else {
                        folio_ref_add(folio, GUP_PIN_COUNTING_BIAS);
                }