Merge tag 'folio-5.16' of git://git.infradead.org/users/willy/pagecache
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 1 Nov 2021 15:47:59 +0000 (08:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 1 Nov 2021 15:47:59 +0000 (08:47 -0700)
Pull memory folios from Matthew Wilcox:
 "Add memory folios, a new type to represent either order-0 pages or the
  head page of a compound page. This should be enough infrastructure to
  support filesystems converting from pages to folios.

  The point of all this churn is to allow filesystems and the page cache
  to manage memory in larger chunks than PAGE_SIZE. The original plan
  was to use compound pages like THP does, but I ran into problems with
  some functions expecting only a head page while others expect the
  precise page containing a particular byte.

  The folio type allows a function to declare that it's expecting only a
  head page. Almost incidentally, this allows us to remove various calls
  to VM_BUG_ON(PageTail(page)) and compound_head().

  This converts just parts of the core MM and the page cache. For 5.17,
  we intend to convert various filesystems (XFS and AFS are ready; other
  filesystems may make it) and also convert more of the MM and page
  cache to folios. For 5.18, multi-page folios should be ready.

  The multi-page folios offer some improvement to some workloads. The
  80% win is real, but appears to be an artificial benchmark (postgres
  startup, which isn't a serious workload). Real workloads (eg building
  the kernel, running postgres in a steady state, etc) seem to benefit
  between 0-10%. I haven't heard of any performance losses as a result
  of this series. Nobody has done any serious performance tuning; I
  imagine that tweaking the readahead algorithm could provide some more
  interesting wins. There are also other places where we could choose to
  create large folios and currently do not, such as writes that are
  larger than PAGE_SIZE.

  I'd like to thank all my reviewers who've offered review/ack tags:
  Christoph Hellwig, David Howells, Jan Kara, Jeff Layton, Johannes
  Weiner, Kirill A. Shutemov, Michal Hocko, Mike Rapoport, Vlastimil
  Babka, William Kucharski, Yu Zhao and Zi Yan.

  I'd also like to thank those who gave feedback I incorporated but
  haven't offered up review tags for this part of the series: Nick
  Piggin, Mel Gorman, Ming Lei, Darrick Wong, Ted Ts'o, John Hubbard,
  Hugh Dickins, and probably a few others who I forget"

* tag 'folio-5.16' of git://git.infradead.org/users/willy/pagecache: (90 commits)
  mm/writeback: Add folio_write_one
  mm/filemap: Add FGP_STABLE
  mm/filemap: Add filemap_get_folio
  mm/filemap: Convert mapping_get_entry to return a folio
  mm/filemap: Add filemap_add_folio()
  mm/filemap: Add filemap_alloc_folio
  mm/page_alloc: Add folio allocation functions
  mm/lru: Add folio_add_lru()
  mm/lru: Convert __pagevec_lru_add_fn to take a folio
  mm: Add folio_evictable()
  mm/workingset: Convert workingset_refault() to take a folio
  mm/filemap: Add readahead_folio()
  mm/filemap: Add folio_mkwrite_check_truncate()
  mm/filemap: Add i_blocks_per_folio()
  mm/writeback: Add folio_redirty_for_writepage()
  mm/writeback: Add folio_account_redirty()
  mm/writeback: Add folio_clear_dirty_for_io()
  mm/writeback: Add folio_cancel_dirty()
  mm/writeback: Add folio_account_cleaned()
  mm/writeback: Add filemap_dirty_folio()
  ...

1  2 
fs/afs/write.c
fs/io_uring.c
include/linux/page-flags.h
mm/huge_memory.c
mm/khugepaged.c
mm/memory-failure.c
mm/memory.c
mm/mempolicy.c
mm/migrate.c
mm/page_alloc.c

diff --cc fs/afs/write.c
Simple merge
diff --cc fs/io_uring.c
Simple merge
@@@ -669,28 -776,14 +785,28 @@@ static inline int PageTransTail(struct 
  PAGEFLAG(DoubleMap, double_map, PF_SECOND)
        TESTSCFLAG(DoubleMap, double_map, PF_SECOND)
  #else
- TESTPAGEFLAG_FALSE(TransHuge)
- TESTPAGEFLAG_FALSE(TransCompound)
- TESTPAGEFLAG_FALSE(TransCompoundMap)
- TESTPAGEFLAG_FALSE(TransTail)
- PAGEFLAG_FALSE(DoubleMap)
-       TESTSCFLAG_FALSE(DoubleMap)
+ TESTPAGEFLAG_FALSE(TransHuge, transhuge)
+ TESTPAGEFLAG_FALSE(TransCompound, transcompound)
+ TESTPAGEFLAG_FALSE(TransCompoundMap, transcompoundmap)
+ TESTPAGEFLAG_FALSE(TransTail, transtail)
+ PAGEFLAG_FALSE(DoubleMap, double_map)
+       TESTSCFLAG_FALSE(DoubleMap, double_map)
  #endif
  
 +#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
 +/*
 + * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the
 + * compound page.
 + *
 + * This flag is set by hwpoison handler.  Cleared by THP split or free page.
 + */
 +PAGEFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
 +      TESTSCFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
 +#else
 +PAGEFLAG_FALSE(HasHWPoisoned)
 +      TESTSCFLAG_FALSE(HasHWPoisoned)
 +#endif
 +
  /*
   * Check if a page is currently marked HWPoisoned. Note that this check is
   * best effort only and inherently racy: there is no way to synchronize with
@@@ -2424,10 -2425,8 +2425,10 @@@ static void __split_huge_page(struct pa
        }
  
        /* lock lru list/PageCompound, ref frozen by page_ref_freeze */
-       lruvec = lock_page_lruvec(head);
+       lruvec = folio_lruvec_lock(folio);
  
 +      ClearPageHasHWPoisoned(head);
 +
        for (i = nr - 1; i >= 1; i--) {
                __split_huge_page_tail(head, i, lruvec, list);
                /* Some pages can be beyond EOF: drop them from page cache */
diff --cc mm/khugepaged.c
Simple merge
Simple merge
diff --cc mm/memory.c
Simple merge
diff --cc mm/mempolicy.c
Simple merge
diff --cc mm/migrate.c
Simple merge
diff --cc mm/page_alloc.c
Simple merge