All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: compaction: use the correct type of list for free pages
@ 2023-07-07  8:51 Baolin Wang
  2023-07-07  8:51 ` [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating " Baolin Wang
  2023-07-07 11:52 ` [PATCH 1/2] mm: compaction: use the correct type of list for " David Hildenbrand
  0 siblings, 2 replies; 7+ messages in thread
From: Baolin Wang @ 2023-07-07  8:51 UTC (permalink / raw)
  To: akpm
  Cc: mgorman, vbabka, david, ying.huang, baolin.wang, linux-mm, linux-kernel

Use the page->buddy_list instead of page->lru to clarify the correct type
of list for free pages.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/compaction.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index dbc9f86b1934..43358efdbdc2 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1500,7 +1500,7 @@ static void fast_isolate_freepages(struct compact_control *cc)
 
 		spin_lock_irqsave(&cc->zone->lock, flags);
 		freelist = &area->free_list[MIGRATE_MOVABLE];
-		list_for_each_entry_reverse(freepage, freelist, lru) {
+		list_for_each_entry_reverse(freepage, freelist, buddy_list) {
 			unsigned long pfn;
 
 			order_scanned++;
@@ -1883,7 +1883,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
 
 		spin_lock_irqsave(&cc->zone->lock, flags);
 		freelist = &area->free_list[MIGRATE_MOVABLE];
-		list_for_each_entry(freepage, freelist, lru) {
+		list_for_each_entry(freepage, freelist, buddy_list) {
 			unsigned long free_pfn;
 
 			if (nr_scanned++ >= limit) {
-- 
2.39.3


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

* [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating free pages
  2023-07-07  8:51 [PATCH 1/2] mm: compaction: use the correct type of list for free pages Baolin Wang
@ 2023-07-07  8:51 ` Baolin Wang
  2023-07-07 11:56   ` David Hildenbrand
  2023-07-10  6:11   ` Huang, Ying
  2023-07-07 11:52 ` [PATCH 1/2] mm: compaction: use the correct type of list for " David Hildenbrand
  1 sibling, 2 replies; 7+ messages in thread
From: Baolin Wang @ 2023-07-07  8:51 UTC (permalink / raw)
  To: akpm
  Cc: mgorman, vbabka, david, ying.huang, baolin.wang, linux-mm, linux-kernel

On my machine with below memory layout, and I can see it will take more
time to skip the larger memory hole (range: 0x100000000 - 0x1800000000)
when isolating free pages. So adding a new helper to skip the memory
hole rapidly, which can reduce the time consumed from about 70us to less
than 1us.

[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
[    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
[    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
[    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
[    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
[    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
[    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
[    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
[    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
[    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/compaction.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 43358efdbdc2..9641e2131901 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -249,11 +249,31 @@ static unsigned long skip_offline_sections(unsigned long start_pfn)
 
 	return 0;
 }
+
+static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
+{
+	unsigned long start_nr = pfn_to_section_nr(start_pfn);
+
+	if (!start_nr || online_section_nr(start_nr))
+		return 0;
+
+	while (start_nr-- > 0) {
+		if (online_section_nr(start_nr))
+			return section_nr_to_pfn(start_nr) + PAGES_PER_SECTION - 1;
+	}
+
+	return 0;
+}
 #else
 static unsigned long skip_offline_sections(unsigned long start_pfn)
 {
 	return 0;
 }
+
+static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
+{
+	return 0;
+}
 #endif
 
 /*
@@ -1668,8 +1688,16 @@ static void isolate_freepages(struct compact_control *cc)
 
 		page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn,
 									zone);
-		if (!page)
+		if (!page) {
+			unsigned long next_pfn;
+
+			next_pfn = skip_offline_sections_reverse(block_start_pfn);
+			if (next_pfn)
+				block_start_pfn = max(pageblock_start_pfn(next_pfn),
+						      low_pfn);
+
 			continue;
+		}
 
 		/* Check the block is suitable for migration */
 		if (!suitable_migration_target(cc, page))
-- 
2.39.3


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

* Re: [PATCH 1/2] mm: compaction: use the correct type of list for free pages
  2023-07-07  8:51 [PATCH 1/2] mm: compaction: use the correct type of list for free pages Baolin Wang
  2023-07-07  8:51 ` [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating " Baolin Wang
@ 2023-07-07 11:52 ` David Hildenbrand
  1 sibling, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2023-07-07 11:52 UTC (permalink / raw)
  To: Baolin Wang, akpm; +Cc: mgorman, vbabka, ying.huang, linux-mm, linux-kernel

On 07.07.23 10:51, Baolin Wang wrote:
> Use the page->buddy_list instead of page->lru to clarify the correct type
> of list for free pages.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>   mm/compaction.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index dbc9f86b1934..43358efdbdc2 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -1500,7 +1500,7 @@ static void fast_isolate_freepages(struct compact_control *cc)
>   
>   		spin_lock_irqsave(&cc->zone->lock, flags);
>   		freelist = &area->free_list[MIGRATE_MOVABLE];
> -		list_for_each_entry_reverse(freepage, freelist, lru) {
> +		list_for_each_entry_reverse(freepage, freelist, buddy_list) {
>   			unsigned long pfn;
>   
>   			order_scanned++;
> @@ -1883,7 +1883,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
>   
>   		spin_lock_irqsave(&cc->zone->lock, flags);
>   		freelist = &area->free_list[MIGRATE_MOVABLE];
> -		list_for_each_entry(freepage, freelist, lru) {
> +		list_for_each_entry(freepage, freelist, buddy_list) {
>   			unsigned long free_pfn;
>   
>   			if (nr_scanned++ >= limit) {

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

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating free pages
  2023-07-07  8:51 ` [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating " Baolin Wang
@ 2023-07-07 11:56   ` David Hildenbrand
  2023-07-10  6:11   ` Huang, Ying
  1 sibling, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2023-07-07 11:56 UTC (permalink / raw)
  To: Baolin Wang, akpm; +Cc: mgorman, vbabka, ying.huang, linux-mm, linux-kernel

On 07.07.23 10:51, Baolin Wang wrote:
> On my machine with below memory layout, and I can see it will take more
> time to skip the larger memory hole (range: 0x100000000 - 0x1800000000)
> when isolating free pages. So adding a new helper to skip the memory
> hole rapidly, which can reduce the time consumed from about 70us to less
> than 1us.

Can you clarify how this relates to the previous commit and mention that 
commit?

> 
> [    0.000000] Zone ranges:
> [    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
> [    0.000000]   DMA32    empty
> [    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]
> [    0.000000] Movable zone start for each node
> [    0.000000] Early memory node ranges
> [    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
> [    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
> [    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
> [    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
> [    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
> [    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
> [    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>   mm/compaction.c | 30 +++++++++++++++++++++++++++++-
>   1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 43358efdbdc2..9641e2131901 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -249,11 +249,31 @@ static unsigned long skip_offline_sections(unsigned long start_pfn)
>   
>   	return 0;
>   }
> +
> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
> +{
> +	unsigned long start_nr = pfn_to_section_nr(start_pfn);
> +
> +	if (!start_nr || online_section_nr(start_nr))
> +		return 0;
> +
> +	while (start_nr-- > 0) {
> +		if (online_section_nr(start_nr))
> +			return section_nr_to_pfn(start_nr) + PAGES_PER_SECTION - 1;
> +	}
> +
> +	return 0;
> +}
>   #else
>   static unsigned long skip_offline_sections(unsigned long start_pfn)
>   {
>   	return 0;
>   }
> +
> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
> +{
> +	return 0;
> +}
>   #endif
>   
>   /*
> @@ -1668,8 +1688,16 @@ static void isolate_freepages(struct compact_control *cc)
>   
>   		page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn,
>   									zone);
> -		if (!page)
> +		if (!page) {
> +			unsigned long next_pfn;
> +
> +			next_pfn = skip_offline_sections_reverse(block_start_pfn);
> +			if (next_pfn)
> +				block_start_pfn = max(pageblock_start_pfn(next_pfn),
> +						      low_pfn);
> +
>   			continue;
> +		}
>   
>   		/* Check the block is suitable for migration */
>   		if (!suitable_migration_target(cc, page))


LGTM

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

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating free pages
  2023-07-07  8:51 ` [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating " Baolin Wang
  2023-07-07 11:56   ` David Hildenbrand
@ 2023-07-10  6:11   ` Huang, Ying
  2023-07-10  9:26     ` Baolin Wang
  1 sibling, 1 reply; 7+ messages in thread
From: Huang, Ying @ 2023-07-10  6:11 UTC (permalink / raw)
  To: Baolin Wang; +Cc: akpm, mgorman, vbabka, david, linux-mm, linux-kernel

Baolin Wang <baolin.wang@linux.alibaba.com> writes:

> On my machine with below memory layout, and I can see it will take more
> time to skip the larger memory hole (range: 0x100000000 - 0x1800000000)
> when isolating free pages. So adding a new helper to skip the memory
> hole rapidly, which can reduce the time consumed from about 70us to less
> than 1us.
>
> [    0.000000] Zone ranges:
> [    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
> [    0.000000]   DMA32    empty
> [    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]

The memory hole is at the beginning of zone NORMAL?  If so, should zone
NORMAL start at 0x1800000000?  And, the free pages will not be scanned
there?  Or my understanding were wrong?

Best Regards,
Huang, Ying

> [    0.000000] Movable zone start for each node
> [    0.000000] Early memory node ranges
> [    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
> [    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
> [    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
> [    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
> [    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
> [    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
> [    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]
>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>  mm/compaction.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 43358efdbdc2..9641e2131901 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -249,11 +249,31 @@ static unsigned long skip_offline_sections(unsigned long start_pfn)
>  
>  	return 0;
>  }
> +
> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
> +{
> +	unsigned long start_nr = pfn_to_section_nr(start_pfn);
> +
> +	if (!start_nr || online_section_nr(start_nr))
> +		return 0;
> +
> +	while (start_nr-- > 0) {
> +		if (online_section_nr(start_nr))
> +			return section_nr_to_pfn(start_nr) + PAGES_PER_SECTION - 1;
> +	}
> +
> +	return 0;
> +}
>  #else
>  static unsigned long skip_offline_sections(unsigned long start_pfn)
>  {
>  	return 0;
>  }
> +
> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
> +{
> +	return 0;
> +}
>  #endif
>  
>  /*
> @@ -1668,8 +1688,16 @@ static void isolate_freepages(struct compact_control *cc)
>  
>  		page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn,
>  									zone);
> -		if (!page)
> +		if (!page) {
> +			unsigned long next_pfn;
> +
> +			next_pfn = skip_offline_sections_reverse(block_start_pfn);
> +			if (next_pfn)
> +				block_start_pfn = max(pageblock_start_pfn(next_pfn),
> +						      low_pfn);
> +
>  			continue;
> +		}
>  
>  		/* Check the block is suitable for migration */
>  		if (!suitable_migration_target(cc, page))

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

* Re: [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating free pages
  2023-07-10  6:11   ` Huang, Ying
@ 2023-07-10  9:26     ` Baolin Wang
  2023-07-11  0:37       ` Huang, Ying
  0 siblings, 1 reply; 7+ messages in thread
From: Baolin Wang @ 2023-07-10  9:26 UTC (permalink / raw)
  To: Huang, Ying; +Cc: akpm, mgorman, vbabka, david, linux-mm, linux-kernel



On 7/10/2023 2:11 PM, Huang, Ying wrote:
> Baolin Wang <baolin.wang@linux.alibaba.com> writes:
> 
>> On my machine with below memory layout, and I can see it will take more
>> time to skip the larger memory hole (range: 0x100000000 - 0x1800000000)
>> when isolating free pages. So adding a new helper to skip the memory
>> hole rapidly, which can reduce the time consumed from about 70us to less
>> than 1us.
>>
>> [    0.000000] Zone ranges:
>> [    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
>> [    0.000000]   DMA32    empty
>> [    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]
> 
> The memory hole is at the beginning of zone NORMAL?  If so, should zone

No, the memory hole range is 0x1000000000 - 0x1800000000, and the normal 
zone is start from 0x100000000.

I'm sorry I made a typo in the commit message, which confuses you. The 
memory hole range should be: 0x1000000000 - 0x1800000000. I updated the 
commit message to the following and addressed David's comment:

"
Just like commit 9721fd82351d ("mm: compaction: skip memory hole rapidly
when isolating migratable pages"), I can see it will also take more
time to skip the larger memory hole (range: 0x1000000000 - 0x1800000000)
when isolating free pages on my machine with below memory layout. So 
like commit 9721fd82351d, adding a new helper to skip the memory hole 
rapidly, which can reduce the time consumed from about 70us to less than 
1us.

[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
[    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
[    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
[    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
[    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
[    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
[    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
[    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
[    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
[    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]
"

> NORMAL start at 0x1800000000?  And, the free pages will not be scanned
> there?  Or my understanding were wrong. >
>> [    0.000000] Movable zone start for each node
>> [    0.000000] Early memory node ranges
>> [    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
>> [    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
>> [    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
>> [    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
>> [    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
>> [    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
>> [    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
>> [    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
>> [    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
>> [    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]
>>
>> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
>> ---
>>   mm/compaction.c | 30 +++++++++++++++++++++++++++++-
>>   1 file changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/compaction.c b/mm/compaction.c
>> index 43358efdbdc2..9641e2131901 100644
>> --- a/mm/compaction.c
>> +++ b/mm/compaction.c
>> @@ -249,11 +249,31 @@ static unsigned long skip_offline_sections(unsigned long start_pfn)
>>   
>>   	return 0;
>>   }
>> +
>> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
>> +{
>> +	unsigned long start_nr = pfn_to_section_nr(start_pfn);
>> +
>> +	if (!start_nr || online_section_nr(start_nr))
>> +		return 0;
>> +
>> +	while (start_nr-- > 0) {
>> +		if (online_section_nr(start_nr))
>> +			return section_nr_to_pfn(start_nr) + PAGES_PER_SECTION - 1;
>> +	}
>> +
>> +	return 0;
>> +}
>>   #else
>>   static unsigned long skip_offline_sections(unsigned long start_pfn)
>>   {
>>   	return 0;
>>   }
>> +
>> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
>> +{
>> +	return 0;
>> +}
>>   #endif
>>   
>>   /*
>> @@ -1668,8 +1688,16 @@ static void isolate_freepages(struct compact_control *cc)
>>   
>>   		page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn,
>>   									zone);
>> -		if (!page)
>> +		if (!page) {
>> +			unsigned long next_pfn;
>> +
>> +			next_pfn = skip_offline_sections_reverse(block_start_pfn);
>> +			if (next_pfn)
>> +				block_start_pfn = max(pageblock_start_pfn(next_pfn),
>> +						      low_pfn);
>> +
>>   			continue;
>> +		}
>>   
>>   		/* Check the block is suitable for migration */
>>   		if (!suitable_migration_target(cc, page))

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

* Re: [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating free pages
  2023-07-10  9:26     ` Baolin Wang
@ 2023-07-11  0:37       ` Huang, Ying
  0 siblings, 0 replies; 7+ messages in thread
From: Huang, Ying @ 2023-07-11  0:37 UTC (permalink / raw)
  To: Baolin Wang; +Cc: akpm, mgorman, vbabka, david, linux-mm, linux-kernel

Baolin Wang <baolin.wang@linux.alibaba.com> writes:

> On 7/10/2023 2:11 PM, Huang, Ying wrote:
>> Baolin Wang <baolin.wang@linux.alibaba.com> writes:
>> 
>>> On my machine with below memory layout, and I can see it will take more
>>> time to skip the larger memory hole (range: 0x100000000 - 0x1800000000)
>>> when isolating free pages. So adding a new helper to skip the memory
>>> hole rapidly, which can reduce the time consumed from about 70us to less
>>> than 1us.
>>>
>>> [    0.000000] Zone ranges:
>>> [    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
>>> [    0.000000]   DMA32    empty
>>> [    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]
>> The memory hole is at the beginning of zone NORMAL?  If so, should
>> zone
>
> No, the memory hole range is 0x1000000000 - 0x1800000000, and the
> normal zone is start from 0x100000000.
>
> I'm sorry I made a typo in the commit message, which confuses you. The
> memory hole range should be: 0x1000000000 - 0x1800000000. I updated
> the commit message to the following and addressed David's comment:

Got it!  Thanks for explanation!

> "
> Just like commit 9721fd82351d ("mm: compaction: skip memory hole rapidly
> when isolating migratable pages"), I can see it will also take more
> time to skip the larger memory hole (range: 0x1000000000 - 0x1800000000)
> when isolating free pages on my machine with below memory layout. So
> like commit 9721fd82351d, adding a new helper to skip the memory hole
> rapidly, which can reduce the time consumed from about 70us to less
> than 1us.

LGTM.

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

> [    0.000000] Zone ranges:
> [    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
> [    0.000000]   DMA32    empty
> [    0.000000]   Normal   [mem 0x0000000100000000-0x0000001fa7ffffff]
> [    0.000000] Movable zone start for each node
> [    0.000000] Early memory node ranges
> [    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
> [    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
> [    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
> [    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
> [    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
> [    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
> [    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
> [    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]
> "
>
>> NORMAL start at 0x1800000000?  And, the free pages will not be scanned
>> there?  Or my understanding were wrong. >
>>> [    0.000000] Movable zone start for each node
>>> [    0.000000] Early memory node ranges
>>> [    0.000000]   node   0: [mem 0x0000000040000000-0x0000000fffffffff]
>>> [    0.000000]   node   0: [mem 0x0000001800000000-0x0000001fa3c7ffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa3c80000-0x0000001fa3ffffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa4000000-0x0000001fa402ffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa4030000-0x0000001fa40effff]
>>> [    0.000000]   node   0: [mem 0x0000001fa40f0000-0x0000001fa73cffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa73d0000-0x0000001fa745ffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa7460000-0x0000001fa746ffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa7470000-0x0000001fa758ffff]
>>> [    0.000000]   node   0: [mem 0x0000001fa7590000-0x0000001fa7ffffff]
>>>
>>> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
>>> ---
>>>   mm/compaction.c | 30 +++++++++++++++++++++++++++++-
>>>   1 file changed, 29 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/mm/compaction.c b/mm/compaction.c
>>> index 43358efdbdc2..9641e2131901 100644
>>> --- a/mm/compaction.c
>>> +++ b/mm/compaction.c
>>> @@ -249,11 +249,31 @@ static unsigned long skip_offline_sections(unsigned long start_pfn)
>>>     	return 0;
>>>   }
>>> +
>>> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
>>> +{
>>> +	unsigned long start_nr = pfn_to_section_nr(start_pfn);
>>> +
>>> +	if (!start_nr || online_section_nr(start_nr))
>>> +		return 0;
>>> +
>>> +	while (start_nr-- > 0) {
>>> +		if (online_section_nr(start_nr))
>>> +			return section_nr_to_pfn(start_nr) + PAGES_PER_SECTION - 1;
>>> +	}
>>> +
>>> +	return 0;
>>> +}
>>>   #else
>>>   static unsigned long skip_offline_sections(unsigned long start_pfn)
>>>   {
>>>   	return 0;
>>>   }
>>> +
>>> +static unsigned long skip_offline_sections_reverse(unsigned long start_pfn)
>>> +{
>>> +	return 0;
>>> +}
>>>   #endif
>>>     /*
>>> @@ -1668,8 +1688,16 @@ static void isolate_freepages(struct compact_control *cc)
>>>     		page = pageblock_pfn_to_page(block_start_pfn,
>>> block_end_pfn,
>>>   									zone);
>>> -		if (!page)
>>> +		if (!page) {
>>> +			unsigned long next_pfn;
>>> +
>>> +			next_pfn = skip_offline_sections_reverse(block_start_pfn);
>>> +			if (next_pfn)
>>> +				block_start_pfn = max(pageblock_start_pfn(next_pfn),
>>> +						      low_pfn);
>>> +
>>>   			continue;
>>> +		}
>>>     		/* Check the block is suitable for migration */
>>>   		if (!suitable_migration_target(cc, page))

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

end of thread, other threads:[~2023-07-11  0:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-07  8:51 [PATCH 1/2] mm: compaction: use the correct type of list for free pages Baolin Wang
2023-07-07  8:51 ` [PATCH 2/2] mm: compaction: skip the memory hole rapidly when isolating " Baolin Wang
2023-07-07 11:56   ` David Hildenbrand
2023-07-10  6:11   ` Huang, Ying
2023-07-10  9:26     ` Baolin Wang
2023-07-11  0:37       ` Huang, Ying
2023-07-07 11:52 ` [PATCH 1/2] mm: compaction: use the correct type of list for " David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.