]> www.infradead.org Git - users/willy/pagecache.git/log
users/willy/pagecache.git
3 years agomm/swap: Add folio_throttle_swaprate folio-tested
Matthew Wilcox (Oracle) [Thu, 6 May 2021 12:42:34 +0000 (08:42 -0400)]
mm/swap: Add folio_throttle_swaprate

The only use of the page argument to cgroup_throttle_swaprate() is to
get the node ID, and this will be the same for all pages in the folio,
so there's no need to convert the page to a folio before calling it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agofs: Dump information about bad inodes
Matthew Wilcox (Oracle) [Wed, 26 May 2021 17:05:37 +0000 (13:05 -0400)]
fs: Dump information about bad inodes

If nrpages is still set, call dump_mapping to tell us what kind of inode
is causing problems.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm,fs: Split dump_mapping() out from dump_page()
Matthew Wilcox (Oracle) [Wed, 26 May 2021 17:03:12 +0000 (13:03 -0400)]
mm,fs: Split dump_mapping() out from dump_page()

dump_mapping() is a big chunk of dump_page(), and it'd be handy to be
able to call it when we don't have a struct page.  Split it out and move
it to fs/inode.c.  Take the opportunity to simplify some of the debug
messages a little.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/writeback: Improve __folio_mark_dirty() comment
Matthew Wilcox (Oracle) [Sun, 20 Dec 2020 11:44:51 +0000 (06:44 -0500)]
mm/writeback: Improve __folio_mark_dirty() comment

Add some notes about how this function needs to be called.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoselftests/vm/transhuge-stress: Support file-backed THPs
Matthew Wilcox (Oracle) [Sun, 25 Jul 2021 03:43:58 +0000 (23:43 -0400)]
selftests/vm/transhuge-stress: Support file-backed THPs

Add a -f <filename> option to test THPs on files

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Support VM_HUGEPAGE for file mappings
Matthew Wilcox (Oracle) [Sun, 25 Jul 2021 03:37:13 +0000 (23:37 -0400)]
mm/filemap: Support VM_HUGEPAGE for file mappings

If the VM_HUGEPAGE flag is set, attempt to allocate PMD-sized THPs
during readahead, even if we have no history of readahead being
successful.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/readahead: Switch to page_cache_ra_order
Matthew Wilcox (Oracle) [Sun, 25 Jul 2021 03:26:14 +0000 (23:26 -0400)]
mm/readahead: Switch to page_cache_ra_order

do_page_cache_ra() was being exposed for the benefit of
do_sync_mmap_readahead().  Switch it over to page_cache_ra_order()
partly because it's a better interface but mostly for the benefit of
the next patch.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/readahead: Align THP mappings for non-DAX
William Kucharski [Sun, 22 Sep 2019 12:43:15 +0000 (08:43 -0400)]
mm/readahead: Align THP mappings for non-DAX

When we have the opportunity to use transparent huge pages to map a
file, we want to follow the same rules as DAX.

Signed-off-by: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/readahead: Add multi-page folio readahead
Matthew Wilcox (Oracle) [Wed, 5 Feb 2020 16:27:01 +0000 (11:27 -0500)]
mm/readahead: Add multi-page folio readahead

If the filesystem supports multi-page folios, allocate larger pages in
the readahead code when it seems worth doing.  The heuristic for choosing
larger page sizes will surely need some tuning, but this aggressive
ramp-up has been good for testing.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/vmscan: Optimise shrink_page_list for smaller THPs
Matthew Wilcox (Oracle) [Sat, 15 Aug 2020 23:28:51 +0000 (19:28 -0400)]
mm/vmscan: Optimise shrink_page_list for smaller THPs

A THP which is smaller than a PMD does not need to do the extra work
in try_to_unmap() of trying to split a PMD entry.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Allow multi-page folios to be added to the page cache
Matthew Wilcox (Oracle) [Thu, 5 Sep 2019 18:03:12 +0000 (14:03 -0400)]
mm/filemap: Allow multi-page folios to be added to the page cache

We return -EEXIST if there are any non-shadow entries in the page
cache in the range covered by the folio.  If there are multiple
shadow entries in the range, we set *shadowp to one of them (currently
the one at the highest index).  If that turns out to be the wrong
answer, we can implement something more complex.  This is mostly
modelled after the equivalent function in the shmem code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm: Support arbitrary THP sizes
Matthew Wilcox (Oracle) [Sat, 30 May 2020 00:54:38 +0000 (20:54 -0400)]
mm: Support arbitrary THP sizes

Use the compound size of the page instead of assuming PTE or PMD size.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm: Fix READ_ONLY_THP warning
Matthew Wilcox (Oracle) [Sat, 10 Oct 2020 15:47:55 +0000 (11:47 -0400)]
mm: Fix READ_ONLY_THP warning

These counters only exist if CONFIG_READ_ONLY_THP_FOR_FS is defined,
but we do not need to warn if the filesystem natively supports multi-page
folios.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/vmscan: Free non-shmem THPs without splitting them
Matthew Wilcox (Oracle) [Wed, 30 Sep 2020 20:15:46 +0000 (16:15 -0400)]
mm/vmscan: Free non-shmem THPs without splitting them

We have to allocate memory in order to split a file-backed page,
so it's not a good idea to split them.  It also doesn't work for XFS
because pages have an extra reference count from page_has_private() and
split_huge_page() expects that reference to have already been removed.
Unfortunately, we still have to split shmem THPs because we can't handle
swapping out an entire THP yet.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/truncate: Convert invalidate_inode_pages2_range to folios
Matthew Wilcox (Oracle) [Thu, 20 May 2021 12:17:44 +0000 (08:17 -0400)]
mm/truncate: Convert invalidate_inode_pages2_range to folios

If we're going to unmap a folio, we have to be sure to unmap the entire
folio, not just the part of it which lies after the search index.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/truncate: Add invalidate_complete_folio2()
Matthew Wilcox (Oracle) [Wed, 28 Jul 2021 19:52:34 +0000 (15:52 -0400)]
mm/truncate: Add invalidate_complete_folio2()

Convert invalidate_complete_page2() to invalidate_complete_folio2().
Use filemap_free_folio() to free the page instead of calling ->freepage
manually.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Add filemap_release_folio()
Matthew Wilcox (Oracle) [Wed, 28 Jul 2021 19:14:48 +0000 (15:14 -0400)]
mm/filemap: Add filemap_release_folio()

Reimplement try_to_release_page() as a wrapper around
filemap_release_folio().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm: Use multi-index entries in the page cache
Matthew Wilcox (Oracle) [Sun, 28 Jun 2020 02:19:08 +0000 (22:19 -0400)]
mm: Use multi-index entries in the page cache

We currently store order-N THPs as 2^N consecutive entries.  While this
consumes rather more memory than necessary, it also turns out to be buggy.
A writeback operation which starts in the middle of a dirty THP will not
notice as the dirty bit is only set on the head index.  With multi-index
entries, the dirty bit will be found no matter where in the THP the
iteration starts.

This does end up simplifying the page cache slightly, although not as
much as I had hoped.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoXArray: Add xas_advance()
Matthew Wilcox (Oracle) [Fri, 27 Aug 2021 11:21:49 +0000 (07:21 -0400)]
XArray: Add xas_advance()

Add a new helper function to help iterate over multi-index entries.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Return only head pages from find_get_entries
Matthew Wilcox (Oracle) [Wed, 2 Sep 2020 03:17:50 +0000 (23:17 -0400)]
mm/filemap: Return only head pages from find_get_entries

All callers now expect head (and base) pages, and can handle multiple
head pages in a single batch, so make find_get_entries() behave that way.
Also take the opportunity to make it use the pagevec infrastructure
instead of open-coding how pvecs behave.  This has the side-effect of
being able to append to a pagevec with existing contents, although we
don't make use of that functionality anywhere yet.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
3 years agomm/truncate,shmem: Handle truncates that split THPs
Matthew Wilcox (Oracle) [Wed, 27 May 2020 21:59:22 +0000 (17:59 -0400)]
mm/truncate,shmem: Handle truncates that split THPs

Handle THP splitting in the parts of the truncation functions which
already handle partial pages.  Factor all that code out into a new
function called truncate_inode_partial_page().

We lose the easy 'bail out' path if a truncate or hole punch is entirely
within a single page.  We can add some more complex logic to restore
the optimisation if it proves to be worthwhile.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
3 years agofs: Rename AS_THP_SUPPORT and mapping_thp_support
Matthew Wilcox (Oracle) [Sun, 29 Aug 2021 10:28:19 +0000 (06:28 -0400)]
fs: Rename AS_THP_SUPPORT and mapping_thp_support

These are now indicators of multi-page folio support, not THP support.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agofs: Convert vfs_dedupe_file_range_compare to folios
Matthew Wilcox (Oracle) [Mon, 14 Dec 2020 12:57:07 +0000 (07:57 -0500)]
fs: Convert vfs_dedupe_file_range_compare to folios

We still only operate on a single page of data at a time due to using
kmap().  A more complex implementation would work on each page in a folio,
but it's not clear that such a complex implementation would be worthwhile.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Use a folio in filemap_map_pages
Matthew Wilcox (Oracle) [Sat, 13 Mar 2021 04:46:45 +0000 (23:46 -0500)]
mm/filemap: Use a folio in filemap_map_pages

Saves 61 bytes due to fewer calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Use folios in next_uptodate_page
Matthew Wilcox (Oracle) [Sat, 13 Mar 2021 04:33:43 +0000 (23:33 -0500)]
mm/filemap: Use folios in next_uptodate_page

This saves 105 bytes of text.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Remove PageHWPoison check from next_uptodate_page()
Matthew Wilcox (Oracle) [Tue, 25 May 2021 14:11:25 +0000 (10:11 -0400)]
mm/filemap: Remove PageHWPoison check from next_uptodate_page()

Pages are individually marked as suffering from hardware poisoning.
Checking that the head page is not hardware poisoned doesn't make
sense; we might be after a subpage.  We check each page individually
before we use it, so this was an optimisation gone wrong.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert page_cache_delete_batch to folios
Matthew Wilcox (Oracle) [Sat, 13 Mar 2021 04:13:46 +0000 (23:13 -0500)]
mm/filemap: Convert page_cache_delete_batch to folios

Saves one call to compound_head() and reduces text size by 15 bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert filemap_get_pages to use folios
Matthew Wilcox (Oracle) [Wed, 10 Mar 2021 19:01:22 +0000 (14:01 -0500)]
mm/filemap: Convert filemap_get_pages to use folios

This saves a few calls to compound_head(), including one in
filemap_update_page().  Shrinks the kernel by 78 bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Add read_cache_folio and read_mapping_folio
Matthew Wilcox (Oracle) [Wed, 16 Dec 2020 16:45:30 +0000 (11:45 -0500)]
mm/filemap: Add read_cache_folio and read_mapping_folio

Reimplement read_cache_page() as a wrapper around read_cache_folio().
Saves over 400 bytes of text from do_read_cache_folio() which more
thn makes up for the extra 100 bytes of text added to the various
wrapper functions.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert filemap_fault to folio
Matthew Wilcox (Oracle) [Wed, 10 Mar 2021 15:46:41 +0000 (10:46 -0500)]
mm/filemap: Convert filemap_fault to folio

Instead of converting back-and-forth between the actual page and
the head page, just convert once at the end of the function where we
set the vmf->page.  Saves 241 bytes of text, or 15% of the size of
filemap_fault().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert do_async_mmap_readahead to take a folio
Matthew Wilcox (Oracle) [Thu, 29 Jul 2021 18:57:01 +0000 (14:57 -0400)]
mm/filemap: Convert do_async_mmap_readahead to take a folio

Call page_cache_async_ra() directly instead of indirecting through
page_cache_async_readahead().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/readahead: Convert page_cache_async_ra() to take a folio
Matthew Wilcox (Oracle) [Thu, 27 May 2021 16:30:54 +0000 (12:30 -0400)]
mm/readahead: Convert page_cache_async_ra() to take a folio

Using the folio here avoids checking whether it's a tail page.
This patch mostly just enables some of the following patches.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert filemap_range_uptodate to folios
Matthew Wilcox (Oracle) [Wed, 10 Mar 2021 16:04:19 +0000 (11:04 -0500)]
mm/filemap: Convert filemap_range_uptodate to folios

The only caller was already passing a head page, so this simply avoids
a call to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert filemap_create_page to folio
Matthew Wilcox (Oracle) [Wed, 10 Mar 2021 15:34:00 +0000 (10:34 -0500)]
mm/filemap: Convert filemap_create_page to folio

This is all internal to filemap and saves 100 bytes of text.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert filemap_read_page to take a folio
Matthew Wilcox (Oracle) [Wed, 10 Mar 2021 15:19:30 +0000 (10:19 -0500)]
mm/filemap: Convert filemap_read_page to take a folio

One of the callers already had a folio; the other two grow by a few
bytes, but filemap_read_page() shrinks by 50 bytes for a net reduction
of 27 bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert find_get_pages_contig to folios
Matthew Wilcox (Oracle) [Sat, 6 Mar 2021 21:38:38 +0000 (16:38 -0500)]
mm/filemap: Convert find_get_pages_contig to folios

None of the callers of find_get_pages_contig() want tail pages.  They all
use order-0 pages today, but if they were converted, they'd want folios.
So just remove the call to find_subpage() instead of replacing it with
folio_page().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert filemap_get_read_batch to use folios
Matthew Wilcox (Oracle) [Fri, 5 Mar 2021 15:29:41 +0000 (10:29 -0500)]
mm/filemap: Convert filemap_get_read_batch to use folios

The page cache only stores folios, never tail pages.  Saves 29 bytes
due to removing calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert find_get_entry to return a folio
Matthew Wilcox (Oracle) [Thu, 17 Dec 2020 05:12:26 +0000 (00:12 -0500)]
mm/filemap: Convert find_get_entry to return a folio

Convert callers to cope.  Saves 580 bytes of kernel text; all five
callers are reduced in size.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Add filemap_remove_folio and __filemap_remove_folio
Matthew Wilcox (Oracle) [Sun, 9 May 2021 13:33:42 +0000 (09:33 -0400)]
mm/filemap: Add filemap_remove_folio and __filemap_remove_folio

Reimplement __delete_from_page_cache() as a wrapper around
__filemap_remove_folio() and delete_from_page_cache() as a wrapper
around filemap_remove_folio().  Remove the EXPORT_SYMBOL as
delete_from_page_cache() was not used by any in-tree modules.
Convert page_cache_free_page() into filemap_free_folio().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert tracing of page cache operations to folio
Matthew Wilcox (Oracle) [Fri, 23 Jul 2021 13:29:46 +0000 (09:29 -0400)]
mm/filemap: Convert tracing of page cache operations to folio

Pass the folio instead of a page.  The page was already implicitly a
folio as it accessed page->mapping directly.  Add the order of the folio
to the tracepoint, as this is important information.  Also drop printing
the address of the struct page as the pfn provides better information
than the struct page address.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert unaccount_page_cache_page to filemap_unaccount_folio
Matthew Wilcox (Oracle) [Sun, 9 May 2021 00:04:05 +0000 (20:04 -0400)]
mm/filemap: Convert unaccount_page_cache_page to filemap_unaccount_folio

Use folios throughout filemap_unaccount_folio(), except for the bug
handling path which would need to use total_mapcount(), which is currently
only defined for builds with THP enabled.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Convert page_cache_delete to take a folio
Matthew Wilcox (Oracle) [Sat, 8 May 2021 04:35:49 +0000 (00:35 -0400)]
mm/filemap: Convert page_cache_delete to take a folio

It was already assuming a head page, so this is a straightforward
conversion.  Convert the one caller to call page_folio(), even though
it must currently be passing in a head page.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/filemap: Add folio_put_wait_locked()
Matthew Wilcox (Oracle) [Tue, 17 Aug 2021 03:36:31 +0000 (23:36 -0400)]
mm/filemap: Add folio_put_wait_locked()

Convert all three callers of put_and_wait_on_page_locked() to
folio_put_wait_locked().  This shrinks the kernel overall by 19 bytes.
filemap_update_page() shrinks by 19 bytes while __migration_entry_wait()
is unchanged.  folio_put_wait_locked() is 14 bytes smaller than
put_and_wait_on_page_locked(), but pmd_migration_entry_wait() grows by
14 bytes.  It removes the assumption from pmd_migration_entry_wait()
that pages cannot be larger than a PMD (which is true today, but
may be interesting to explore in the future).

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/memcg: Convert mem_cgroup_css_from_page to folio_memcg_css
Matthew Wilcox (Oracle) [Mon, 16 Aug 2021 16:03:22 +0000 (12:03 -0400)]
mm/memcg: Convert mem_cgroup_css_from_page to folio_memcg_css

Move the hidden page_folio() call from inside mem_cgroup_css_from_page()
to the callers.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomips: Rename PMD_ORDER to PMD_TABLE_ORDER
Matthew Wilcox (Oracle) [Wed, 30 Jun 2021 12:43:38 +0000 (08:43 -0400)]
mips: Rename PMD_ORDER to PMD_TABLE_ORDER

This is the order of the page table allocation, not the order of a PMD.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoarm: Rename PMD_ORDER to PMD_BITS
Matthew Wilcox (Oracle) [Wed, 30 Jun 2021 12:43:38 +0000 (08:43 -0400)]
arm: Rename PMD_ORDER to PMD_BITS

This is the number of bits used by a PMD entry, not the order of a PMD.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoxfs: Support multi-page folios
Matthew Wilcox (Oracle) [Wed, 19 May 2021 22:38:43 +0000 (18:38 -0400)]
xfs: Support multi-page folios

Now that iomap has been converted, XFS is multi-page folio safe.
Indicate to the VFS that it can now create multi-page folios for XFS.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Support multi-page folios in invalidatepage
Matthew Wilcox (Oracle) [Wed, 13 Jan 2021 15:48:49 +0000 (10:48 -0500)]
iomap: Support multi-page folios in invalidatepage

If we're punching a hole in a multi-page folio, we need to remove the
per-folio iomap data as the folio is about to be split and each page will
need its own.  If a dirty folio is only partially-uptodate, the iomap
data contains the information about which blocks cannot be written back,
so assert that a dirty folio is fully uptodate.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Convert iomap_migrate_page to use folios
Matthew Wilcox (Oracle) [Fri, 7 May 2021 19:08:09 +0000 (15:08 -0400)]
iomap: Convert iomap_migrate_page to use folios

The arguments are still pages for now, but we can use folios internally
and cut out a lot of calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Convert iomap_add_to_ioend to take a folio
Matthew Wilcox (Oracle) [Sun, 2 May 2021 19:40:41 +0000 (15:40 -0400)]
iomap: Convert iomap_add_to_ioend to take a folio

We still iterate one block at a time, but now we call compound_head()
less often.  Rename file_offset to pos to fit the rest of the file.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap,xfs: Convert ->discard_page to ->discard_folio
Matthew Wilcox (Oracle) [Fri, 30 Jul 2021 13:56:05 +0000 (09:56 -0400)]
iomap,xfs: Convert ->discard_page to ->discard_folio

XFS has the only implementation of ->discard_page today, so convert it
to use folios in the same patch as converting the API.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Convert iomap_write_end_inline to take a folio
Matthew Wilcox (Oracle) [Sun, 2 May 2021 15:44:44 +0000 (11:44 -0400)]
iomap: Convert iomap_write_end_inline to take a folio

This conversion is only safe because iomap only supports writes to inline
data which starts at the beginning of the file.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Convert iomap_write_begin and iomap_write_end to folios
Matthew Wilcox (Oracle) [Sun, 2 May 2021 15:33:08 +0000 (11:33 -0400)]
iomap: Convert iomap_write_begin and iomap_write_end to folios

These functions still only work in PAGE_SIZE chunks, but there are
fewer conversions from tail to head pages as a result of this patch.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Convert iomap_page_mkwrite to use a folio
Matthew Wilcox (Oracle) [Thu, 29 Apr 2021 02:32:02 +0000 (22:32 -0400)]
iomap: Convert iomap_page_mkwrite to use a folio

If we write to any page in a folio, we have to mark the entire
folio as dirty, and potentially COW the entire folio, because it'll
all get written back as one unit.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Convert readahead and readpage to use a folio
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 13:39:51 +0000 (09:39 -0400)]
iomap: Convert readahead and readpage to use a folio

Handle folios of arbitrary size instead of working in PAGE_SIZE units.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Convert iomap_read_inline_data to take a folio
Matthew Wilcox (Oracle) [Sat, 24 Jul 2021 03:24:50 +0000 (23:24 -0400)]
iomap: Convert iomap_read_inline_data to take a folio

We still only support up to a single page of inline data (at least,
per call to iomap_read_inline_data()), but it can now be written into
the middle of a folio in case we decide to allocate a 16KiB page for
a file that's 8.1KiB in size.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Use folio offsets instead of page offsets
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 12:20:48 +0000 (08:20 -0400)]
iomap: Use folio offsets instead of page offsets

Pass a folio around instead of the page, and make sure the offset
is relative to the start of the folio instead of the start of a page.
Also use size_t for offset & length to make it clear that these are byte
counts, and to support >2GB folios in the future.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Convert bio completions to use folios
Matthew Wilcox (Oracle) [Fri, 1 Jan 2021 21:53:26 +0000 (16:53 -0500)]
iomap: Convert bio completions to use folios

Use bio_for_each_folio() to iterate over each folio in the bio
instead of iterating over each page.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Pass the iomap_page into iomap_set_range_uptodate
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 12:16:50 +0000 (08:16 -0400)]
iomap: Pass the iomap_page into iomap_set_range_uptodate

All but one caller already has the iomap_page, so we can avoid getting
it again.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Add iomap_invalidate_folio
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 11:51:36 +0000 (07:51 -0400)]
iomap: Add iomap_invalidate_folio

Keep iomap_invalidatepage around as a wrapper for use in address_space
operations.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Convert iomap_releasepage to use a folio
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 11:51:36 +0000 (07:51 -0400)]
iomap: Convert iomap_releasepage to use a folio

This is an address_space operation, so its argument must remain as a
struct page, but we can use a folio internally.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoiomap: Convert iomap_page_release to take a folio
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 03:22:22 +0000 (23:22 -0400)]
iomap: Convert iomap_page_release to take a folio

iomap_page_release() was also assuming that it was being passed a
head page.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
3 years agoiomap: Convert iomap_page_create to take a folio
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 03:12:52 +0000 (23:12 -0400)]
iomap: Convert iomap_page_create to take a folio

This function already assumed it was being passed a head page, so
just formalise that.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoiomap: Convert to_iomap_page to take a folio
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 02:56:17 +0000 (22:56 -0400)]
iomap: Convert to_iomap_page to take a folio

The big comment about only using a head page can go away now that
it takes a folio argument.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 years agoblock: Add bio_for_each_folio_all()
Matthew Wilcox (Oracle) [Mon, 4 Jan 2021 15:58:17 +0000 (10:58 -0500)]
block: Add bio_for_each_folio_all()

Allow callers to iterate over each folio instead of each page.  The
bio need not have been constructed using folios originally.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoblock: Add bio_add_folio()
Matthew Wilcox (Oracle) [Thu, 8 Apr 2021 05:33:45 +0000 (01:33 -0400)]
block: Add bio_add_folio()

This is a thin wrapper around bio_add_page().  The main advantage here
is the documentation that stupidly large folios are not supported.
It's not currently possible to allocate stupidly large folios, but if
it ever becomes possible, this function will fail gracefully instead of
doing I/O to the wrong bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agofs: Remove FS_THP_SUPPORT
Matthew Wilcox (Oracle) [Sun, 29 Aug 2021 10:07:03 +0000 (06:07 -0400)]
fs: Remove FS_THP_SUPPORT

Instead of setting a bit in the fs_flags to set a bit in the
address_space, set the bit in the address_space directly.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agoremove vm_bug_on
Matthew Wilcox (Oracle) [Thu, 19 Aug 2021 18:24:53 +0000 (14:24 -0400)]
remove vm_bug_on

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
3 years agomm/writeback: Add folio_write_one
Matthew Wilcox (Oracle) [Tue, 9 Mar 2021 18:48:03 +0000 (13:48 -0500)]
mm/writeback: Add folio_write_one

Transform write_one_page() into folio_write_one() and add a compatibility
wrapper.  Also move the declaration to pagemap.h as this is page cache
functionality that doesn't need to be used by the rest of the kernel.

Saves 58 bytes of kernel text.  While folio_write_one() is 101 bytes
smaller than write_one_page(), the inlined call to page_folio() expands
each caller.  There are fewer than ten callers so it doesn't seem worth
putting a wrapper in the core.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
3 years agomm/filemap: Add FGP_STABLE
Matthew Wilcox (Oracle) [Thu, 24 Dec 2020 17:55:56 +0000 (12:55 -0500)]
mm/filemap: Add FGP_STABLE

Allow filemap_get_folio() to wait for writeback to complete (if the
filesystem wants that behaviour).  This is the folio equivalent of
grab_cache_page_write_begin(), which is moved into the folio-compat
file as a reminder to migrate all the code using it.  This paves the
way for getting rid of AOP_FLAG_NOFS once grab_cache_page_write_begin()
is removed.

Kernel grows by 11 bytes.  filemap_get_folio() grows by 33 bytes but
grab_cache_page_write_begin() shrinks by 22 bytes to make up for it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/filemap: Add filemap_get_folio
Matthew Wilcox (Oracle) [Mon, 8 Mar 2021 16:45:35 +0000 (11:45 -0500)]
mm/filemap: Add filemap_get_folio

filemap_get_folio() is a replacement for find_get_page().
Turn pagecache_get_page() into a wrapper around __filemap_get_folio().
Remove find_lock_head() as this use case is now covered by
filemap_get_folio().

Reduces overall kernel size by 209 bytes.  __filemap_get_folio() is
316 bytes shorter than pagecache_get_page() was, but the new
pagecache_get_page() wrapper is 99 bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/filemap: Convert mapping_get_entry to return a folio
Matthew Wilcox (Oracle) [Wed, 16 Dec 2020 04:22:38 +0000 (23:22 -0500)]
mm/filemap: Convert mapping_get_entry to return a folio

The pagecache only contains folios, so indicate that this is definitely
not a tail page.  Shrinks mapping_get_entry() by 56 bytes, but grows
pagecache_get_page() by 21 bytes as gcc makes slightly different hot/cold
code decisions.  A net reduction of 35 bytes of text.

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>
3 years agomm/filemap: Add filemap_add_folio()
Matthew Wilcox (Oracle) [Tue, 8 Dec 2020 13:56:28 +0000 (08:56 -0500)]
mm/filemap: Add filemap_add_folio()

Convert __add_to_page_cache_locked() into __filemap_add_folio().
Add an assertion to it that (for !hugetlbfs), the folio is naturally
aligned within the file.  Move the prototype from mm.h to pagemap.h.
Convert add_to_page_cache_lru() into filemap_add_folio().  Add a
compatibility wrapper for unconverted callers.

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>
3 years agomm/filemap: Add filemap_alloc_folio
Matthew Wilcox (Oracle) [Wed, 16 Dec 2020 04:11:07 +0000 (23:11 -0500)]
mm/filemap: Add filemap_alloc_folio

Reimplement __page_cache_alloc as a wrapper around filemap_alloc_folio
to allow filesystems to be converted at our leisure.  Increases
kernel text size by 133 bytes, mostly in cachefiles_read_backing_file().
pagecache_get_page() shrinks by 32 bytes, though.

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>
3 years agomm/page_alloc: Add folio allocation functions
Matthew Wilcox (Oracle) [Wed, 16 Dec 2020 03:55:54 +0000 (22:55 -0500)]
mm/page_alloc: Add folio allocation functions

The __folio_alloc(), __folio_alloc_node() and folio_alloc() functions
are mostly for type safety, but they also ensure that the page allocator
allocates a compound page and initialises the deferred list if the page
is large enough to have one.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/lru: Add folio_add_lru()
Matthew Wilcox (Oracle) [Thu, 29 Apr 2021 15:09:31 +0000 (11:09 -0400)]
mm/lru: Add folio_add_lru()

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>
3 years agomm/lru: Convert __pagevec_lru_add_fn to take a folio
Matthew Wilcox (Oracle) [Fri, 14 May 2021 19:08:29 +0000 (15:08 -0400)]
mm/lru: Convert __pagevec_lru_add_fn to take a folio

This saves five calls to compound_head(), totalling 60 bytes of text.

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>
3 years agomm: Add folio_evictable()
Matthew Wilcox (Oracle) [Fri, 14 May 2021 19:04:28 +0000 (15:04 -0400)]
mm: Add folio_evictable()

This is the folio equivalent of page_evictable().  Unfortunately, it's
different from !folio_test_unevictable(), but I think it's used in places
where you have to be a VM expert and can reasonably be expected to know
the difference.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/workingset: Convert workingset_refault() to take a folio
Matthew Wilcox (Oracle) [Thu, 29 Apr 2021 14:27:16 +0000 (10:27 -0400)]
mm/workingset: Convert workingset_refault() to take a folio

This nets us 178 bytes of savings from removing calls to compound_head.
The three callers all grow a little, but each of them will be converted
to use folios soon, so that's fine.

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>
3 years agomm/filemap: Add readahead_folio()
Matthew Wilcox (Oracle) [Tue, 27 Apr 2021 20:37:09 +0000 (16:37 -0400)]
mm/filemap: Add readahead_folio()

The pointers stored in the page cache are folios, by definition.
This change comes with a behaviour change -- callers of readahead_folio()
are no longer required to put the page reference themselves.  This matches
how readpage works, rather than matching how readpages used to work.

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>
3 years agomm/filemap: Add folio_mkwrite_check_truncate()
Matthew Wilcox (Oracle) [Thu, 29 Apr 2021 02:30:06 +0000 (22:30 -0400)]
mm/filemap: Add folio_mkwrite_check_truncate()

This is the folio equivalent of page_mkwrite_check_truncate().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
3 years agomm/filemap: Add i_blocks_per_folio()
Matthew Wilcox (Oracle) [Wed, 28 Apr 2021 03:11:28 +0000 (23:11 -0400)]
mm/filemap: Add i_blocks_per_folio()

Reimplement i_blocks_per_page() as a wrapper around i_blocks_per_folio().

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>
3 years agomm/writeback: Add folio_redirty_for_writepage()
Matthew Wilcox (Oracle) [Mon, 3 May 2021 03:22:52 +0000 (23:22 -0400)]
mm/writeback: Add folio_redirty_for_writepage()

Reimplement redirty_page_for_writepage() as a wrapper around
folio_redirty_for_writepage().  Account the number of pages in the
folio, add kernel-doc and move the prototype to writeback.h.

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>
3 years agomm/writeback: Add folio_account_redirty()
Matthew Wilcox (Oracle) [Mon, 3 May 2021 14:06:55 +0000 (10:06 -0400)]
mm/writeback: Add folio_account_redirty()

Account the number of pages in the folio that we're redirtying.
Turn account_page_dirty() into a wrapper around it.  Also turn
the comment on folio_account_redirty() into kernel-doc and
edit it slightly so it makes sense to its potential callers.

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>
3 years agomm/writeback: Add folio_clear_dirty_for_io()
Matthew Wilcox (Oracle) [Sun, 28 Feb 2021 21:21:20 +0000 (16:21 -0500)]
mm/writeback: Add folio_clear_dirty_for_io()

Transform clear_page_dirty_for_io() into folio_clear_dirty_for_io()
and add a compatibility wrapper.  Also move the declaration to pagemap.h
as this is page cache functionality that doesn't need to be used by the
rest of the kernel.

Increases the size of the kernel by 79 bytes.  While we remove a few
calls to compound_head(), we add a call to folio_nr_pages() to get the
stats correct for the eventual support of multi-page folios.

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>
3 years agomm/writeback: Add folio_cancel_dirty()
Matthew Wilcox (Oracle) [Mon, 8 Mar 2021 21:43:04 +0000 (16:43 -0500)]
mm/writeback: Add folio_cancel_dirty()

Turn __cancel_dirty_page() into __folio_cancel_dirty() and add wrappers.
Move the prototypes into pagemap.h since this is page cache functionality.
Saves 44 bytes of kernel text in total; 33 bytes from __folio_cancel_dirty
and 11 from two callers of cancel_dirty_page().

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>
3 years agomm/writeback: Add folio_account_cleaned()
Matthew Wilcox (Oracle) [Tue, 4 May 2021 20:12:09 +0000 (16:12 -0400)]
mm/writeback: Add folio_account_cleaned()

Get the statistics right; compound pages were being accounted as a
single page.  This didn't matter before now as no filesystem which
supported compound pages did writeback.  Also move the declaration
to pagemap.h since this is part of the page cache.  Add a wrapper for
account_page_cleaned().

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>
3 years agomm/writeback: Add filemap_dirty_folio()
Matthew Wilcox (Oracle) [Tue, 4 May 2021 03:30:44 +0000 (23:30 -0400)]
mm/writeback: Add filemap_dirty_folio()

Reimplement __set_page_dirty_nobuffers() as a wrapper around
filemap_dirty_folio().  Eventually folio_mark_dirty() will pass
the folio's mapping to the address space's ->dirty_folio()
operation, so add the parameter to filemap_dirty_folio() now.

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>
3 years agomm/writeback: Convert tracing writeback_page_template to folios
Matthew Wilcox (Oracle) [Wed, 14 Jul 2021 02:45:50 +0000 (22:45 -0400)]
mm/writeback: Convert tracing writeback_page_template to folios

Rename writeback_dirty_page() to writeback_dirty_folio() and
wait_on_page_writeback() to folio_wait_writeback().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/writeback: Add __folio_mark_dirty()
Matthew Wilcox (Oracle) [Tue, 4 May 2021 15:01:10 +0000 (11:01 -0400)]
mm/writeback: Add __folio_mark_dirty()

Turn __set_page_dirty() into a wrapper around __folio_mark_dirty().
Convert account_page_dirtied() into folio_account_dirtied() and account
the number of pages in the folio to support multi-page folios.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/writeback: Add folio_mark_dirty()
Matthew Wilcox (Oracle) [Tue, 27 Apr 2021 03:53:10 +0000 (23:53 -0400)]
mm/writeback: Add folio_mark_dirty()

Reimplement set_page_dirty() as a wrapper around folio_mark_dirty().
There is no change to filesystems as they were already being called
with the compound_head of the page being marked dirty.  We avoid
several calls to compound_head(), both statically (through
using folio_test_dirty() instead of PageDirty() and dynamically by
calling folio_mapping() instead of page_mapping().

Also return bool instead of int to show the range of values actually
returned, and add kernel-doc.

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>
3 years agomm/writeback: Add folio_start_writeback()
Matthew Wilcox (Oracle) [Sat, 24 Apr 2021 16:00:48 +0000 (12:00 -0400)]
mm/writeback: Add folio_start_writeback()

Rename set_page_writeback() to folio_start_writeback() to match
folio_end_writeback().  Do not bother with wrappers that return void;
callers are perfectly capable of ignoring return values.

Add wrappers for set_page_writeback(), set_page_writeback_keepwrite() and
test_set_page_writeback() for compatibililty with existing filesystems.
The main advantage of this patch is getting the statistics right,
although it does eliminate a couple of 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>
3 years agomm/writeback: Add __folio_end_writeback()
Matthew Wilcox (Oracle) [Sat, 16 Jan 2021 04:34:16 +0000 (23:34 -0500)]
mm/writeback: Add __folio_end_writeback()

test_clear_page_writeback() is actually an mm-internal function, although
it's named as if it's a pagecache function.  Move it to mm/internal.h,
rename it to __folio_end_writeback() and change the return type to bool.

The conversion from page to folio is mostly about accounting the number
of pages being written back, although it does eliminate a couple of
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>
3 years agomm/writeback: Change __wb_writeout_inc() to __wb_writeout_add()
Matthew Wilcox (Oracle) [Sat, 20 Mar 2021 20:45:15 +0000 (16:45 -0400)]
mm/writeback: Change __wb_writeout_inc() to __wb_writeout_add()

Allow for accounting N pages at once instead of one page at a time.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agoflex_proportions: Allow N events instead of 1
Matthew Wilcox (Oracle) [Sat, 20 Mar 2021 20:34:54 +0000 (16:34 -0400)]
flex_proportions: Allow N events instead of 1

When batching events (such as writing back N pages in a single I/O), it
is better to do one flex_proportion operation instead of N.  There is
only one caller of __fprop_inc_percpu_max(), and it's the one we're
going to change in the next patch, so rename it instead of adding a
compatibility wrapper.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
3 years agomm/writeback: Rename __add_wb_stat() to wb_stat_mod()
Matthew Wilcox (Oracle) [Fri, 19 Mar 2021 12:39:50 +0000 (08:39 -0400)]
mm/writeback: Rename __add_wb_stat() to wb_stat_mod()

Make this look like the newly renamed vmstat functions.

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>
3 years agomm/migrate: Add folio_migrate_copy()
Matthew Wilcox (Oracle) [Fri, 7 May 2021 19:05:06 +0000 (15:05 -0400)]
mm/migrate: Add folio_migrate_copy()

This is the folio equivalent of migrate_page_copy(), which is retained
as a wrapper for filesystems which are not yet converted to folios.
Also convert copy_huge_page() to folio_copy().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/migrate: Add folio_migrate_flags()
Matthew Wilcox (Oracle) [Fri, 7 May 2021 19:26:29 +0000 (15:26 -0400)]
mm/migrate: Add folio_migrate_flags()

Turn migrate_page_states() into a wrapper around folio_migrate_flags().
Also convert two functions only called from folio_migrate_flags() to
be folio-based.  ksm_migrate_page() becomes folio_migrate_ksm() and
copy_page_owner() becomes folio_copy_owner().  folio_migrate_flags()
alone shrinks by two thirds -- 1967 bytes down to 642 bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
3 years agomm/migrate: Add folio_migrate_mapping()
Matthew Wilcox (Oracle) [Fri, 7 May 2021 11:28:40 +0000 (07:28 -0400)]
mm/migrate: Add folio_migrate_mapping()

Reimplement migrate_page_move_mapping() as a wrapper around
folio_migrate_mapping().  Saves 193 bytes of kernel text.

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>
3 years agomm/rmap: Add folio_mkclean()
Matthew Wilcox (Oracle) [Sun, 28 Feb 2021 21:02:57 +0000 (16:02 -0500)]
mm/rmap: Add folio_mkclean()

Transform page_mkclean() into folio_mkclean() and add a page_mkclean()
wrapper around folio_mkclean().

folio_mkclean is 15 bytes smaller than page_mkclean, but the kernel
is enlarged by 33 bytes due to inlining page_folio() into each caller.
This will go away once the callers are converted to use folio_mkclean().

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>