Skip to content

RFC Large pages in the page cache

Matthew Wilcox linux-fsdevel linux-mm lkml 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 RFC Latest51 patches 8 repliesIn review
  2. v539 patches 0 repliesSuperseded
  3. v436 patches 22 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v325 patches10 repliesSuperseded
v225 patches42 repliesSuperseded
v1 RFC15 patches28 repliesSuperseded

Changes in v6 from the cover letter

- Improved debug output for large pages (will send to Andrew soon)
- Make compound_nr() more efficient (will send to Andrew soon)
- Renamed hpage_nr_pages() to thp_nr_pages()
- Added thp_head()
- Set the THP_SUPPORT flag in shmfs
- Change zero_user_segments() to call flush_dcache_page() once for the head page instead of once for each subpage. The architectures listed above need to be fixed.
- Fix shmem & truncate to call zero_user_segment() with the head page
- Fix page_is_mergeable() for THPs
- Fix a bug in iomap_iop_set_range_uptodate() where I was assuming that the offset was block-aligned
- Fix a few more places that assume unsigned int is large enough to hold offset/length within a page
- Fix doing writeback of a page after discarding its iop due to a partial truncate
- Convert the iomap write paths more comprehensively. That's now four separate patches

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/51mm: Print head flags in dump_pagemm/debug.c+1 -10 replies
2/51mm: Print the inode number in dump_pagemm/debug.c+6 -50 replies
3/51mm: Print hashed address of struct pagemm/debug.c+5 -50 replies
4/51mm: Move PageDoubleMap bitinclude/linux/page-flags.h+1 -11 reply
5/51mm: Simplify PageDoubleMap with PF_SECOND policyinclude/linux/page-flags.h+10 -301 reply
6/51mm: Store compound_nr as well as compound_orderinclude/linux/mm.h include/linux/mm_types.h mm/page_alloc.c+8 -30 replies
7/51mm: Move page-flags include to top of fileinclude/linux/mm.h+1 -50 replies
8/51mm: Add thp_orderinclude/linux/huge_mm.h+19 -00 replies
9/51mm: Add thp_sizedrivers/nvdimm/btt.c drivers/nvdimm/pmem.c include/linux/huge_mm.h +3 more+18 -110 replies
10/51mm: Replace hpage_nr_pages with thp_nr_pagesinclude/linux/huge_mm.h include/linux/mm_inline.h include/linux/pagemap.h +17 more+62 -590 replies
11/51mm: Add thp_headinclude/linux/huge_mm.h+15 -00 replies
12/51mm: Introduce offset_in_thpinclude/linux/mm.h+1 -00 replies
13/51mm: Support arbitrary THP sizesinclude/linux/huge_mm.h include/linux/mm.h+23 -270 replies
14/51fs: Add a filesystem flag for THPsfs/inode.c include/linux/fs.h include/linux/pagemap.h +1 more+10 -10 replies
15/51fs: Do not update nr_thps for mappings which support THPsinclude/linux/fs.h include/linux/pagemap.h+29 -270 replies
16/51fs: Introduce i_blocks_per_pagefs/iomap/buffered-io.c fs/jfs/jfs_metapage.c fs/xfs/xfs_aops.c +1 more+21 -60 replies
17/51fs: Make page_mkwrite_check_truncate thp-awareinclude/linux/pagemap.h+5 -50 replies
18/51mm: Support THPs in zero_user_segmentsinclude/linux/highmem.h mm/highmem.c+68 -50 replies
19/51mm: Zero the head page, not the tail pagemm/shmem.c mm/truncate.c+14 -00 replies
20/51block: Add bio_for_each_thp_segment_allinclude/linux/bio.h include/linux/bvec.h+36 -01 reply
21/51block: Support THPs in page_is_mergeableblock/bio.c+1 -11 reply
22/51iomap: Support arbitrarily many blocks per pagefs/iomap/buffered-io.c+8 -170 replies
23/51iomap: Support THPs in iomap_adjust_read_rangefs/iomap/buffered-io.c+12 -110 replies
24/51iomap: Support THPs in invalidatepagefs/iomap/buffered-io.c+8 -60 replies
25/51iomap: Support THPs in read pathsfs/iomap/buffered-io.c+16 -50 replies
26/51iomap: Convert iomap_write_end typesfs/iomap/buffered-io.c+12 -190 replies
27/51iomap: Change calling convention for zeroingfs/dax.c fs/iomap/buffered-io.c include/linux/dax.h+22 -270 replies
28/51iomap: Change iomap_write_begin calling conventionfs/iomap/buffered-io.c+34 -290 replies
29/51iomap: Support THPs in write pathsfs/iomap/buffered-io.c+24 -200 replies
30/51iomap: Inline data shouldn't see THPsfs/iomap/buffered-io.c+2 -00 replies
31/51iomap: Handle tail pages in iomap_page_mkwritefs/iomap/buffered-io.c+1 -10 replies
32/51xfs: Support THPsfs/xfs/xfs_aops.c fs/xfs/xfs_super.c+2 -20 replies
33/51mm: Make prep_transhuge_page return its argumentinclude/linux/huge_mm.h mm/huge_memory.c+12 -40 replies
34/51mm: Add __page_cache_alloc_orderinclude/linux/pagemap.h mm/filemap.c+29 -70 replies
35/51mm: Allow THPs to be added to the page cachemm/filemap.c+35 -170 replies
36/51mm: Allow THPs to be removed from the page cachemm/filemap.c+1 -10 replies
37/51mm: Remove page fault assumption of compound page sizemm/memory.c+4 -30 replies
38/51mm: Fix total_mapcount assumption of page sizemm/huge_memory.c+5 -40 replies
39/51mm: Remove assumptions of THP sizemm/huge_memory.c mm/rmap.c+13 -120 replies
40/51mm: Avoid splitting THPsmm/vmscan.c+3 -30 replies
41/51mm: Fix truncation for pages of arbitrary sizemm/truncate.c+3 -30 replies
42/51mm: Handle truncates that split THPsmm/internal.h mm/shmem.c mm/truncate.c+59 -300 replies
43/51mm: Support storing shadow entries for THPsmm/filemap.c+11 -60 replies
44/51mm: Support retrieving tail pages from the page cachemm/filemap.c+1 -10 replies
45/51mm: Support tail pages in wait_for_stable_pagemm/page-writeback.c+1 -00 replies
46/51mm: Add DEFINE_READAHEADinclude/linux/pagemap.h mm/readahead.c+8 -50 replies
47/51mm: Make page_cache_readahead_unbounded take a readahead_controlfs/ext4/verity.c fs/f2fs/verity.c include/linux/pagemap.h +1 more+18 -210 replies
48/51mm: Make __do_page_cache_readahead take a readahead_controlmm/internal.h mm/readahead.c+19 -180 replies
49/51mm: Allow PageReadahead to be set on head pagesinclude/linux/page-flags.h mm/filemap.c+9 -90 replies
50/51mm: Add THP readaheadmm/readahead.c+87 -60 replies
51/51mm: Align THP mappings for non-DAXmm/huge_memory.c+1 -40 replies

Reviews trailers per patch

6 of 51 patches have a Reviewed-by or Acked-by.

PatchChristoph HellwigKirill A. ShutemovDavid HildenbrandZi Yan
1/51
2/51
3/51
4/51R-b
5/51
6/51
7/51
8/51
9/51
10/51
11/51
12/51R-b
13/51
14/51
15/51
16/51R-b
17/51
18/51
19/51
20/51
21/51
22/51
23/51
24/51
25/51
26/51
27/51
28/51
29/51
30/51R-b
31/51
32/51
33/51A-b
34/51A-b
35/51
36/51
37/51
38/51
39/51
40/51
41/51
42/51
43/51
44/51
45/51
46/51
47/51
48/51
49/51
50/51
51/51

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v6 thread

Cover letter [RFC v6 00/51] Large pages in the page cache

From: "Matthew Wilcox (Oracle)" <[email protected]>

Another fortnight, another dump of my current large pages work. I've squished a lot of bugs this time. xfstests is much happier now, running for 1631 seconds and getting as far as generic/086. This patchset is getting a little big, so I'm going to try to get some bits of it upstream soon (the bits that make sense regardless of whether the rest of this is merged).

It's now based on linus' master (6f630784cc0d), and you can get it from
http://git.infradead.org/users/willy/linux-dax.git/shortlog/refs/heads/xarray-pagecache
if you'd rather see it there (this branch is force-pushed frequently)

The primary idea here is that a large part of the overhead in dealing with individual pages is that there's just so darned many of them. We would be better off dealing with fewer, larger pages, even if they don't get to be the size necessary for the CPU to use a larger TLB entry.

The approach taken is to make THPs support arbitrary power-of-two sizes (instead of just PMDs). There's probably some tuning to be done to decide what sizes are worth using, but we're a fair way from doing performance work with this patchset yet.

TODO:
- Fix arc/arm/arm64/mips/powerpc/space flush_dcache_page() to support THPs natively
- Actually create large pages for sufficiently large writes
- Copy in larger chunks for write() in iomap
- More bug fixing

v6:
- Improved debug output for large pages (will send to Andrew soon)
- Make compound_nr() more efficient (will send to Andrew soon)
- Renamed hpage_nr_pages() to thp_nr_pages()
- Added thp_head()
- Set the THP_SUPPORT flag in shmfs
- Change zero_user_segments() to call flush_dcache_page() once for the head page instead of once for each subpage. The architectures listed above need to be fixed.
- Fix shmem & truncate to call zero_user_segment() with the head page
- Fix page_is_mergeable() for THPs
- Fix a bug in iomap_iop_set_range_uptodate() where I was assuming that the offset was block-aligned
- Fix a few more places that assume unsigned int is large enough to hold offset/length within a page
- Fix doing writeback of a page after discarding its iop due to a partial truncate
- Convert the iomap write paths more comprehensively. That's now four separate patches
v5:
- Add a mapping AS_LARGE_PAGES flag to reduce the levels of indirection (Dave Chinner)
- Change iomap_invalidate_page() to handle subpages of a THP being punched
- Ensure we don't call page_cache_async_readahead() with a tail page
- Revert to Bill's original patch for thp_get_unmapped_area() to allow for hardware page sizes other than PMD to be supported more easily
- Remove a few more HPAGE_PMD_NR
- Move shmem_punch_compound() to truncate.c and rename it to punch_thp()
- Add support for page_private to punch_thp()

v4:
- Fix thp_size typo
- Fix the iomap page_mkwrite() path to operate on the head page, even though the vm_fault has a pointer to the tail page
- Fix iomap_finish_ioend() to use bio_for_each_thp_segment_all()
- Rework PageDoubleMap (see first two patches for details)
- Fix page_cache_delete() to handle shadow entries being stored to a THP
- Fix the assertion in pagecache_get_page() to handle tail pages
- Change PageReadahead from NO_COMPOUND to ONLY_HEAD
- Handle PageReadahead being set on head pages
- Handle total_mapcount correctly (Kirill)
- Pull the FS_LARGE_PAGES check out into mapping_large_pages()
- Fix page size assumption in truncate_cleanup_page()
- Avoid splitting large pages unnecessarily on truncate
- Disable the page cache truncation introduced as part of the read-only THP patch set
- Call compound_head() in iomap buffered write paths -- we retrieve a (potentially) tail page from the page cache and need to use that for flush_dcache_page(), but we expect to operate on a head page in most of the iomap code

Kirill A. Shutemov (1):
mm: Fix total_mapcount assumption of page size

Matthew Wilcox (Oracle) (49):
mm: Print head flags in dump_page
mm: Print the inode number in dump_page
mm: Print hashed address of struct page
mm: Move PageDoubleMap bit
mm: Simplify PageDoubleMap with PF_SECOND policy
mm: Store compound_nr as well as compound_order
mm: Move page-flags include to top of file
mm: Add thp_order
mm: Add thp_size
mm: Replace hpage_nr_pages with thp_nr_pages
mm: Add thp_head
mm: Introduce offset_in_thp
mm: Support arbitrary THP sizes
fs: Add a filesystem flag for THPs
fs: Do not update nr_thps for mappings which support THPs
fs: Introduce i_blocks_per_page
fs: Make page_mkwrite_check_truncate thp-aware
mm: Support THPs in zero_user_segments
mm: Zero the head page, not the tail page
block: Add bio_for_each_thp_segment_all
block: Support THPs in page_is_mergeable
iomap: Support arbitrarily many blocks per page
iomap: Support THPs in iomap_adjust_read_range
iomap: Support THPs in invalidatepage
iomap: Support THPs in read paths
iomap: Convert iomap_write_end types
iomap: Change calling convention for zeroing
iomap: Change iomap_write_begin calling convention
iomap: Support THPs in write paths
iomap: Inline data shouldn't see THPs
iomap: Handle tail pages in iomap_page_mkwrite
xfs: Support THPs
mm: Make prep_transhuge_page return its argument
mm: Add __page_cache_alloc_order
mm: Allow THPs to be added to the page cache
mm: Allow THPs to be removed from the page cache
mm: Remove page fault assumption of compound page size
mm: Remove assumptions of THP size
mm: Avoid splitting THPs
mm: Fix truncation for pages of arbitrary size
mm: Handle truncates that split THPs
mm: Support storing shadow entries for THPs
mm: Support retrieving tail pages from the page cache
mm: Support tail pages in wait_for_stable_page
mm: Add DEFINE_READAHEAD
mm: Make page_cache_readahead_unbounded take a readahead_control
mm: Make __do_page_cache_readahead take a readahead_control
mm: Allow PageReadahead to be set on head pages
mm: Add THP readahead

William Kucharski (1):
mm: Align THP mappings for non-DAX

 block/bio.c                |   2 +-
 drivers/nvdimm/btt.c       |   4 +-
 drivers/nvdimm/pmem.c      |   6 +-
 fs/dax.c                   |  13 +-
 fs/ext4/verity.c           |   4 +-
 fs/f2fs/verity.c           |   4 +-
 fs/inode.c                 |   2 +
 fs/iomap/buffered-io.c     | 250 +++++++++++++++++++------------------
 fs/jfs/jfs_metapage.c      |   2 +-
 fs/xfs/xfs_aops.c          |   4 +-
 fs/xfs/xfs_super.c         |   2 +-
 include/linux/bio.h        |  13 ++
 include/linux/bvec.h       |  23 ++++
 include/linux/dax.h        |   3 +-
 include/linux/fs.h         |  28 +----
 include/linux/highmem.h    |  11 +-
 include/linux/huge_mm.h    |  65 ++++++++--
 include/linux/mm.h         |  46 +++----
 include/linux/mm_inline.h  |   6 +-
 include/linux/mm_types.h   |   1 +
 include/linux/page-flags.h |  46 ++-----
 include/linux/pagemap.h    | 102 ++++++++++++---
 mm/compaction.c            |   2 +-
 mm/debug.c                 |  23 ++--
 mm/filemap.c               | 101 +++++++++------
 mm/gup.c                   |   2 +-
 mm/highmem.c               |  62 ++++++++-
 mm/huge_memory.c           |  38 +++---
 mm/hugetlb.c               |   2 +-
 mm/internal.h              |  17 +--
 mm/memcontrol.c            |  10 +-
 mm/memory.c                |   7 +-
 mm/memory_hotplug.c        |   7 +-
 mm/mempolicy.c             |   2 +-
 mm/migrate.c               |  16 +--
 mm/mlock.c                 |   9 +-
 mm/page-writeback.c        |   1 +
 mm/page_alloc.c            |   5 +-
 mm/page_io.c               |   4 +-
 mm/page_vma_mapped.c       |   6 +-
 mm/readahead.c             | 145 ++++++++++++++++-----
 mm/rmap.c                  |  18 +--
 mm/shmem.c                 |  39 ++----
 mm/swap.c                  |  16 +--
 mm/swap_state.c            |   6 +-
 mm/swapfile.c              |   2 +-
 mm/truncate.c              |  70 ++++++++++-
 mm/vmscan.c                |  12 +-
 48 files changed, 795 insertions(+), 464 deletions(-)
Signature · 1 line
2.26.2