mm/memory_hotplug: cleanup do_migrate_range()
Subsystems (2)
v2 cover mm/memory_hotplug: cleanup do_migrate_range()
Make do_migrate_range() return value mechanism simple.
Changes from v1
(https://lore.kernel.org/linux-mm/[email protected]/)
- Simply return nothing from do_migrate_range() (David Hildenbrand)
- Add a cleanup for 'ret' variable
SeongJae Park (2):
mm/memory_hotplug: return nothing from do_migrate_range() mm/memory_hotplug: cleanup 'ret' variable usage in do_migrate_range()
mm/memory_hotplug.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 mm/memory_hotplug: return nothing from do_migrate_range()
Return value mechanism of do_migrate_range() is not very simple, while no caller of the function checks the return value. Make the function return nothing to be more simple.
--- mm/memory_hotplug.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/memory_hotplug.c +1 -4
@@ -1620,8 +1620,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,return 0 ; } -static int -do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) +static void do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) {unsigned long pfn;struct page *page, *head;
@@ -1721,8 +1720,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)putback_movable_pages (&source); } } - -return ret; }static int __init cmdline_parse_movable_node (char *p)
Signature · 1 line
2.25.1
Re: [PATCH v2 1/2] mm/memory_hotplug: return nothing from do_migrate_range()
Quoted 25 lines · SeongJae Park
Return value mechanism of
do_migrate_range()is not very simple, while no caller of the function checks the return value. Make the function return nothing to be more simple.Suggested-by David Hildenbrand <[email protected]>Signed-off-by SeongJae Park <[email protected]>--- mm/memory_hotplug.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/memory_hotplug.c +1
-2@@ -1620,8 +1620,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,return 0 ; } -static int -do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) +static void do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) {unsigned long pfn;struct page *page, *head;
mm/memory_hotplug.c do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) · line 1723
Quoted 6 lines
mm/memory_hotplug.c +0
-2@@ -1721,8 +1720,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)putback_movable_pages (&source); } } - -return ret; }
I think this patch should also stop initializing ret = 0 inside that function.
With that
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v2 1/2] mm/memory_hotplug: return nothing from do_migrate_range()
Hi David,
Quoted 19 lines · On Thu, 16 Feb 2023 10:46:59 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 18 lines · SeongJae Park
Return value mechanism of
do_migrate_range()is not very simple, while no caller of the function checks the return value. Make the function return nothing to be more simple.Suggested-by David Hildenbrand <[email protected]>Signed-off-by SeongJae Park <[email protected]>--- mm/memory_hotplug.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/memory_hotplug.c +0
-0@@ -1620,8 +1620,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,return 0 ; }
Quoted 16 lines
mm/memory_hotplug.c do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) · line 1723
Quoted 13 lines
mm/memory_hotplug.c +1
-4-static int -do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) +static void do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) {unsigned long pfn;struct page *page, *head;@@ -1721,8 +1720,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)putback_movable_pages (&source); } } - -return ret; }I think this patch should also stop initializing ret = 0 inside that function.
The second patch does it, and I read your reply to the patch asking squashing it in this one. I will send the new version soon.
Quoted 4 lines
With that
Thanks you.
Thanks,
SJ
Quoted 7 lines
Signature · 4 lines
-- Thanks, David / dhildenb
Re: [PATCH v2 1/2] mm/memory_hotplug: return nothing from do_migrate_range()
In reply to SeongJae ParkQuoted 25 lines · SeongJae Park
Return value mechanism of
do_migrate_range()is not very simple, while no caller of the function checks the return value. Make the function return nothing to be more simple.Suggested-by David Hildenbrand <[email protected]>Signed-off-by SeongJae Park <[email protected]>--- mm/memory_hotplug.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/memory_hotplug.c +1
-2@@ -1620,8 +1620,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,return 0 ; } -static int -do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) +static void do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) {unsigned long pfn;struct page *page, *head;
mm/memory_hotplug.c do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) · line 1725
Quoted 5 lines
mm/memory_hotplug.c +0
-2@@ -1721,8 +1720,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)putback_movable_pages (&source); } } - -return ret;
Nit: while we are at it, can we also remove the "TODO" comment in offline_pages()?
ret = scan_movable_pages(pfn, end_pfn, &pfn);
if (!ret) {
/*
* TODO: fatal migration failures should bail
* out
*/
do_migrate_range(pfn, end_pfn);
}With David's comments:
Re: [PATCH v2 1/2] mm/memory_hotplug: return nothing from do_migrate_range()
Hi Baolin,
Quoted 46 lines · On Thu, 16 Feb 2023 18:53:34 +0800 Baolin Wang <[email protected]>…
Quoted 25 lines · SeongJae Park
Return value mechanism of
do_migrate_range()is not very simple, while no caller of the function checks the return value. Make the function return nothing to be more simple.Suggested-by David Hildenbrand <[email protected]>Signed-off-by SeongJae Park <[email protected]>--- mm/memory_hotplug.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/memory_hotplug.c +1
-2@@ -1620,8 +1620,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,return 0 ; } -static int -do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) +static void do_migrate_range (unsigned long start_pfn,unsigned long end_pfn) {unsigned long pfn;struct page *page, *head;mm/memory_hotplug.c do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) · line 1725
Quoted 5 lines
mm/memory_hotplug.c +0
-2@@ -1721,8 +1720,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)putback_movable_pages (&source); } } - -return ret;Nit: while we are at it, can we also remove the "TODO" comment in
offline_pages()?ret =
scan_movable_pages(pfn, end_pfn, &pfn);if (!ret) { /* * TODO: fatal migration failures should bail * out */ do_migrate_range(pfn, end_pfn); }
Quoted 2 lines
With David's comments:
Reviewed-by Baolin Wang <[email protected]>
As David mentioned we're just still unclear what issues are fatal[1], I was thinking we didn't forgive the future work, so left the comment. If anyone has different opinion or I'm getting something wrong, please let me know.
[1] https://lore.kernel.org/linux-mm/[email protected]/
Thanks,
SJ
PATCH v2 2/2 mm/memory_hotplug: cleanup 'ret' variable usage in do_migrate_range()
In reply to SeongJae ParkBecause do_migrate_range() is returning nothing, some 'ret' variable usages are unnecessary. Remove unnecessary usage and reduce its scope.
--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/memory_hotplug.c +1 -2
@@ -1624,7 +1624,6 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) {unsigned long pfn;struct page *page, *head; -int ret =0 ;LIST_HEAD (source); static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
@@ -1678,7 +1677,6 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) page_is_file_lru(page)); }else { - ret = -EBUSY ;if (__ratelimit (&migrate_rs)) {pr_warn ("failed to isolate pfn %lx\n" , pfn);dump_page (page,"isolation failed" );
@@ -1692,6 +1690,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) .nmask = &nmask, .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, }; +int ret;/* * We have checked that migration range is on a single zone so
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] mm/memory_hotplug: cleanup 'ret' variable usage in do_migrate_range()
Quoted 29 lines · SeongJae Park
Because
do_migrate_range()is returning nothing, some 'ret' variable usages are unnecessary. Remove unnecessary usage and reduce its scope.Signed-off-by SeongJae Park <[email protected]>--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/memory_hotplug.c +0
-2@@ -1624,7 +1624,6 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) {unsigned long pfn;struct page *page, *head; -int ret =0 ;LIST_HEAD (source); static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);@@ -1678,7 +1677,6 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) page_is_file_lru(page)); }else { - ret = -EBUSY ;if (__ratelimit (&migrate_rs)) {pr_warn ("failed to isolate pfn %lx\n" , pfn);dump_page (page,"isolation failed" );
mm/memory_hotplug.c static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) · line 1696
Quoted 7 lines
mm/memory_hotplug.c +1
-0@@ -1692,6 +1690,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) .nmask = &nmask, .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, }; +int ret;/* * We have checked that migration range is on a single zone so
Please squash that into the previous patch, just calling it "mm/memory_hotplug: cleanup return value handling in do_migrate_range()" or similar.
Signature · 3 lines
Thanks, David / dhildenb