]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm/lru: Add folio_add_lru()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 29 Apr 2021 15:09:31 +0000 (11:09 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 18 Oct 2021 11:49:40 +0000 (07:49 -0400)
Reimplement lru_cache_add() as a wrapper around folio_add_lru().
Saves 159 bytes of kernel text due to removing calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
include/linux/swap.h
mm/folio-compat.c
mm/swap.c

index 892faac942daf865f17d424e782697c1619225bb..cdf0957a88a49a343307646f1ea0c5cbb90cdd33 100644 (file)
@@ -351,6 +351,7 @@ extern unsigned long nr_free_buffer_pages(void);
 extern void lru_note_cost(struct lruvec *lruvec, bool file,
                          unsigned int nr_pages);
 extern void lru_note_cost_folio(struct folio *);
+extern void folio_add_lru(struct folio *);
 extern void lru_cache_add(struct page *);
 void mark_page_accessed(struct page *);
 void folio_mark_accessed(struct folio *);
index c1e01bc36d3225dd8526a7740c211262f87b4760..6de3cd78a4aedbc005de7d33420d04749db03441 100644 (file)
@@ -102,3 +102,9 @@ bool redirty_page_for_writepage(struct writeback_control *wbc,
        return folio_redirty_for_writepage(wbc, page_folio(page));
 }
 EXPORT_SYMBOL(redirty_page_for_writepage);
+
+void lru_cache_add(struct page *page)
+{
+       folio_add_lru(page_folio(page));
+}
+EXPORT_SYMBOL(lru_cache_add);
index 858b4a8220ca8401a4edc9e52498b11979d25765..8ff9ba7cf2de3e79b134581af87b156105753e24 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -437,29 +437,29 @@ void folio_mark_accessed(struct folio *folio)
 EXPORT_SYMBOL(folio_mark_accessed);
 
 /**
- * lru_cache_add - add a page to a page list
- * @page: the page to be added to the LRU.
+ * folio_add_lru - Add a folio to an LRU list.
+ * @folio: The folio to be added to the LRU.
  *
- * Queue the page for addition to the LRU via pagevec. The decision on whether
+ * Queue the folio for addition to the LRU. The decision on whether
  * to add the page to the [in]active [file|anon] list is deferred until the
- * pagevec is drained. This gives a chance for the caller of lru_cache_add()
- * have the page added to the active list using mark_page_accessed().
+ * pagevec is drained. This gives a chance for the caller of folio_add_lru()
+ * have the folio added to the active list using folio_mark_accessed().
  */
-void lru_cache_add(struct page *page)
+void folio_add_lru(struct folio *folio)
 {
        struct pagevec *pvec;
 
-       VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page);
-       VM_BUG_ON_PAGE(PageLRU(page), page);
+       VM_BUG_ON_FOLIO(folio_test_active(folio) && folio_test_unevictable(folio), folio);
+       VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
 
-       get_page(page);
+       folio_get(folio);
        local_lock(&lru_pvecs.lock);
        pvec = this_cpu_ptr(&lru_pvecs.lru_add);
-       if (pagevec_add_and_need_flush(pvec, page))
+       if (pagevec_add_and_need_flush(pvec, &folio->page))
                __pagevec_lru_add(pvec);
        local_unlock(&lru_pvecs.lock);
 }
-EXPORT_SYMBOL(lru_cache_add);
+EXPORT_SYMBOL(folio_add_lru);
 
 /**
  * lru_cache_add_inactive_or_unevictable