[PATCH v2] mm/migrate: Continue to migrate for non-hugetlb folios

Chen Wandun posted 1 patch 2 years, 7 months ago
mm/migrate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH v2] mm/migrate: Continue to migrate for non-hugetlb folios
Posted by Chen Wandun 2 years, 7 months ago
migrate_hugetlbs returns -ENOMEM when no enough hugetlb,
however there may be free non-hugetlb folios available,
so continue to migrate for non-hugetlb folios.

Nowdays the only negtive return value of migrate_hugetlbs
is -ENOMEM, keep compatible for coming negtive return value
instead of ignore return value.

Signed-off-by: Chen Wandun <chenwandun@huawei.com>

---
v1 --> v2: modify changelog and comment. thanks Huang Ying.
---
 mm/migrate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index b971edbf32fc..68927aa06f9b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1939,7 +1939,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 
 	rc_gather = migrate_hugetlbs(from, get_new_page, put_new_page, private,
 				     mode, reason, &stats, &ret_folios);
-	if (rc_gather < 0)
+	/* There may be free non-hugetlb folios available, continue to migrate. */
+	if (rc_gather < 0 && rc_gather != -ENOMEM)
 		goto out;
 again:
 	nr_pages = 0;
-- 
2.25.1
Re: [PATCH v2] mm/migrate: Continue to migrate for non-hugetlb folios
Posted by Huang, Ying 2 years, 7 months ago
Chen Wandun <chenwandun@huawei.com> writes:

> migrate_hugetlbs returns -ENOMEM when no enough hugetlb,
> however there may be free non-hugetlb folios available,
> so continue to migrate for non-hugetlb folios.
>
> Nowdays the only negtive return value of migrate_hugetlbs
> is -ENOMEM, keep compatible for coming negtive return value
> instead of ignore return value.
>
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>

LGTM, Thanks!

Reviewed-by: "Huang, Ying" <ying.huang@intel.com>

>
> ---
> v1 --> v2: modify changelog and comment. thanks Huang Ying.
> ---
>  mm/migrate.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index b971edbf32fc..68927aa06f9b 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1939,7 +1939,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>  
>  	rc_gather = migrate_hugetlbs(from, get_new_page, put_new_page, private,
>  				     mode, reason, &stats, &ret_folios);
> -	if (rc_gather < 0)
> +	/* There may be free non-hugetlb folios available, continue to migrate. */
> +	if (rc_gather < 0 && rc_gather != -ENOMEM)
>  		goto out;
>  again:
>  	nr_pages = 0;