diff mbox series

[31/75] mm: Add lru_to_folio()

Message ID 20220204195852.1751729-32-willy@infradead.org (mailing list archive)
State New
Headers show
Series MM folio patches for 5.18 | expand

Commit Message

Matthew Wilcox Feb. 4, 2022, 7:58 p.m. UTC
Since page->lru occupies the same bytes as compound_head, any page
on the LRU list must be a folio.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/mm.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Christoph Hellwig Feb. 7, 2022, 7:50 a.m. UTC | #1
On Fri, Feb 04, 2022 at 07:58:08PM +0000, Matthew Wilcox (Oracle) wrote:
> Since page->lru occupies the same bytes as compound_head, any page
> on the LRU list must be a folio.

Any reason to not turn this into an inline function?
Matthew Wilcox Feb. 11, 2022, 8:24 p.m. UTC | #2
On Sun, Feb 06, 2022 at 11:50:06PM -0800, Christoph Hellwig wrote:
> On Fri, Feb 04, 2022 at 07:58:08PM +0000, Matthew Wilcox (Oracle) wrote:
> > Since page->lru occupies the same bytes as compound_head, any page
> > on the LRU list must be a folio.
> 
> Any reason to not turn this into an inline function?

Good idea.  Done.
diff mbox series

Patch

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3ca6dea4fe4a..6cb2651eccbe 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -229,6 +229,7 @@  int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
 #define PAGE_ALIGNED(addr)	IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)
 
 #define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
+#define lru_to_folio(head) (list_entry((head)->prev, struct folio, lru))
 
 void setup_initial_init_mm(void *start_code, void *end_code,
 			   void *end_data, void *brk);