linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] readahead: Use folio_nr_pages() instead of shift operation
@ 2025-07-10  6:04 Chi Zhiling
  2025-07-11 16:15 ` David Hildenbrand
  0 siblings, 1 reply; 6+ messages in thread
From: Chi Zhiling @ 2025-07-10  6:04 UTC (permalink / raw)
  To: willy, akpm; +Cc: linux-fsdevel, linux-mm, linux-kernel, Chi Zhiling

From: Chi Zhiling <chizhiling@kylinos.cn>

folio_nr_pages() is faster helper function to get the number of pages
when NR_PAGES_IN_LARGE_FOLIO is enabled.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
---
 mm/readahead.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/readahead.c b/mm/readahead.c
index 95a24f12d1e7..406756d34309 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -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;
 		/*
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] readahead: Use folio_nr_pages() instead of shift operation
  2025-07-10  6:04 [PATCH] readahead: Use folio_nr_pages() instead of shift operation Chi Zhiling
@ 2025-07-11 16:15 ` David Hildenbrand
  2025-07-12  2:23   ` Chi Zhiling
  0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2025-07-11 16:15 UTC (permalink / raw)
  To: Chi Zhiling, willy, akpm
  Cc: linux-fsdevel, linux-mm, linux-kernel, Chi Zhiling, Ryan Roberts

On 10.07.25 08:04, Chi Zhiling wrote:
> From: Chi Zhiling <chizhiling@kylinos.cn>
> 
> folio_nr_pages() is faster helper function to get the number of pages
> when NR_PAGES_IN_LARGE_FOLIO is enabled.
> 
> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
> ---
>   mm/readahead.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/readahead.c b/mm/readahead.c
> index 95a24f12d1e7..406756d34309 100644
> --- a/mm/readahead.c
> +++ b/mm/readahead.c
> @@ -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

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] readahead: Use folio_nr_pages() instead of shift operation
  2025-07-11 16:15 ` David Hildenbrand
@ 2025-07-12  2:23   ` Chi Zhiling
  2025-07-12 22:25     ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Chi Zhiling @ 2025-07-12  2:23 UTC (permalink / raw)
  To: David Hildenbrand, willy, akpm
  Cc: linux-fsdevel, linux-mm, linux-kernel, Chi Zhiling, Ryan Roberts

On 2025/7/12 00:15, David Hildenbrand wrote:
> On 10.07.25 08:04, Chi Zhiling wrote:
>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>
>> folio_nr_pages() is faster helper function to get the number of pages
>> when NR_PAGES_IN_LARGE_FOLIO is enabled.
>>
>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>> ---
>>   mm/readahead.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/readahead.c b/mm/readahead.c
>> index 95a24f12d1e7..406756d34309 100644
>> --- a/mm/readahead.c
>> +++ b/mm/readahead.c
>> @@ -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?

I have no objection, it's up to Ryan.

> 
> LGTM

Thanks,

> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] readahead: Use folio_nr_pages() instead of shift operation
  2025-07-12  2:23   ` Chi Zhiling
@ 2025-07-12 22:25     ` Andrew Morton
  2025-07-14  7:54       ` Ryan Roberts
  2025-07-14  8:04       ` David Hildenbrand
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2025-07-12 22:25 UTC (permalink / raw)
  To: Chi Zhiling
  Cc: David Hildenbrand, willy, linux-fsdevel, linux-mm, linux-kernel,
	Chi Zhiling, Ryan Roberts

On Sat, 12 Jul 2025 10:23:32 +0800 Chi Zhiling <chizhiling@163.com> wrote:

> On 2025/7/12 00:15, David Hildenbrand wrote:
> > On 10.07.25 08:04, Chi Zhiling wrote:
> >> From: Chi Zhiling <chizhiling@kylinos.cn>
> >>
> >> folio_nr_pages() is faster helper function to get the number of pages
> >> when NR_PAGES_IN_LARGE_FOLIO is enabled.
> >>
> >> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
> >> ---
> >>   mm/readahead.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/mm/readahead.c b/mm/readahead.c
> >> index 95a24f12d1e7..406756d34309 100644
> >> --- a/mm/readahead.c
> >> +++ b/mm/readahead.c
> >> @@ -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?
> 
> 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!





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] readahead: Use folio_nr_pages() instead of shift operation
  2025-07-12 22:25     ` Andrew Morton
@ 2025-07-14  7:54       ` Ryan Roberts
  2025-07-14  8:04       ` David Hildenbrand
  1 sibling, 0 replies; 6+ messages in thread
From: Ryan Roberts @ 2025-07-14  7:54 UTC (permalink / raw)
  To: Andrew Morton, Chi Zhiling
  Cc: David Hildenbrand, willy, linux-fsdevel, linux-mm, linux-kernel,
	Chi Zhiling

On 12/07/2025 23:25, Andrew Morton wrote:
> On Sat, 12 Jul 2025 10:23:32 +0800 Chi Zhiling <chizhiling@163.com> wrote:
> 
>> On 2025/7/12 00:15, David Hildenbrand wrote:
>>> On 10.07.25 08:04, Chi Zhiling wrote:
>>>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>>>
>>>> folio_nr_pages() is faster helper function to get the number of pages
>>>> when NR_PAGES_IN_LARGE_FOLIO is enabled.
>>>>
>>>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>>>> ---
>>>>   mm/readahead.c | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/mm/readahead.c b/mm/readahead.c
>>>> index 95a24f12d1e7..406756d34309 100644
>>>> --- a/mm/readahead.c
>>>> +++ b/mm/readahead.c
>>>> @@ -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?
>>
>> 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!
> 

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:

Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] readahead: Use folio_nr_pages() instead of shift operation
  2025-07-12 22:25     ` Andrew Morton
  2025-07-14  7:54       ` Ryan Roberts
@ 2025-07-14  8:04       ` David Hildenbrand
  1 sibling, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2025-07-14  8:04 UTC (permalink / raw)
  To: Andrew Morton, Chi Zhiling
  Cc: willy, linux-fsdevel, linux-mm, linux-kernel, Chi Zhiling,
	Ryan Roberts

On 13.07.25 00:25, Andrew Morton wrote:
> On Sat, 12 Jul 2025 10:23:32 +0800 Chi Zhiling <chizhiling@163.com> wrote:
> 
>> On 2025/7/12 00:15, David Hildenbrand wrote:
>>> On 10.07.25 08:04, Chi Zhiling wrote:
>>>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>>>
>>>> folio_nr_pages() is faster helper function to get the number of pages
>>>> when NR_PAGES_IN_LARGE_FOLIO is enabled.
>>>>
>>>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>>>> ---
>>>>    mm/readahead.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/mm/readahead.c b/mm/readahead.c
>>>> index 95a24f12d1e7..406756d34309 100644
>>>> --- a/mm/readahead.c
>>>> +++ b/mm/readahead.c
>>>> @@ -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?
>>
>> 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!

Yeah, in that case, obviously no rebase :)

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-14  8:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10  6:04 [PATCH] readahead: Use folio_nr_pages() instead of shift operation Chi Zhiling
2025-07-11 16:15 ` David Hildenbrand
2025-07-12  2:23   ` Chi Zhiling
2025-07-12 22:25     ` Andrew Morton
2025-07-14  7:54       ` Ryan Roberts
2025-07-14  8:04       ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).