* [PATCH 1/8] filemap: Remove readahead_page()
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 20:52 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 2/8] mm: Remove offset_in_thp() Matthew Wilcox (Oracle)
` (6 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
All filesystems have now been converted to call readahead_folio()
so we can delete this wrapper.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 26baa78f1ca7..cd4bd0f8e5f6 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1308,9 +1308,9 @@ static inline bool filemap_range_needs_writeback(struct address_space *mapping,
* struct readahead_control - Describes a readahead request.
*
* A readahead request is for consecutive pages. Filesystems which
- * implement the ->readahead method should call readahead_page() or
- * readahead_page_batch() in a loop and attempt to start I/O against
- * each page in the request.
+ * implement the ->readahead method should call readahead_folio() or
+ * __readahead_batch() in a loop and attempt to start reads into each
+ * folio in the request.
*
* Most of the fields in this struct are private and should be accessed
* by the functions below.
@@ -1415,22 +1415,6 @@ static inline struct folio *__readahead_folio(struct readahead_control *ractl)
return folio;
}
-/**
- * readahead_page - Get the next page to read.
- * @ractl: The current readahead request.
- *
- * Context: The page is locked and has an elevated refcount. The caller
- * should decreases the refcount once the page has been submitted for I/O
- * and unlock the page once all I/O to that page has completed.
- * Return: A pointer to the next page, or %NULL if we are done.
- */
-static inline struct page *readahead_page(struct readahead_control *ractl)
-{
- struct folio *folio = __readahead_folio(ractl);
-
- return &folio->page;
-}
-
/**
* readahead_folio - Get the next folio to read.
* @ractl: The current readahead request.
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 1/8] filemap: Remove readahead_page()
2025-04-02 21:06 ` [PATCH 1/8] filemap: Remove readahead_page() Matthew Wilcox (Oracle)
@ 2025-04-04 20:52 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:52 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> All filesystems have now been converted to call readahead_folio()
> so we can delete this wrapper.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/pagemap.h | 22 +++-------------------
> 1 file changed, 3 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 26baa78f1ca7..cd4bd0f8e5f6 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -1308,9 +1308,9 @@ static inline bool filemap_range_needs_writeback(struct address_space *mapping,
> * struct readahead_control - Describes a readahead request.
> *
> * A readahead request is for consecutive pages. Filesystems which
> - * implement the ->readahead method should call readahead_page() or
> - * readahead_page_batch() in a loop and attempt to start I/O against
> - * each page in the request.
> + * implement the ->readahead method should call readahead_folio() or
> + * __readahead_batch() in a loop and attempt to start reads into each
> + * folio in the request.
> *
> * Most of the fields in this struct are private and should be accessed
> * by the functions below.
> @@ -1415,22 +1415,6 @@ static inline struct folio *__readahead_folio(struct readahead_control *ractl)
> return folio;
> }
>
> -/**
> - * readahead_page - Get the next page to read.
> - * @ractl: The current readahead request.
> - *
> - * Context: The page is locked and has an elevated refcount. The caller
> - * should decreases the refcount once the page has been submitted for I/O
> - * and unlock the page once all I/O to that page has completed.
> - * Return: A pointer to the next page, or %NULL if we are done.
> - */
> -static inline struct page *readahead_page(struct readahead_control *ractl)
> -{
> - struct folio *folio = __readahead_folio(ractl);
> -
> - return &folio->page;
> -}
> -
> /**
> * readahead_folio - Get the next folio to read.
> * @ractl: The current readahead request.
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 2/8] mm: Remove offset_in_thp()
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
2025-04-02 21:06 ` [PATCH 1/8] filemap: Remove readahead_page() Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 20:52 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 3/8] iov_iter: Convert iter_xarray_populate_pages() to use folios Matthew Wilcox (Oracle)
` (5 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
All callers have been converted to call offset_in_folio().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/mm.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d910b6ffcbed..99e9addec5cf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2428,7 +2428,6 @@ static inline void clear_page_pfmemalloc(struct page *page)
extern void pagefault_out_of_memory(void);
#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
-#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1))
#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1))
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 2/8] mm: Remove offset_in_thp()
2025-04-02 21:06 ` [PATCH 2/8] mm: Remove offset_in_thp() Matthew Wilcox (Oracle)
@ 2025-04-04 20:52 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:52 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> All callers have been converted to call offset_in_folio().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/mm.h | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index d910b6ffcbed..99e9addec5cf 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2428,7 +2428,6 @@ static inline void clear_page_pfmemalloc(struct page *page)
> extern void pagefault_out_of_memory(void);
>
> #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
> -#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1))
> #define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1))
>
> /*
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3/8] iov_iter: Convert iter_xarray_populate_pages() to use folios
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
2025-04-02 21:06 ` [PATCH 1/8] filemap: Remove readahead_page() Matthew Wilcox (Oracle)
2025-04-02 21:06 ` [PATCH 2/8] mm: Remove offset_in_thp() Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 20:53 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 4/8] iov_iter: Convert iov_iter_extract_xarray_pages() " Matthew Wilcox (Oracle)
` (4 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
ITER_XARRAY is exclusively used with xarrays that contain folios,
not pages, so extract folio pointers from it, not page pointers.
Removes a hidden call to compound_head() and a use of find_subpage().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
lib/iov_iter.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 8c7fdb7d8c8f..7c50691fc5bb 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1059,22 +1059,22 @@ static ssize_t iter_xarray_populate_pages(struct page **pages, struct xarray *xa
pgoff_t index, unsigned int nr_pages)
{
XA_STATE(xas, xa, index);
- struct page *page;
+ struct folio *folio;
unsigned int ret = 0;
rcu_read_lock();
- for (page = xas_load(&xas); page; page = xas_next(&xas)) {
- if (xas_retry(&xas, page))
+ for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
+ if (xas_retry(&xas, folio))
continue;
- /* Has the page moved or been split? */
- if (unlikely(page != xas_reload(&xas))) {
+ /* Has the folio moved or been split? */
+ if (unlikely(folio != xas_reload(&xas))) {
xas_reset(&xas);
continue;
}
- pages[ret] = find_subpage(page, xas.xa_index);
- get_page(pages[ret]);
+ pages[ret] = folio_file_page(folio, xas.xa_index);
+ folio_get(folio);
if (++ret == nr_pages)
break;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 3/8] iov_iter: Convert iter_xarray_populate_pages() to use folios
2025-04-02 21:06 ` [PATCH 3/8] iov_iter: Convert iter_xarray_populate_pages() to use folios Matthew Wilcox (Oracle)
@ 2025-04-04 20:53 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:53 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> ITER_XARRAY is exclusively used with xarrays that contain folios,
> not pages, so extract folio pointers from it, not page pointers.
> Removes a hidden call to compound_head() and a use of find_subpage().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> lib/iov_iter.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 8c7fdb7d8c8f..7c50691fc5bb 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1059,22 +1059,22 @@ static ssize_t iter_xarray_populate_pages(struct page **pages, struct xarray *xa
> pgoff_t index, unsigned int nr_pages)
> {
> XA_STATE(xas, xa, index);
> - struct page *page;
> + struct folio *folio;
> unsigned int ret = 0;
>
> rcu_read_lock();
> - for (page = xas_load(&xas); page; page = xas_next(&xas)) {
> - if (xas_retry(&xas, page))
> + for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
> + if (xas_retry(&xas, folio))
> continue;
>
> - /* Has the page moved or been split? */
> - if (unlikely(page != xas_reload(&xas))) {
> + /* Has the folio moved or been split? */
> + if (unlikely(folio != xas_reload(&xas))) {
> xas_reset(&xas);
> continue;
> }
>
> - pages[ret] = find_subpage(page, xas.xa_index);
> - get_page(pages[ret]);
> + pages[ret] = folio_file_page(folio, xas.xa_index);
> + folio_get(folio);
> if (++ret == nr_pages)
> break;
> }
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 4/8] iov_iter: Convert iov_iter_extract_xarray_pages() to use folios
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2025-04-02 21:06 ` [PATCH 3/8] iov_iter: Convert iter_xarray_populate_pages() to use folios Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 20:56 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 5/8] filemap: Remove find_subpage() Matthew Wilcox (Oracle)
` (3 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
ITER_XARRAY is exclusively used with xarrays that contain folios,
not pages, so extract folio pointers from it, not page pointers.
Removes a use of find_subpage().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
lib/iov_iter.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 7c50691fc5bb..a56bbf71a5d6 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1650,11 +1650,11 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i,
iov_iter_extraction_t extraction_flags,
size_t *offset0)
{
- struct page *page, **p;
+ struct page **p;
+ struct folio *folio;
unsigned int nr = 0, offset;
loff_t pos = i->xarray_start + i->iov_offset;
- pgoff_t index = pos >> PAGE_SHIFT;
- XA_STATE(xas, i->xarray, index);
+ XA_STATE(xas, i->xarray, pos >> PAGE_SHIFT);
offset = pos & ~PAGE_MASK;
*offset0 = offset;
@@ -1665,17 +1665,17 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i,
p = *pages;
rcu_read_lock();
- for (page = xas_load(&xas); page; page = xas_next(&xas)) {
- if (xas_retry(&xas, page))
+ for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
+ if (xas_retry(&xas, folio))
continue;
- /* Has the page moved or been split? */
- if (unlikely(page != xas_reload(&xas))) {
+ /* Has the folio moved or been split? */
+ if (unlikely(folio != xas_reload(&xas))) {
xas_reset(&xas);
continue;
}
- p[nr++] = find_subpage(page, xas.xa_index);
+ p[nr++] = folio_file_page(folio, xas.xa_index);
if (nr == maxpages)
break;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 4/8] iov_iter: Convert iov_iter_extract_xarray_pages() to use folios
2025-04-02 21:06 ` [PATCH 4/8] iov_iter: Convert iov_iter_extract_xarray_pages() " Matthew Wilcox (Oracle)
@ 2025-04-04 20:56 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:56 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> ITER_XARRAY is exclusively used with xarrays that contain folios,
> not pages, so extract folio pointers from it, not page pointers.
> Removes a use of find_subpage().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> lib/iov_iter.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 7c50691fc5bb..a56bbf71a5d6 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1650,11 +1650,11 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i,
> iov_iter_extraction_t extraction_flags,
> size_t *offset0)
> {
> - struct page *page, **p;
> + struct page **p;
> + struct folio *folio;
> unsigned int nr = 0, offset;
> loff_t pos = i->xarray_start + i->iov_offset;
> - pgoff_t index = pos >> PAGE_SHIFT;
> - XA_STATE(xas, i->xarray, index);
> + XA_STATE(xas, i->xarray, pos >> PAGE_SHIFT);
>
> offset = pos & ~PAGE_MASK;
> *offset0 = offset;
> @@ -1665,17 +1665,17 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i,
> p = *pages;
>
> rcu_read_lock();
> - for (page = xas_load(&xas); page; page = xas_next(&xas)) {
> - if (xas_retry(&xas, page))
> + for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
> + if (xas_retry(&xas, folio))
> continue;
>
> - /* Has the page moved or been split? */
> - if (unlikely(page != xas_reload(&xas))) {
> + /* Has the folio moved or been split? */
> + if (unlikely(folio != xas_reload(&xas))) {
> xas_reset(&xas);
> continue;
> }
>
> - p[nr++] = find_subpage(page, xas.xa_index);
> + p[nr++] = folio_file_page(folio, xas.xa_index);
> if (nr == maxpages)
> break;
> }
I'm curious, if we would have a large folio in there, and we'd want to
extract multiple pages ... wouldn't we only extract one page per large
folio only? :/
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 5/8] filemap: Remove find_subpage()
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2025-04-02 21:06 ` [PATCH 4/8] iov_iter: Convert iov_iter_extract_xarray_pages() " Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 20:57 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 6/8] filemap: Convert __readahead_batch() to use a folio Matthew Wilcox (Oracle)
` (2 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
All users of this function now call folio_file_page() instead.
Delete it.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index cd4bd0f8e5f6..0ddd4bd8cdf8 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -945,19 +945,6 @@ static inline bool folio_contains(struct folio *folio, pgoff_t index)
return index - folio_index(folio) < folio_nr_pages(folio);
}
-/*
- * Given the page we found in the page cache, return the page corresponding
- * to this index in the file
- */
-static inline struct page *find_subpage(struct page *head, pgoff_t index)
-{
- /* HugeTLBfs wants the head page regardless */
- if (PageHuge(head))
- return head;
-
- return head + (index & (thp_nr_pages(head) - 1));
-}
-
unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start,
pgoff_t end, struct folio_batch *fbatch);
unsigned filemap_get_folios_contig(struct address_space *mapping,
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 5/8] filemap: Remove find_subpage()
2025-04-02 21:06 ` [PATCH 5/8] filemap: Remove find_subpage() Matthew Wilcox (Oracle)
@ 2025-04-04 20:57 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:57 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> All users of this function now call folio_file_page() instead.
> Delete it.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/pagemap.h | 13 -------------
> 1 file changed, 13 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index cd4bd0f8e5f6..0ddd4bd8cdf8 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -945,19 +945,6 @@ static inline bool folio_contains(struct folio *folio, pgoff_t index)
> return index - folio_index(folio) < folio_nr_pages(folio);
> }
>
> -/*
> - * Given the page we found in the page cache, return the page corresponding
> - * to this index in the file
> - */
> -static inline struct page *find_subpage(struct page *head, pgoff_t index)
> -{
> - /* HugeTLBfs wants the head page regardless */
> - if (PageHuge(head))
> - return head;
> -
> - return head + (index & (thp_nr_pages(head) - 1));
> -}
> -
> unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start,
> pgoff_t end, struct folio_batch *fbatch);
> unsigned filemap_get_folios_contig(struct address_space *mapping,
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 6/8] filemap: Convert __readahead_batch() to use a folio
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2025-04-02 21:06 ` [PATCH 5/8] filemap: Remove find_subpage() Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 20:59 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 7/8] filemap: Remove readahead_page_batch() Matthew Wilcox (Oracle)
2025-04-02 21:06 ` [PATCH 8/8] mm: Delete thp_nr_pages() Matthew Wilcox (Oracle)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
Extract folios from i_mapping, not pages. Removes a hidden call to
compound_head(), a use of thp_nr_pages() and an unnecessary assertion
that we didn't find a tail page in the page cache.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 0ddd4bd8cdf8..c5c9b3770d75 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1424,7 +1424,7 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
{
unsigned int i = 0;
XA_STATE(xas, &rac->mapping->i_pages, 0);
- struct page *page;
+ struct folio *folio;
BUG_ON(rac->_batch_count > rac->_nr_pages);
rac->_nr_pages -= rac->_batch_count;
@@ -1433,13 +1433,12 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
xas_set(&xas, rac->_index);
rcu_read_lock();
- xas_for_each(&xas, page, rac->_index + rac->_nr_pages - 1) {
- if (xas_retry(&xas, page))
+ xas_for_each(&xas, folio, rac->_index + rac->_nr_pages - 1) {
+ if (xas_retry(&xas, folio))
continue;
- VM_BUG_ON_PAGE(!PageLocked(page), page);
- VM_BUG_ON_PAGE(PageTail(page), page);
- array[i++] = page;
- rac->_batch_count += thp_nr_pages(page);
+ VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
+ array[i++] = folio_page(folio, 0);
+ rac->_batch_count += folio_nr_pages(folio);
if (i == array_sz)
break;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 6/8] filemap: Convert __readahead_batch() to use a folio
2025-04-02 21:06 ` [PATCH 6/8] filemap: Convert __readahead_batch() to use a folio Matthew Wilcox (Oracle)
@ 2025-04-04 20:59 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:59 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> Extract folios from i_mapping, not pages. Removes a hidden call to
> compound_head(), a use of thp_nr_pages() and an unnecessary assertion
> that we didn't find a tail page in the page cache.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/pagemap.h | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 0ddd4bd8cdf8..c5c9b3770d75 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -1424,7 +1424,7 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
> {
> unsigned int i = 0;
> XA_STATE(xas, &rac->mapping->i_pages, 0);
> - struct page *page;
> + struct folio *folio;
>
> BUG_ON(rac->_batch_count > rac->_nr_pages);
> rac->_nr_pages -= rac->_batch_count;
> @@ -1433,13 +1433,12 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
>
> xas_set(&xas, rac->_index);
> rcu_read_lock();
> - xas_for_each(&xas, page, rac->_index + rac->_nr_pages - 1) {
> - if (xas_retry(&xas, page))
> + xas_for_each(&xas, folio, rac->_index + rac->_nr_pages - 1) {
> + if (xas_retry(&xas, folio))
> continue;
> - VM_BUG_ON_PAGE(!PageLocked(page), page);
> - VM_BUG_ON_PAGE(PageTail(page), page);
> - array[i++] = page;
> - rac->_batch_count += thp_nr_pages(page);
> + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
> + array[i++] = folio_page(folio, 0);
> + rac->_batch_count += folio_nr_pages(folio);
> if (i == array_sz)
> break;
> }
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 7/8] filemap: Remove readahead_page_batch()
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
` (5 preceding siblings ...)
2025-04-02 21:06 ` [PATCH 6/8] filemap: Convert __readahead_batch() to use a folio Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 21:00 ` David Hildenbrand
2025-04-02 21:06 ` [PATCH 8/8] mm: Delete thp_nr_pages() Matthew Wilcox (Oracle)
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
This function has no more callers; delete it.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index c5c9b3770d75..af25fb640463 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1447,20 +1447,6 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
return i;
}
-/**
- * readahead_page_batch - Get a batch of pages to read.
- * @rac: The current readahead request.
- * @array: An array of pointers to struct page.
- *
- * Context: The pages are locked and have an elevated refcount. The caller
- * should decreases the refcount once the page has been submitted for I/O
- * and unlock the page once all I/O to that page has completed.
- * Return: The number of pages placed in the array. 0 indicates the request
- * is complete.
- */
-#define readahead_page_batch(rac, array) \
- __readahead_batch(rac, array, ARRAY_SIZE(array))
-
/**
* readahead_pos - The byte offset into the file of this readahead request.
* @rac: The readahead request.
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 7/8] filemap: Remove readahead_page_batch()
2025-04-02 21:06 ` [PATCH 7/8] filemap: Remove readahead_page_batch() Matthew Wilcox (Oracle)
@ 2025-04-04 21:00 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 21:00 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> This function has no more callers; delete it.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/pagemap.h | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index c5c9b3770d75..af25fb640463 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -1447,20 +1447,6 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
> return i;
> }
>
> -/**
> - * readahead_page_batch - Get a batch of pages to read.
> - * @rac: The current readahead request.
> - * @array: An array of pointers to struct page.
> - *
> - * Context: The pages are locked and have an elevated refcount. The caller
> - * should decreases the refcount once the page has been submitted for I/O
> - * and unlock the page once all I/O to that page has completed.
> - * Return: The number of pages placed in the array. 0 indicates the request
> - * is complete.
> - */
> -#define readahead_page_batch(rac, array) \
> - __readahead_batch(rac, array, ARRAY_SIZE(array))
> -
> /**
> * readahead_pos - The byte offset into the file of this readahead request.
> * @rac: The readahead request.
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 8/8] mm: Delete thp_nr_pages()
2025-04-02 21:06 [PATCH 0/8] Misc folio patches for 6.16 Matthew Wilcox (Oracle)
` (6 preceding siblings ...)
2025-04-02 21:06 ` [PATCH 7/8] filemap: Remove readahead_page_batch() Matthew Wilcox (Oracle)
@ 2025-04-02 21:06 ` Matthew Wilcox (Oracle)
2025-04-04 21:00 ` David Hildenbrand
7 siblings, 1 reply; 17+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-04-02 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, linux-fsdevel
All callers now use folio_nr_pages(). Delete this wrapper.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/mm.h | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 99e9addec5cf..0481e30f563e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2206,15 +2206,6 @@ static inline long compound_nr(struct page *page)
return folio_large_nr_pages(folio);
}
-/**
- * thp_nr_pages - The number of regular pages in this huge page.
- * @page: The head page of a huge page.
- */
-static inline long thp_nr_pages(struct page *page)
-{
- return folio_nr_pages((struct folio *)page);
-}
-
/**
* folio_next - Move to the next physical folio.
* @folio: The folio we're currently operating on.
--
2.47.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 8/8] mm: Delete thp_nr_pages()
2025-04-02 21:06 ` [PATCH 8/8] mm: Delete thp_nr_pages() Matthew Wilcox (Oracle)
@ 2025-04-04 21:00 ` David Hildenbrand
0 siblings, 0 replies; 17+ messages in thread
From: David Hildenbrand @ 2025-04-04 21:00 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm, linux-fsdevel
On 02.04.25 23:06, Matthew Wilcox (Oracle) wrote:
> All callers now use folio_nr_pages(). Delete this wrapper.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/mm.h | 9 ---------
> 1 file changed, 9 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 99e9addec5cf..0481e30f563e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2206,15 +2206,6 @@ static inline long compound_nr(struct page *page)
> return folio_large_nr_pages(folio);
> }
>
> -/**
> - * thp_nr_pages - The number of regular pages in this huge page.
> - * @page: The head page of a huge page.
> - */
> -static inline long thp_nr_pages(struct page *page)
> -{
> - return folio_nr_pages((struct folio *)page);
> -}
> -
> /**
> * folio_next - Move to the next physical folio.
> * @folio: The folio we're currently operating on.
Hurray!
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 17+ messages in thread