The patch titled Subject: mm: convert find_get_entry to return the head page has been added to the -mm tree. Its filename is mm-convert-find_get_entry-to-return-the-head-page.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-convert-find_get_entry-to-return-the-head-page.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-convert-find_get_entry-to-return-the-head-page.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> Subject: mm: convert find_get_entry to return the head page There are only four callers remaining of find_get_entry(). get_shadow_from_swap_cache() only wants to see shadow entries and doesn't care about which page is returned. Push the find_subpage() call into find_lock_entry(), find_get_incore_page() and pagecache_get_page(). Link: https://lkml.kernel.org/r/20200910183318.20139-7-willy@xxxxxxxxxxxxx Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Cc: Huang Ying <ying.huang@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Matthew Auld <matthew.auld@xxxxxxxxx> Cc: William Kucharski <william.kucharski@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/filemap.c | 13 +++++++------ mm/swap_state.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) --- a/mm/filemap.c~mm-convert-find_get_entry-to-return-the-head-page +++ a/mm/filemap.c @@ -1547,19 +1547,19 @@ EXPORT_SYMBOL(page_cache_prev_miss); /** * find_get_entry - find and get a page cache entry * @mapping: the address_space to search - * @offset: the page cache index + * @index: The page cache index. * * Looks up the page cache slot at @mapping & @offset. If there is a - * page cache page, it is returned with an increased refcount. + * page cache page, the head page is returned with an increased refcount. * * If the slot holds a shadow entry of a previously evicted page, or a * swap entry from shmem/tmpfs, it is returned. * - * Return: the found page or shadow entry, %NULL if nothing is found. + * Return: The head page or shadow entry, %NULL if nothing is found. */ -struct page *find_get_entry(struct address_space *mapping, pgoff_t offset) +struct page *find_get_entry(struct address_space *mapping, pgoff_t index) { - XA_STATE(xas, &mapping->i_pages, offset); + XA_STATE(xas, &mapping->i_pages, index); struct page *page; rcu_read_lock(); @@ -1587,7 +1587,6 @@ repeat: put_page(page); goto repeat; } - page = find_subpage(page, offset); out: rcu_read_unlock(); @@ -1624,6 +1623,7 @@ repeat: put_page(page); goto repeat; } + page = find_subpage(page, offset); VM_BUG_ON_PAGE(page_to_pgoff(page) != offset, page); } return page; @@ -1670,6 +1670,7 @@ repeat: page = NULL; if (!page) goto no_page; + page = find_subpage(page, index); if (fgp_flags & FGP_LOCK) { if (fgp_flags & FGP_NOWAIT) { --- a/mm/swap_state.c~mm-convert-find_get_entry-to-return-the-head-page +++ a/mm/swap_state.c @@ -432,7 +432,7 @@ struct page *find_get_incore_page(struct struct page *page = find_get_entry(mapping, index); if (!xa_is_value(page)) - return page; + return find_subpage(page, index); if (!shmem_mapping(mapping)) return NULL; _ Patches currently in -mm which might be from willy@xxxxxxxxxxxxx are mm-debug-do-not-dereference-i_ino-blindly.patch mm-factor-find_get_incore_page-out-of-mincore_page.patch mm-use-find_get_incore_page-in-memcontrol.patch mm-optimise-madvise-willneed.patch proc-optimise-smaps-for-shmem-entries.patch i915-use-find_lock_page-instead-of-find_lock_entry.patch mm-convert-find_get_entry-to-return-the-head-page.patch mm-shmem-return-head-page-from-find_lock_entry.patch mm-add-find_lock_head.patch mm-account-pmd-tables-like-pte-tables.patch mm-move-pagedoublemap-bit.patch mm-simplify-pagedoublemap-with-pf_second-policy.patch xarray-add-xa_get_order.patch xarray-add-xas_split.patch xarray-add-xas_split-fix-2.patch mm-filemap-fix-storing-to-a-thp-shadow-entry.patch mm-filemap-fix-page-cache-removal-for-arbitrary-sized-thps.patch mm-memory-remove-page-fault-assumption-of-compound-page-size.patch mm-page_owner-change-split_page_owner-to-take-a-count.patch mm-huge_memory-fix-page_trans_huge_mapcount-assumption-of-thp-size.patch mm-huge_memory-fix-can_split_huge_page-assumption-of-thp-size.patch mm-rmap-fix-assumptions-of-thp-size.patch mm-truncate-fix-truncation-for-pages-of-arbitrary-size.patch mm-page-writeback-support-tail-pages-in-wait_for_stable_page.patch mm-vmscan-allow-arbitrary-sized-pages-to-be-paged-out.patch mm-readahead-add-define_readahead.patch mm-readahead-make-page_cache_ra_unbounded-take-a-readahead_control.patch mm-readahead-make-do_page_cache_ra-take-a-readahead_control.patch mm-readahead-add-page_cache_sync_ra-and-page_cache_async_ra.patch harden-autofs-ioctl-table.patch