* 回复: Re: [PATCH] migrate_pages: modify max number of pages to migrate in batch
@ 2024-06-25 3:33 李真能
2024-06-25 4:36 ` Huang, Ying
0 siblings, 1 reply; 2+ messages in thread
From: 李真能 @ 2024-06-25 3:33 UTC (permalink / raw)
To: ying.huang; +Cc: Andrew Morton, linux-mm, linux-kernel
[-- Attachment #1: Type: text/html, Size: 3302 bytes --]
[-- Attachment #2: migrate_pages-modify-max-number-of-pages-to-migrate-in-batch.patch --]
[-- Type: application/octet-stream, Size: 1364 bytes --]
From 25c3d2df1d38b49f389234e074978d05946a0a63 Mon Sep 17 00:00:00 2001
From: Zhenneng Li <lizhenneng@kylinos.cn>
Date: Mon, 24 Jun 2024 12:19:08 +0800
Subject: [PATCH] migrate_pages: modify max number of pages to migrate in batch
We restrict the number of pages to be migrated to no more than
HPAGE_PMD_NR or NR_MAX_BATCHED_MIGRATION, but in fact, the
number of pages to be migrated may reach 2*HPAGE_PMD_NR-1 or 2
*NR_MAX_BATCHED_MIGRATION-1, it's not in inconsistent with the context.
Please refer to the patch: 42012e0436d4(migrate_pages: restrict number
of pages to migrate in batch)
Signed-off-by: Zhenneng Li <lizhenneng@kylinos.cn>
---
mm/migrate.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 781979567f64..cce8e2b85e89 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1957,11 +1957,12 @@ int migrate_pages(struct list_head *from, new_folio_t get_new_folio,
}
nr_pages += folio_nr_pages(folio);
- if (nr_pages >= NR_MAX_BATCHED_MIGRATION)
+ if ((nr_pages >= NR_MAX_BATCHED_MIGRATION) &&
+ (!list_first_entry(from, struct folio, lru)))
break;
}
if (nr_pages >= NR_MAX_BATCHED_MIGRATION)
- list_cut_before(&folios, from, &folio2->lru);
+ list_cut_before(&folios, from, &folio->lru);
else
list_splice_init(from, &folios);
if (mode == MIGRATE_ASYNC)
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: 回复: Re: [PATCH] migrate_pages: modify max number of pages to migrate in batch
2024-06-25 3:33 回复: Re: [PATCH] migrate_pages: modify max number of pages to migrate in batch 李真能
@ 2024-06-25 4:36 ` Huang, Ying
0 siblings, 0 replies; 2+ messages in thread
From: Huang, Ying @ 2024-06-25 4:36 UTC (permalink / raw)
To: 李真能; +Cc: Andrew Morton, linux-mm, linux-kernel
李真能 <lizhenneng@kylinos.cn> writes:
> ----
>
>
>
>
>
> 主 题:Re: [PATCH] migrate_pages: modify max number of pages to migrate in batch
> 日 期:2024-06-25 09:17
> 发件人:ying.huang
> 收件人:李真能;
>
> Hi, Zhenneng,
>
> Zhenneng Li writes:
>
>> We restrict the number of pages to be migrated to no more than
>> HPAGE_PMD_NR or NR_MAX_BATCHED_MIGRATION, but in fact, the
>> number of pages to be migrated may reach 2*HPAGE_PMD_NR-1 or 2
>> *NR_MAX_BATCHED_MIGRATION-1, it's not in inconsistent with the context.
>
> Yes. It's not HPAGE_PMD_NR exactly.
>
>> Please refer to the patch: 42012e0436d4(migrate_pages: restrict number
>> of pages to migrate in batch)
>>
>> Signed-off-by: Zhenneng Li
>> ---
>> mm/migrate.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index 781979567f64..7a4b37aac9e8 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1961,7 +1961,7 @@ int migrate_pages(struct list_head *from, new_folio_t get_new_folio,
>> break;
>> }
>> if (nr_pages >= NR_MAX_BATCHED_MIGRATION)
>> - list_cut_before(&folios, from, &folio2->lru);
>> + list_cut_before(&folios, from, &folio->lru);
>
> If the first entry of the list "from" is a THP with size HPAGE_PMD_NR,
> "folio" will be the first entry of from, so that "folios" will be empty.
> Right?
>
> Yes, It's right, so we can check whether it is the first entry of the list "from", new patch are as follows(attachment is
> patch file):
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 781979567f64..cce8e2b85e89 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1957,11 +1957,12 @@ int migrate_pages(struct list_head *from, new_folio_t get_new_folio,
> }
>
> nr_pages += folio_nr_pages(folio);
> - if (nr_pages >= NR_MAX_BATCHED_MIGRATION)
> + if ((nr_pages >= NR_MAX_BATCHED_MIGRATION) &&
> + (!list_first_entry(from, struct folio, lru)))
> break;
> }
> if (nr_pages >= NR_MAX_BATCHED_MIGRATION)
> - list_cut_before(&folios, from, &folio2->lru);
> + list_cut_before(&folios, from, &folio->lru);
> else
> list_splice_init(from, &folios);
> if (mode == MIGRATE_ASYNC)
>
I don't think that it's necessary to change this. Yes, the max batch
number of the page migration may be 2*HPAGE_PMD_NR-1. Does it cause any
latency issue for you?
>
>> else
>> list_splice_init(from, &folios);
>> if (mode == MIGRATE_ASYNC)
--
Best Regards,
Huang, Ying
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-25 4:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-25 3:33 回复: Re: [PATCH] migrate_pages: modify max number of pages to migrate in batch 李真能
2024-06-25 4:36 ` Huang, Ying
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox