diff mbox series

[v3,01/12] mm: Make pagecache tagged lookups return only head pages

Message ID 20201026041408.25230-2-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Overhaul multi-page lookups for THP | expand

Commit Message

Matthew Wilcox Oct. 26, 2020, 4:13 a.m. UTC
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.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
---
 mm/filemap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Mike Rapoport Oct. 28, 2020, 7:50 a.m. UTC | #1
On Mon, Oct 26, 2020 at 04:13:57AM +0000, Matthew Wilcox (Oracle) wrote:
> 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.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> ---
>  mm/filemap.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index d5e7c2029d16..edde5dc0d28f 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2066,7 +2066,7 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
>  EXPORT_SYMBOL(find_get_pages_contig);
>  
>  /**
> - * find_get_pages_range_tag - find and return pages in given range matching @tag
> + * find_get_pages_range_tag - Find and return head pages matching @tag.
>   * @mapping:	the address_space to search
>   * @index:	the starting page index
>   * @end:	The final page index (inclusive)
> @@ -2074,8 +2074,8 @@ EXPORT_SYMBOL(find_get_pages_contig);
>   * @nr_pages:	the maximum number of pages
>   * @pages:	where the resulting pages are placed
>   *
> - * Like find_get_pages, except we only return pages which are tagged with
> - * @tag.   We update @index to index the next page for the traversal.
> + * Like find_get_pages(), except we only return head pages which are tagged
> + * with @tag.   We update @index to index the next page for the traversal.

Nit:                                           ^ next head page

>   *
>   * Return: the number of pages which were found.
>   */
> @@ -2109,9 +2109,9 @@ unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index,
>  		if (unlikely(page != xas_reload(&xas)))
>  			goto put_page;
>  
> -		pages[ret] = find_subpage(page, xas.xa_index);
> +		pages[ret] = page;
>  		if (++ret == nr_pages) {
> -			*index = xas.xa_index + 1;
> +			*index = page->index + thp_nr_pages(page);
>  			goto out;
>  		}
>  		continue;
> -- 
> 2.28.0
> 
>
Matthew Wilcox Nov. 12, 2020, 5:41 p.m. UTC | #2
On Wed, Oct 28, 2020 at 09:50:56AM +0200, Mike Rapoport wrote:
> > @@ -2074,8 +2074,8 @@ EXPORT_SYMBOL(find_get_pages_contig);
> >   * @nr_pages:	the maximum number of pages
> >   * @pages:	where the resulting pages are placed
> >   *
> > - * Like find_get_pages, except we only return pages which are tagged with
> > - * @tag.   We update @index to index the next page for the traversal.
> > + * Like find_get_pages(), except we only return head pages which are tagged
> > + * with @tag.   We update @index to index the next page for the traversal.
> 
> Nit:                                           ^ next head page

I don't love the sentence anyway.  How about:

 * Like find_get_pages(), except we only return head pages which are tagged
 * with @tag.  @index is updated to the index immediately after the last
 * page we return, ready for the next iteration.
Mike Rapoport Nov. 12, 2020, 7:11 p.m. UTC | #3
On Thu, Nov 12, 2020 at 05:41:50PM +0000, Matthew Wilcox wrote:
> On Wed, Oct 28, 2020 at 09:50:56AM +0200, Mike Rapoport wrote:
> > > @@ -2074,8 +2074,8 @@ EXPORT_SYMBOL(find_get_pages_contig);
> > >   * @nr_pages:	the maximum number of pages
> > >   * @pages:	where the resulting pages are placed
> > >   *
> > > - * Like find_get_pages, except we only return pages which are tagged with
> > > - * @tag.   We update @index to index the next page for the traversal.
> > > + * Like find_get_pages(), except we only return head pages which are tagged
> > > + * with @tag.   We update @index to index the next page for the traversal.
> > 
> > Nit:                                           ^ next head page
> 
> I don't love the sentence anyway.  How about:
> 
>  * Like find_get_pages(), except we only return head pages which are tagged
>  * with @tag.  @index is updated to the index immediately after the last
>  * page we return, ready for the next iteration.

I like it.
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index d5e7c2029d16..edde5dc0d28f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2066,7 +2066,7 @@  unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
 EXPORT_SYMBOL(find_get_pages_contig);
 
 /**
- * find_get_pages_range_tag - find and return pages in given range matching @tag
+ * find_get_pages_range_tag - Find and return head pages matching @tag.
  * @mapping:	the address_space to search
  * @index:	the starting page index
  * @end:	The final page index (inclusive)
@@ -2074,8 +2074,8 @@  EXPORT_SYMBOL(find_get_pages_contig);
  * @nr_pages:	the maximum number of pages
  * @pages:	where the resulting pages are placed
  *
- * Like find_get_pages, except we only return pages which are tagged with
- * @tag.   We update @index to index the next page for the traversal.
+ * Like find_get_pages(), except we only return head pages which are tagged
+ * with @tag.   We update @index to index the next page for the traversal.
  *
  * Return: the number of pages which were found.
  */
@@ -2109,9 +2109,9 @@  unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index,
 		if (unlikely(page != xas_reload(&xas)))
 			goto put_page;
 
-		pages[ret] = find_subpage(page, xas.xa_index);
+		pages[ret] = page;
 		if (++ret == nr_pages) {
-			*index = xas.xa_index + 1;
+			*index = page->index + thp_nr_pages(page);
 			goto out;
 		}
 		continue;