Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1500076 > unrolled thread

[RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation

Started byjs1304@gmail.com
First post2016-10-13 10:10 +0200
Last post2016-10-26 06:50 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation js1304@gmail.com - 2016-10-13 10:10 +0200
    Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first  in movable allocation Vlastimil Babka <vbabka@suse.cz> - 2016-10-13 11:20 +0200
      Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first  in movable allocation Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-10-14 03:30 +0200
        Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first  in movable allocation Vlastimil Babka <vbabka@suse.cz> - 2016-10-14 13:00 +0200
          Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first  in movable allocation Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-10-26 06:50 +0200

#1500076 — [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation

Fromjs1304@gmail.com
Date2016-10-13 10:10 +0200
Subject[RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation
Message-ID<srJfr-Vf-1@gated-at.bofh.it>
From: Joonsoo Kim <iamjoonsoo.kim@lge.com>

When we try to find freepage in fallback buddy list, we always serach
the largest one. This would help for fragmentation if we process
unmovable/reclaimable allocation request because it could cause permanent
fragmentation on movable pageblock and spread out such allocations would
cause more fragmentation. But, movable allocation request is
rather different. It would be simply freed or migrated so it doesn't
contribute to fragmentation on the other pageblock. In this case, it would
be better not to break the precious highest order freepage so we need to
search the smallest freepage first.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/page_alloc.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c4f7d05..70427bf 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2121,15 +2121,31 @@ static void unreserve_highatomic_pageblock(const struct alloc_context *ac)
 	int fallback_mt;
 	bool can_steal;
 
-	/* Find the largest possible block of pages in the other list */
-	for (current_order = MAX_ORDER-1;
-				current_order >= order && current_order <= MAX_ORDER-1;
-				--current_order) {
+	if (start_migratetype == MIGRATE_MOVABLE)
+		current_order = order;
+	else
+		current_order = MAX_ORDER - 1;
+
+	/*
+	 * Find the appropriate block of pages in the other list.
+	 * If start_migratetype is MIGRATE_UNMOVABLE/MIGRATE_RECLAIMABLE,
+	 * it would be better to find largest pageblock since it could cause
+	 * fragmentation. However, in case of MIGRATE_MOVABLE, there is no
+	 * risk about fragmentation so it would be better to use smallest one.
+	 */
+	while (current_order >= order && current_order <= MAX_ORDER - 1) {
+
 		area = &(zone->free_area[current_order]);
 		fallback_mt = find_suitable_fallback(area, current_order,
 				start_migratetype, false, &can_steal);
-		if (fallback_mt == -1)
+		if (fallback_mt == -1) {
+			if (start_migratetype == MIGRATE_MOVABLE)
+				current_order++;
+			else
+				current_order--;
+
 			continue;
+		}
 
 		page = list_first_entry(&area->free_list[fallback_mt],
 						struct page, lru);
-- 
1.9.1

[toc] | [next] | [standalone]


#1500117 — Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation

FromVlastimil Babka <vbabka@suse.cz>
Date2016-10-13 11:20 +0200
SubjectRe: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation
Message-ID<srKlc-1y8-7@gated-at.bofh.it>
In reply to#1500076
On 10/13/2016 10:08 AM, js1304@gmail.com wrote:
> From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> When we try to find freepage in fallback buddy list, we always serach
> the largest one. This would help for fragmentation if we process
> unmovable/reclaimable allocation request because it could cause permanent
> fragmentation on movable pageblock and spread out such allocations would
> cause more fragmentation. But, movable allocation request is
> rather different. It would be simply freed or migrated so it doesn't
> contribute to fragmentation on the other pageblock. In this case, it would
> be better not to break the precious highest order freepage so we need to
> search the smallest freepage first.

I've also pondered this, but then found a lower hanging fruit that 
should be hopefully clear win and mitigate most cases of breaking 
high-order pages unnecessarily:

http://marc.info/?l=linux-mm&m=147582914330198&w=2

So I would try that first, and then test your patch on top? In your 
patch there's a risk that we make it harder for unmovable/reclaimable 
pageblocks to become movable again (we start with the smallest page 
which means there's lower chance that move_freepages_block() will 
convert more than half of the block). And Johannes's report seems to be 
about a regression in exactly this aspect of the heuristics.

> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  mm/page_alloc.c | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index c4f7d05..70427bf 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2121,15 +2121,31 @@ static void unreserve_highatomic_pageblock(const struct alloc_context *ac)
>  	int fallback_mt;
>  	bool can_steal;
>
> -	/* Find the largest possible block of pages in the other list */
> -	for (current_order = MAX_ORDER-1;
> -				current_order >= order && current_order <= MAX_ORDER-1;
> -				--current_order) {
> +	if (start_migratetype == MIGRATE_MOVABLE)
> +		current_order = order;
> +	else
> +		current_order = MAX_ORDER - 1;
> +
> +	/*
> +	 * Find the appropriate block of pages in the other list.
> +	 * If start_migratetype is MIGRATE_UNMOVABLE/MIGRATE_RECLAIMABLE,
> +	 * it would be better to find largest pageblock since it could cause
> +	 * fragmentation. However, in case of MIGRATE_MOVABLE, there is no
> +	 * risk about fragmentation so it would be better to use smallest one.
> +	 */
> +	while (current_order >= order && current_order <= MAX_ORDER - 1) {
> +
>  		area = &(zone->free_area[current_order]);
>  		fallback_mt = find_suitable_fallback(area, current_order,
>  				start_migratetype, false, &can_steal);
> -		if (fallback_mt == -1)
> +		if (fallback_mt == -1) {
> +			if (start_migratetype == MIGRATE_MOVABLE)
> +				current_order++;
> +			else
> +				current_order--;
> +
>  			continue;
> +		}
>
>  		page = list_first_entry(&area->free_list[fallback_mt],
>  						struct page, lru);
>

[toc] | [prev] | [next] | [standalone]


#1500662 — Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation

FromJoonsoo Kim <iamjoonsoo.kim@lge.com>
Date2016-10-14 03:30 +0200
SubjectRe: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation
Message-ID<srZtT-2Sz-1@gated-at.bofh.it>
In reply to#1500117
On Thu, Oct 13, 2016 at 11:12:10AM +0200, Vlastimil Babka wrote:
> On 10/13/2016 10:08 AM, js1304@gmail.com wrote:
> >From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> >When we try to find freepage in fallback buddy list, we always serach
> >the largest one. This would help for fragmentation if we process
> >unmovable/reclaimable allocation request because it could cause permanent
> >fragmentation on movable pageblock and spread out such allocations would
> >cause more fragmentation. But, movable allocation request is
> >rather different. It would be simply freed or migrated so it doesn't
> >contribute to fragmentation on the other pageblock. In this case, it would
> >be better not to break the precious highest order freepage so we need to
> >search the smallest freepage first.
> 
> I've also pondered this, but then found a lower hanging fruit that
> should be hopefully clear win and mitigate most cases of breaking
> high-order pages unnecessarily:
> 
> http://marc.info/?l=linux-mm&m=147582914330198&w=2

Yes, I agree with that change. That's the similar patch what I tried
before.

"mm/page_alloc: don't break highest order freepage if steal"
http://marc.info/?l=linux-mm&m=143011930520417&w=2

> 
> So I would try that first, and then test your patch on top? In your
> patch there's a risk that we make it harder for
> unmovable/reclaimable pageblocks to become movable again (we start
> with the smallest page which means there's lower chance that
> move_freepages_block() will convert more than half of the block).

Indeed, but, with your "count movable pages when stealing", risk would
disappear. :)

> And Johannes's report seems to be about a regression in exactly this
> aspect of the heuristics.

Even if your change slows down the breaking high order freepage, but,
it would provide just a small delay to break. High order freepage
would be broken soon and we cannot prevent to decrease high order
freepage in the system. With my approach, high order freepage would
stay longer time.

For Johannes case, my approach doesn't aim at recovering from that
situation. Instead, it tries to prevent such situation that
migratetype of pageblock is changed.

Thanks.

[toc] | [prev] | [next] | [standalone]


#1500828 — Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation

FromVlastimil Babka <vbabka@suse.cz>
Date2016-10-14 13:00 +0200
SubjectRe: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation
Message-ID<ss8nv-dl-3@gated-at.bofh.it>
In reply to#1500662
On 10/14/2016 03:26 AM, Joonsoo Kim wrote:
> On Thu, Oct 13, 2016 at 11:12:10AM +0200, Vlastimil Babka wrote:
>> On 10/13/2016 10:08 AM, js1304@gmail.com wrote:
>> >From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>> >
>> >When we try to find freepage in fallback buddy list, we always serach
>> >the largest one. This would help for fragmentation if we process
>> >unmovable/reclaimable allocation request because it could cause permanent
>> >fragmentation on movable pageblock and spread out such allocations would
>> >cause more fragmentation. But, movable allocation request is
>> >rather different. It would be simply freed or migrated so it doesn't
>> >contribute to fragmentation on the other pageblock. In this case, it would
>> >be better not to break the precious highest order freepage so we need to
>> >search the smallest freepage first.
>>
>> I've also pondered this, but then found a lower hanging fruit that
>> should be hopefully clear win and mitigate most cases of breaking
>> high-order pages unnecessarily:
>>
>> http://marc.info/?l=linux-mm&m=147582914330198&w=2
>
> Yes, I agree with that change. That's the similar patch what I tried
> before.
>
> "mm/page_alloc: don't break highest order freepage if steal"
> http://marc.info/?l=linux-mm&m=143011930520417&w=2

Ah, indeed, I forgot about it and had to rediscover :)

>
>>
>> So I would try that first, and then test your patch on top? In your
>> patch there's a risk that we make it harder for
>> unmovable/reclaimable pageblocks to become movable again (we start
>> with the smallest page which means there's lower chance that
>> move_freepages_block() will convert more than half of the block).
>
> Indeed, but, with your "count movable pages when stealing", risk would
> disappear. :)

Hmm, but that counting is only triggered when we attempt to steal whole 
pageblock. For movable allocation, can_steal_fallback() allows that only for
(order >= pageblock_order / 2), and since your patch makes "order" as small as 
possible for movable allocations, the chances are lower?

>> And Johannes's report seems to be about a regression in exactly this
>> aspect of the heuristics.
>
> Even if your change slows down the breaking high order freepage, but,
> it would provide just a small delay to break. High order freepage
> would be broken soon and we cannot prevent to decrease high order
> freepage in the system. With my approach, high order freepage would
> stay longer time.
>
> For Johannes case, my approach doesn't aim at recovering from that
> situation. Instead, it tries to prevent such situation that
> migratetype of pageblock is changed.
>
> Thanks.
>

[toc] | [prev] | [next] | [standalone]


#1508788 — Re: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation

FromJoonsoo Kim <iamjoonsoo.kim@lge.com>
Date2016-10-26 06:50 +0200
SubjectRe: [RFC PATCH 2/5] mm/page_alloc: use smallest fallback page first in movable allocation
Message-ID<swok1-79z-17@gated-at.bofh.it>
In reply to#1500828
On Fri, Oct 14, 2016 at 12:52:26PM +0200, Vlastimil Babka wrote:
> On 10/14/2016 03:26 AM, Joonsoo Kim wrote:
> >On Thu, Oct 13, 2016 at 11:12:10AM +0200, Vlastimil Babka wrote:
> >>On 10/13/2016 10:08 AM, js1304@gmail.com wrote:
> >>>From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >>>
> >>>When we try to find freepage in fallback buddy list, we always serach
> >>>the largest one. This would help for fragmentation if we process
> >>>unmovable/reclaimable allocation request because it could cause permanent
> >>>fragmentation on movable pageblock and spread out such allocations would
> >>>cause more fragmentation. But, movable allocation request is
> >>>rather different. It would be simply freed or migrated so it doesn't
> >>>contribute to fragmentation on the other pageblock. In this case, it would
> >>>be better not to break the precious highest order freepage so we need to
> >>>search the smallest freepage first.
> >>
> >>I've also pondered this, but then found a lower hanging fruit that
> >>should be hopefully clear win and mitigate most cases of breaking
> >>high-order pages unnecessarily:
> >>
> >>http://marc.info/?l=linux-mm&m=147582914330198&w=2
> >
> >Yes, I agree with that change. That's the similar patch what I tried
> >before.
> >
> >"mm/page_alloc: don't break highest order freepage if steal"
> >http://marc.info/?l=linux-mm&m=143011930520417&w=2
> 
> Ah, indeed, I forgot about it and had to rediscover :)
> 
> >
> >>
> >>So I would try that first, and then test your patch on top? In your
> >>patch there's a risk that we make it harder for
> >>unmovable/reclaimable pageblocks to become movable again (we start
> >>with the smallest page which means there's lower chance that
> >>move_freepages_block() will convert more than half of the block).
> >
> >Indeed, but, with your "count movable pages when stealing", risk would
> >disappear. :)
> 
> Hmm, but that counting is only triggered when we attempt to steal
> whole pageblock. For movable allocation, can_steal_fallback() allows
> that only for
> (order >= pageblock_order / 2), and since your patch makes "order"
> as small as possible for movable allocations, the chances are lower?

Chances are lower than current but we eventually try to steal that
(order >= pageblock_order / 2) freepage from unmovable pageblock and
your logic will result in changing pageblock migratetype from
unmovable to movable.

Thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web