readahead: Use folio_nr_pages() instead of shift operation
Subsystems (3)
PATCH 1/1 readahead: Use folio_nr_pages() instead of shift operation
From: Chi Zhiling <[email protected]>
folio_nr_pages() is faster helper function to get the number of pages when NR_PAGES_IN_LARGE_FOLIO is enabled.
--- mm/readahead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/readahead.c +1 -1
@@ -649,7 +649,7 @@ void page_cache_async_ra(struct readahead_control *ractl,* Ramp up sizes, and push forward the readahead window. */ expected =round_down (ra->start + ra->size - ra->async_size, -1UL <<folio_order (folio)); +folio_nr_pages (folio));if (index == expected) { ra->start += ra->size;/*
Signature · 1 line
2.43.0
Quoted 15 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
folio_nr_pages()is faster helper function to get the number of pages whenNR_PAGES_IN_LARGE_FOLIOis enabled.Signed-off-by Chi Zhiling <[email protected]>--- mm/readahead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/readahead.c +0
-0
mm/readahead.c void page_cache_async_ra(struct readahead_control *ractl, · line 655
Quoted 8 lines
mm/readahead.c +1
-1@@ -649,7 +649,7 @@ void page_cache_async_ra(struct readahead_control *ractl,* Ramp up sizes, and push forward the readahead window. */ expected =round_down (ra->start + ra->size - ra->async_size, -1UL <<folio_order (folio)); +folio_nr_pages (folio));if (index == expected) { ra->start += ra->size;/*
This should probably get squashed in Ryans commit?
LGTM
Signature · 3 lines
Cheers, David / dhildenb
Quoted 11 lines · David Hildenbrand
Quoted 10 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
folio_nr_pages()is faster helper function to get the number of pages whenNR_PAGES_IN_LARGE_FOLIOis enabled.Signed-off-by Chi Zhiling <[email protected]>---
mm/readahead.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 13 lines
mm/readahead.c +1
-1@@ -649,7 +649,7 @@ void page_cache_async_ra(struct readahead_control*ractl, * Ramp up sizes, and push forward the readahead window. */ expected = round_down(ra->start + ra->size - ra->async_size, - 1UL << folio_order(folio)); + folio_nr_pages(folio)); if (index == expected) { ra->start += ra->size;Quoted 1 line
/*
This should probably get squashed in Ryans commit?
I have no objection, it's up to Ryan.
Quoted 2 lines
LGTM
Thanks,
Quoted 1 line
Andrew Morton
maintainerQuoted 29 lines · On Sat, 12 Jul 2025 10:23:32 +0800 Chi Zhiling <[email protected]> wrote:
Quoted 11 lines · David Hildenbrand
Quoted 10 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
folio_nr_pages()is faster helper function to get the number of pages whenNR_PAGES_IN_LARGE_FOLIOis enabled.Signed-off-by Chi Zhiling <[email protected]>---
mm/readahead.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
Quoted 13 lines
mm/readahead.c +1
-1@@ -649,7 +649,7 @@ void page_cache_async_ra(struct readahead_control*ractl, * Ramp up sizes, and push forward the readahead window. */ expected = round_down(ra->start + ra->size - ra->async_size, - 1UL << folio_order(folio)); + folio_nr_pages(folio)); if (index == expected) { ra->start += ra->size;Quoted 1 line
/*
This should probably get squashed in Ryans commit?
Quoted 1 line
I have no objection, it's up to Ryan.
"Ryans commit" is now c4602f9fa77f ("mm/readahead: store folio order in struct file_ra_state") in mm-stable. I'd prefer not to rebase for this!
Ryan Roberts
Reviewed-byQuoted 31 lines · Andrew Morton
Quoted 29 lines · On Sat, 12 Jul 2025 10:23:32 +0800 Chi Zhiling <[email protected]> wrote:
Quoted 27 lines · David Hildenbrand
Quoted 23 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
folio_nr_pages()is faster helper function to get the number of pages whenNR_PAGES_IN_LARGE_FOLIOis enabled.Signed-off-by Chi Zhiling <[email protected]>---
mm/readahead.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)mm/readahead.c +1
-1@@ -649,7 +649,7 @@ void page_cache_async_ra(struct readahead_control*ractl, * Ramp up sizes, and push forward the readahead window. */ expected = round_down(ra->start + ra->size - ra->async_size, - 1UL << folio_order(folio)); + folio_nr_pages(folio)); if (index == expected) { ra->start += ra->size;Quoted 1 line
/*
This should probably get squashed in Ryans commit?
Quoted 5 lines
Quoted 1 line
I have no objection, it's up to Ryan.
"Ryans commit" is now
c4602f9fa77f("mm/readahead: store folio order in structfile_ra_state") in mm-stable. I'd prefer not to rebase for this!
Sorry about that... the function was previously using foilio_order() and storing in a local variable and using it in 2 places, one of which was "1UL << order". Because the other user went away I just moved the folio_order() call inline. But agree folio_nr_pages() is better. FWIW:
David Hildenbrand
Acked-byQuoted 31 lines · Andrew Morton
Quoted 29 lines · On Sat, 12 Jul 2025 10:23:32 +0800 Chi Zhiling <[email protected]> wrote:
Quoted 27 lines · David Hildenbrand
Quoted 23 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
folio_nr_pages()is faster helper function to get the number of pages whenNR_PAGES_IN_LARGE_FOLIOis enabled.Signed-off-by Chi Zhiling <[email protected]>--- mm/readahead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/readahead.c +1
-1@@ -649,7 +649,7 @@ void page_cache_async_ra(struct readahead_control*ractl, * Ramp up sizes, and push forward the readahead window. */ expected = round_down(ra->start + ra->size - ra->async_size, - 1UL << folio_order(folio)); + folio_nr_pages(folio)); if (index == expected) { ra->start += ra->size;Quoted 1 line
/*
This should probably get squashed in Ryans commit?
Quoted 4 lines
Quoted 1 line
I have no objection, it's up to Ryan.
"Ryans commit" is now
c4602f9fa77f("mm/readahead: store folio order in structfile_ra_state") in mm-stable. I'd prefer not to rebase for this!
Yeah, in that case, obviously no rebase :)
Signature · 3 lines
Cheers, David / dhildenb