linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH v14 33/39] mm/lru: Add folio_add_lru()
Date: Thu, 15 Jul 2021 21:00:24 +0100	[thread overview]
Message-ID: <20210715200030.899216-34-willy@infradead.org> (raw)
In-Reply-To: <20210715200030.899216-1-willy@infradead.org>

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>
---
 include/linux/swap.h |  1 +
 mm/folio-compat.c    |  6 ++++++
 mm/swap.c            | 22 +++++++++++-----------
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 5e01675af7ab..81801ba78b1e 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -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 *);
diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index c1e01bc36d32..6de3cd78a4ae 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -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);
diff --git a/mm/swap.c b/mm/swap.c
index 89d4471ceb80..6f382abeccf9 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -459,29 +459,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
-- 
2.30.2



  parent reply	other threads:[~2021-07-15 20:35 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 19:59 [PATCH v14c 00/39] Memory folios: Pagecache edition Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 01/39] mm: Add folio_pfn() Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 02/39] mm: Add folio_raw_mapping() Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 03/39] mm: Add flush_dcache_folio() Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 04/39] mm: Add kmap_local_folio() Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 05/39] mm: Add arch_make_folio_accessible() Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 06/39] mm: Add folio_young and folio_idle Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 07/39] mm/swap: Add folio_activate() Matthew Wilcox (Oracle)
2021-07-15 19:59 ` [PATCH v14 08/39] mm/swap: Add folio_mark_accessed() Matthew Wilcox (Oracle)
2023-10-08 15:34   ` Gregory Price
2023-10-10 18:08     ` Matthew Wilcox
2023-10-13 16:38       ` Gregory Price
2021-07-15 20:00 ` [PATCH v14 09/39] mm/rmap: Add folio_mkclean() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 10/39] mm/migrate: Add folio_migrate_mapping() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 11/39] mm/migrate: Add folio_migrate_flags() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 12/39] mm/migrate: Add folio_migrate_copy() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 13/39] mm/writeback: Rename __add_wb_stat() to wb_stat_mod() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 14/39] flex_proportions: Allow N events instead of 1 Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 15/39] mm/writeback: Change __wb_writeout_inc() to __wb_writeout_add() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 16/39] mm/writeback: Add __folio_end_writeback() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 17/39] mm/writeback: Add folio_start_writeback() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 18/39] mm/writeback: Add folio_mark_dirty() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 19/39] mm/writeback: Add __folio_mark_dirty() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 20/39] mm/writeback: Convert tracing writeback_page_template to folios Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 21/39] mm/writeback: Add filemap_dirty_folio() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 22/39] mm/writeback: Add folio_account_cleaned() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 23/39] mm/writeback: Add folio_cancel_dirty() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 24/39] mm/writeback: Add folio_clear_dirty_for_io() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 25/39] mm/writeback: Add folio_account_redirty() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 26/39] mm/writeback: Add folio_redirty_for_writepage() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 27/39] mm/filemap: Add i_blocks_per_folio() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 28/39] mm/filemap: Add folio_mkwrite_check_truncate() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 29/39] mm/filemap: Add readahead_folio() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 30/39] mm/workingset: Convert workingset_refault() to take a folio Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 31/39] mm: Add folio_evictable() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 32/39] mm/lru: Convert __pagevec_lru_add_fn to take a folio Matthew Wilcox (Oracle)
2021-07-15 20:00 ` Matthew Wilcox (Oracle) [this message]
2021-07-15 20:00 ` [PATCH v14 34/39] mm/page_alloc: Add folio allocation functions Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 35/39] mm/filemap: Add filemap_alloc_folio Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 36/39] mm/filemap: Add filemap_add_folio() Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 37/39] mm/filemap: Convert mapping_get_entry to return a folio Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 38/39] mm/filemap: Add filemap_get_folio Matthew Wilcox (Oracle)
2021-07-15 20:00 ` [PATCH v14 39/39] mm/filemap: Add FGP_STABLE Matthew Wilcox (Oracle)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210715200030.899216-34-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).