mm/khugepaged: use page_cache_sync_ra() directly
Subsystems (2)
PATCH 1/1 mm/khugepaged: use page_cache_sync_ra() directly
The static inline page_cache_sync_readahead() wrapper in pagemap.h is legacy and only wraps page_cache_sync_ra() after initializing a local readahead_control structure using DEFINE_READAHEAD.
Modernize the khugepaged readahead call by using page_cache_sync_ra() directly. This avoids the legacy wrapper and aligns the khugepaged readahead implementation with other subsystems in the kernel.
No functional change is introduced, as the logic and behavior remain identical.
--- mm/khugepaged.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/khugepaged.c +3 -3
@@ -2331,10 +2331,10 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr, } }else {/* !is_shmem */ if (!folio ||xa_is_value (folio)) { +DEFINE_READAHEAD (ractl, file, &file->f_ra, mapping, index); +xas_unlock_irq (&xas); -page_cache_sync_readahead (mapping, &file->f_ra, - file, index, - end - index); +page_cache_sync_ra (&ractl, end - index);/* drain lru cache to help folio_isolate_lru() */ lru_add_drain (); folio =filemap_lock_folio (mapping, index);
Signature · 1 line
2.47.3
Dev Jain
reviewerQuoted 2 lines · Aditya Prakash Srivastava
The static inline
page_cache_sync_readahead()wrapper inpagemap.his legacy and only wrapspage_cache_sync_ra()after initializing
How exactly is this a legacy interface?
Quoted 5 lines
a local
readahead_controlstructure usingDEFINE_READAHEAD.Modernize the khugepaged readahead call by using
page_cache_sync_ra()directly. This avoids the legacy wrapper and aligns the khugepaged readahead implementation with other subsystems in the kernel.
I can see multiple callers of page_cache_sync_readahead.
Quoted 27 lines
No functional change is introduced, as the logic and behavior remain identical.
Signed-off-by Aditya Prakash Srivastava <[email protected]>--- mm/khugepaged.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/khugepaged.c +3
-3@@ -2331,10 +2331,10 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr, } }else {/* !is_shmem */ if (!folio ||xa_is_value (folio)) { +DEFINE_READAHEAD (ractl, file, &file->f_ra, mapping, index); +xas_unlock_irq (&xas); -page_cache_sync_readahead (mapping, &file->f_ra, - file, index, - end - index); +page_cache_sync_ra (&ractl, end - index);/* drain lru cache to help folio_isolate_lru() */ lru_add_drain (); folio =filemap_lock_folio (mapping, index);
David Hildenbrand (Arm)
maintainerQuoted 21 lines · Aditya Prakash Srivastava
The static inline
page_cache_sync_readahead()wrapper inpagemap.his legacy and only wrapspage_cache_sync_ra()after initializing a localreadahead_controlstructure usingDEFINE_READAHEAD.Modernize the khugepaged readahead call by using
page_cache_sync_ra()directly. This avoids the legacy wrapper and aligns the khugepaged readahead implementation with other subsystems in the kernel.No functional change is introduced, as the logic and behavior remain identical.
Signed-off-by Aditya Prakash Srivastava <[email protected]>--- mm/khugepaged.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/khugepaged.c +0
-0
mm/khugepaged.c static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr, · line 2337
Quoted 10 lines
mm/khugepaged.c +3
-3@@ -2331,10 +2331,10 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr, } }else {/* !is_shmem */ if (!folio ||xa_is_value (folio)) { +DEFINE_READAHEAD (ractl, file, &file->f_ra, mapping, index); +xas_unlock_irq (&xas); -page_cache_sync_readahead (mapping, &file->f_ra, - file, index, - end - index); +page_cache_sync_ra (&ractl, end - index);
The page_cache_sync_readahead() call nicely wraps these two things.
You are essentially duplicating code, no?
So I also miss the point.
Signature · 3 lines
Cheers, David
Quoted 3 lines · Aditya Prakash Srivastava
The static inline
page_cache_sync_readahead()wrapper inpagemap.his legacy and only wrapspage_cache_sync_ra()after initializing a localreadahead_controlstructure usingDEFINE_READAHEAD.
As Dev notes there's nothing legacy about it, it's used in multiple places.
Quoted 4 lines
Modernize the khugepaged readahead call by using
page_cache_sync_ra()directly. This avoids the legacy wrapper and aligns the khugepaged readahead implementation with other subsystems in the kernel.
Nope, it's replacing a helper function that wraps something with open coding it instead for no good reason.
Quoted 5 lines
No functional change is introduced, as the logic and behavior remain identical.
Signed-off-by Aditya Prakash Srivastava <[email protected]>
Sorry this patch is replacing a wrapper with open code for not really much benefit.
Quoted 23 lines
--- mm/khugepaged.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/khugepaged.c +3
-4@@ -2331,10 +2331,10 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr, } }else {/* !is_shmem */ if (!folio ||xa_is_value (folio)) { +DEFINE_READAHEAD (ractl, file, &file->f_ra, mapping, index); +xas_unlock_irq (&xas); -page_cache_sync_readahead (mapping, &file->f_ra, - file, index, - end - index); +page_cache_sync_ra (&ractl, end - index);/* drain lru cache to help folio_isolate_lru() */ lru_add_drain (); folio =filemap_lock_folio (mapping, index); --
Quoted 2 lines
2.47.3
Cheers, Lorenzo
Thanks for the feedback. I agree that replacing the helper with its open-coded implementation at a single call site doesn't provide a meaningful improvement. I'll drop this patch.
Thanks,
Aditya
Quoted 52 lines · Lorenzo Stoakes (ARM)
Quoted 3 lines · Aditya Prakash Srivastava
The static inline
page_cache_sync_readahead()wrapper inpagemap.his legacy and only wrapspage_cache_sync_ra()after initializing a localreadahead_controlstructure usingDEFINE_READAHEAD.As Dev notes there's nothing legacy about it, it's used in multiple places.
Quoted 4 lines
Modernize the khugepaged readahead call by using
page_cache_sync_ra()directly. This avoids the legacy wrapper and aligns the khugepaged readahead implementation with other subsystems in the kernel.Nope, it's replacing a helper function that wraps something with open coding it instead for no good reason.
Quoted 5 lines
No functional change is introduced, as the logic and behavior remain identical.
Signed-off-by Aditya Prakash Srivastava <[email protected]>Sorry this patch is replacing a wrapper with open code for not really much benefit.
Quoted 23 lines
--- mm/khugepaged.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/khugepaged.c +3
-4@@ -2331,10 +2331,10 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr, } }else {/* !is_shmem */ if (!folio ||xa_is_value (folio)) { +DEFINE_READAHEAD (ractl, file, &file->f_ra, mapping, index); +xas_unlock_irq (&xas); -page_cache_sync_readahead (mapping, &file->f_ra, - file, index, - end - index); +page_cache_sync_ra (&ractl, end - index);/* drain lru cache to help folio_isolate_lru() */ lru_add_drain (); folio =filemap_lock_folio (mapping, index); --Quoted 2 lines
2.47.3
Cheers, Lorenzo