Skip to content

Commit c49f50d

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
mm: make pagecache tagged lookups return only head pages
Patch series "Overhaul multi-page lookups for THP", v4. This THP prep patchset changes several page cache iteration APIs to only return head pages. - It's only possible to tag head pages in the page cache, so only return head pages, not all their subpages. - Factor a lot of common code out of the various batch lookup routines - Add mapping_seek_hole_data() - Unify find_get_entries() and pagevec_lookup_entries() - Make find_get_entries only return head pages, like find_get_entry(). These are only loosely connected, but they seem to make sense together as a series. This patch (of 14): Pagecache tags are used for dirty page writeback. Since dirtiness is tracked on a per-THP basis, we only want to return the head page rather than each subpage of a tagged page. All the filesystems which use huge pages today are in-memory, so there are no tagged huge pages today. Link: https://lkml.kernel.org/r/20201112212641.27837-2-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Yang Shi <yang.shi@linux.alibaba.com> Cc: Dave Chinner <dchinner@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6fbd6cf commit c49f50d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mm/filemap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,16 +2062,17 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
20622062
EXPORT_SYMBOL(find_get_pages_contig);
20632063

20642064
/**
2065-
* find_get_pages_range_tag - find and return pages in given range matching @tag
2065+
* find_get_pages_range_tag - Find and return head pages matching @tag.
20662066
* @mapping: the address_space to search
20672067
* @index: the starting page index
20682068
* @end: The final page index (inclusive)
20692069
* @tag: the tag index
20702070
* @nr_pages: the maximum number of pages
20712071
* @pages: where the resulting pages are placed
20722072
*
2073-
* Like find_get_pages, except we only return pages which are tagged with
2074-
* @tag. We update @index to index the next page for the traversal.
2073+
* Like find_get_pages(), except we only return head pages which are tagged
2074+
* with @tag. @index is updated to the index immediately after the last
2075+
* page we return, ready for the next iteration.
20752076
*
20762077
* Return: the number of pages which were found.
20772078
*/
@@ -2105,9 +2106,9 @@ unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index,
21052106
if (unlikely(page != xas_reload(&xas)))
21062107
goto put_page;
21072108

2108-
pages[ret] = find_subpage(page, xas.xa_index);
2109+
pages[ret] = page;
21092110
if (++ret == nr_pages) {
2110-
*index = xas.xa_index + 1;
2111+
*index = page->index + thp_nr_pages(page);
21112112
goto out;
21122113
}
21132114
continue;

0 commit comments

Comments
 (0)