All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
       [not found] <719282122.1183240.1486298780546.ref@mail.yahoo.com>
@ 2017-02-05 12:46 ` Shantanu Goel
  2017-02-06  3:19   ` Hillf Danton
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Shantanu Goel @ 2017-02-05 12:46 UTC (permalink / raw)
  To: linux-mm

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

Hi,

On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep() requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from /proc/vmstat looked this way after a day and a half of uptime:

compact_migrate_scanned 240496
compact_free_scanned 76238632
compact_isolated 123472
compact_stall 1791
compact_fail 29
compact_success 1762
compact_daemon_wake 0


After applying the patch and about 10 hours of uptime the state looks like this:

compact_migrate_scanned 59927299
compact_free_scanned 2021075136
compact_isolated 640926
compact_stall 4
compact_fail 2
compact_success 2
compact_daemon_wake 5160


Thanks,
Shantanu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-vmscan-match-zone-balance-check-in-prepare_kswapd_sl.patch --]
[-- Type: text/x-patch, Size: 1250 bytes --]

From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
From: Shantanu Goel <sgoel01@yahoo.com>
Date: Sat, 4 Feb 2017 19:07:53 -0500
Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep

The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
since the latter will return as soon as any one of the zones in the
classzone is above the watermark.  This is specially important for
higher order allocations since balance_pgdat will typically reset
the order to zero relying on compaction to create the higher order
pages.  Without this patch, prepare_kswapd_sleep fails to wake up
kcompactd since the zone balance check fails.

Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
---
 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7682469..11899ff 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3142,11 +3142,11 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx)
 		if (!managed_zone(zone))
 			continue;
 
-		if (!zone_balanced(zone, order, classzone_idx))
-			return false;
+		if (zone_balanced(zone, order, classzone_idx))
+			return true;
 	}
 
-	return true;
+	return false;
 }
 
 /*
-- 
2.7.4


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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-05 12:46 ` [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep Shantanu Goel
@ 2017-02-06  3:19   ` Hillf Danton
  2017-02-06  8:31   ` Michal Hocko
  2017-02-06 16:17   ` Mel Gorman
  2 siblings, 0 replies; 10+ messages in thread
From: Hillf Danton @ 2017-02-06  3:19 UTC (permalink / raw)
  To: 'Shantanu Goel', linux-mm

On February 05, 2017 8:46 PM Shantanu Goel wrote: 
> 
> Hi,
> 
Would you please reformat your patch and redeliver it after taking a look at 
files like 
	linux-4.9/Documentation/SubmitChecklist
	linux-4.9/Documentation/SubmittingPatches 

thanks
Hillf

> On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and
> prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep()
> requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and
> consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from
> /proc/vmstat looked this way after a day and a half of uptime:
> 
> compact_migrate_scanned 240496
> compact_free_scanned 76238632
> compact_isolated 123472
> compact_stall 1791
> compact_fail 29
> compact_success 1762
> compact_daemon_wake 0
> 
> 
> After applying the patch and about 10 hours of uptime the state looks like this:
> 
> compact_migrate_scanned 59927299
> compact_free_scanned 2021075136
> compact_isolated 640926
> compact_stall 4
> compact_fail 2
> compact_success 2
> compact_daemon_wake 5160
> 
> 
> Thanks,
> Shantanu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-05 12:46 ` [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep Shantanu Goel
  2017-02-06  3:19   ` Hillf Danton
@ 2017-02-06  8:31   ` Michal Hocko
  2017-02-06 11:51     ` Vlastimil Babka
  2017-02-06 16:17   ` Mel Gorman
  2 siblings, 1 reply; 10+ messages in thread
From: Michal Hocko @ 2017-02-06  8:31 UTC (permalink / raw)
  To: Shantanu Goel; +Cc: linux-mm, Vlastimil Babka

[CC Vlastimil]

On Sun 05-02-17 12:46:20, Shantanu Goel wrote:
> Hi,
> 
> On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep() requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from /proc/vmstat looked this way after a day and a half of uptime:
> 
> compact_migrate_scanned 240496
> compact_free_scanned 76238632
> compact_isolated 123472
> compact_stall 1791
> compact_fail 29
> compact_success 1762
> compact_daemon_wake 0
> 
> 
> After applying the patch and about 10 hours of uptime the state looks like this:
> 
> compact_migrate_scanned 59927299
> compact_free_scanned 2021075136
> compact_isolated 640926
> compact_stall 4
> compact_fail 2
> compact_success 2
> compact_daemon_wake 5160
> 
> 
> Thanks,
> Shantanu

> From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
> From: Shantanu Goel <sgoel01@yahoo.com>
> Date: Sat, 4 Feb 2017 19:07:53 -0500
> Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
> 
> The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
> since the latter will return as soon as any one of the zones in the
> classzone is above the watermark.  This is specially important for
> higher order allocations since balance_pgdat will typically reset
> the order to zero relying on compaction to create the higher order
> pages.  Without this patch, prepare_kswapd_sleep fails to wake up
> kcompactd since the zone balance check fails.
> 
> Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
> ---
>  mm/vmscan.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 7682469..11899ff 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3142,11 +3142,11 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx)
>  		if (!managed_zone(zone))
>  			continue;
>  
> -		if (!zone_balanced(zone, order, classzone_idx))
> -			return false;
> +		if (zone_balanced(zone, order, classzone_idx))
> +			return true;
>  	}
>  
> -	return true;
> +	return false;
>  }
>  
>  /*
> -- 
> 2.7.4
> 


-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-06  8:31   ` Michal Hocko
@ 2017-02-06 11:51     ` Vlastimil Babka
  0 siblings, 0 replies; 10+ messages in thread
From: Vlastimil Babka @ 2017-02-06 11:51 UTC (permalink / raw)
  To: Michal Hocko, Shantanu Goel; +Cc: linux-mm, Mel Gorman

On 02/06/2017 09:31 AM, Michal Hocko wrote:
> [CC Vlastimil]

Hmm, we should rather add Mel as this is due to his patches.

> On Sun 05-02-17 12:46:20, Shantanu Goel wrote:
>> Hi,
>>
>> On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep() requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from /proc/vmstat looked this way after a day and a half of uptime:
>>
>> compact_migrate_scanned 240496
>> compact_free_scanned 76238632
>> compact_isolated 123472
>> compact_stall 1791
>> compact_fail 29
>> compact_success 1762
>> compact_daemon_wake 0
>>
>>
>> After applying the patch and about 10 hours of uptime the state looks like this:
>>
>> compact_migrate_scanned 59927299
>> compact_free_scanned 2021075136
>> compact_isolated 640926
>> compact_stall 4
>> compact_fail 2
>> compact_success 2
>> compact_daemon_wake 5160
>>
>>
>> Thanks,
>> Shantanu
> 
>> From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
>> From: Shantanu Goel <sgoel01@yahoo.com>
>> Date: Sat, 4 Feb 2017 19:07:53 -0500
>> Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
>>
>> The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
>> since the latter will return as soon as any one of the zones in the
>> classzone is above the watermark.

This seems to be since commit 86c79f6b5426ce ("mm: vmscan: do not
reclaim from kswapd if there is any eligible zone")

>  This is specially important for
>> higher order allocations since balance_pgdat will typically reset
>> the order to zero relying on compaction to create the higher order
>> pages.  Without this patch, prepare_kswapd_sleep fails to wake up
>> kcompactd since the zone balance check fails.
>>
>> Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
>> ---
>>  mm/vmscan.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 7682469..11899ff 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -3142,11 +3142,11 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx)
>>  		if (!managed_zone(zone))
>>  			continue;
>>  
>> -		if (!zone_balanced(zone, order, classzone_idx))
>> -			return false;
>> +		if (zone_balanced(zone, order, classzone_idx))
>> +			return true;
>>  	}
>>  
>> -	return true;
>> +	return false;

Looks like this restores the logic that was changed by 38087d9b03609
("mm, vmscan: simplify the logic deciding whether kswapd sleeps").
Probably from the same node reclaim series than the commit above.
I'm not sure if this part of commit 38087d9b03609 was intentional
though, as changelog doesn't mention it, and it wasn't there until the
last, v9, posting. In that light the fix looks like the right thing to
do, but maybe Mel can remember what was behind this...

>>  }
>>  
>>  /*
>> -- 
>> 2.7.4
>>
> 
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-05 12:46 ` [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep Shantanu Goel
  2017-02-06  3:19   ` Hillf Danton
  2017-02-06  8:31   ` Michal Hocko
@ 2017-02-06 16:17   ` Mel Gorman
  2017-02-06 17:43     ` Vlastimil Babka
  2017-02-07  0:16     ` Shantanu Goel
  2 siblings, 2 replies; 10+ messages in thread
From: Mel Gorman @ 2017-02-06 16:17 UTC (permalink / raw)
  To: Shantanu Goel; +Cc: linux-mm

On Sun, Feb 05, 2017 at 12:46:20PM +0000, Shantanu Goel wrote:
> 
> On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep() requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from /proc/vmstat looked this way after a day and a half of uptime:
> 
> compact_migrate_scanned 240496
> compact_free_scanned 76238632
> compact_isolated 123472
> compact_stall 1791
> compact_fail 29
> compact_success 1762
> compact_daemon_wake 0
> 
> 
> After applying the patch and about 10 hours of uptime the state looks like this:
> 
> compact_migrate_scanned 59927299
> compact_free_scanned 2021075136
> compact_isolated 640926
> compact_stall 4
> compact_fail 2
> compact_success 2
> compact_daemon_wake 5160
> 

This should be in the changelog of the patch itself and the patch should
be inline instead of being an attachment.

> 
> Thanks,
> Shantanu

> From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
> From: Shantanu Goel <sgoel01@yahoo.com>
> Date: Sat, 4 Feb 2017 19:07:53 -0500
> Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
> 
> The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
> since the latter will return as soon as any one of the zones in the
> classzone is above the watermark.  This is specially important for
> higher order allocations since balance_pgdat will typically reset
> the order to zero relying on compaction to create the higher order
> pages.  Without this patch, prepare_kswapd_sleep fails to wake up
> kcompactd since the zone balance check fails.
> 
> Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>

I don't recall specifically why I made that change but I've no objections
to the patch so;

Acked-by: Mel Gorman <mgorman@techsingularity.net>

However, note that there is a slight risk that kswapd will sleep for a
short interval early due to a very small zone such as ZONE_DMA. If this
is a general problem then it'll manifest as less kswapd reclaim and more
direct reclaim. If it turns out this is an issue then a revert will not
be the right fix. Instead, all the checks for zone_balance will need to
account for the only balanced zone being a tiny percentage of memory in
the node.

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-06 16:17   ` Mel Gorman
@ 2017-02-06 17:43     ` Vlastimil Babka
  2017-02-06 22:24       ` Mel Gorman
  2017-02-07  0:16     ` Shantanu Goel
  1 sibling, 1 reply; 10+ messages in thread
From: Vlastimil Babka @ 2017-02-06 17:43 UTC (permalink / raw)
  To: Mel Gorman, Shantanu Goel; +Cc: linux-mm

On 02/06/2017 05:17 PM, Mel Gorman wrote:

>>
>> Thanks,
>> Shantanu
>
>> From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
>> From: Shantanu Goel <sgoel01@yahoo.com>
>> Date: Sat, 4 Feb 2017 19:07:53 -0500
>> Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
>>
>> The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
>> since the latter will return as soon as any one of the zones in the
>> classzone is above the watermark.  This is specially important for
>> higher order allocations since balance_pgdat will typically reset
>> the order to zero relying on compaction to create the higher order
>> pages.  Without this patch, prepare_kswapd_sleep fails to wake up
>> kcompactd since the zone balance check fails.
>>
>> Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
>
> I don't recall specifically why I made that change but I've no objections
> to the patch so;
>
> Acked-by: Mel Gorman <mgorman@techsingularity.net>
>
> However, note that there is a slight risk that kswapd will sleep for a
> short interval early due to a very small zone such as ZONE_DMA. If this
> is a general problem then it'll manifest as less kswapd reclaim and more
> direct reclaim. If it turns out this is an issue then a revert will not
> be the right fix. Instead, all the checks for zone_balance will need to
> account for the only balanced zone being a tiny percentage of memory in
> the node.

Hopefully the lowmem reserves should take care of this in that case? They easily 
make a low zone inaccessible even when fully free. Unless the small zone is high 
one though, such as Normal zone on system with only 4GB memory, so most of it is 
in DMA32.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-06 17:43     ` Vlastimil Babka
@ 2017-02-06 22:24       ` Mel Gorman
  0 siblings, 0 replies; 10+ messages in thread
From: Mel Gorman @ 2017-02-06 22:24 UTC (permalink / raw)
  To: Vlastimil Babka; +Cc: Shantanu Goel, linux-mm

On Mon, Feb 06, 2017 at 06:43:08PM +0100, Vlastimil Babka wrote:
> On 02/06/2017 05:17 PM, Mel Gorman wrote:
> 
> > > 
> > > Thanks,
> > > Shantanu
> > 
> > > From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
> > > From: Shantanu Goel <sgoel01@yahoo.com>
> > > Date: Sat, 4 Feb 2017 19:07:53 -0500
> > > Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
> > > 
> > > The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
> > > since the latter will return as soon as any one of the zones in the
> > > classzone is above the watermark.  This is specially important for
> > > higher order allocations since balance_pgdat will typically reset
> > > the order to zero relying on compaction to create the higher order
> > > pages.  Without this patch, prepare_kswapd_sleep fails to wake up
> > > kcompactd since the zone balance check fails.
> > > 
> > > Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
> > 
> > I don't recall specifically why I made that change but I've no objections
> > to the patch so;
> > 
> > Acked-by: Mel Gorman <mgorman@techsingularity.net>
> > 
> > However, note that there is a slight risk that kswapd will sleep for a
> > short interval early due to a very small zone such as ZONE_DMA. If this
> > is a general problem then it'll manifest as less kswapd reclaim and more
> > direct reclaim. If it turns out this is an issue then a revert will not
> > be the right fix. Instead, all the checks for zone_balance will need to
> > account for the only balanced zone being a tiny percentage of memory in
> > the node.
> 
> Hopefully the lowmem reserves should take care of this in that case? They
> easily make a low zone inaccessible even when fully free. Unless the small
> zone is high one though, such as Normal zone on system with only 4GB memory,
> so most of it is in DMA32.

More than likely, it'll be ok. It'll simply be something to check if
direct reclaim goes through the roof and it bisects to this patch for
some reason.

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-06 16:17   ` Mel Gorman
  2017-02-06 17:43     ` Vlastimil Babka
@ 2017-02-07  0:16     ` Shantanu Goel
  2017-02-07  9:54       ` Mel Gorman
  2017-02-10 13:11       ` Vlastimil Babka
  1 sibling, 2 replies; 10+ messages in thread
From: Shantanu Goel @ 2017-02-07  0:16 UTC (permalink / raw)
  To: Mel Gorman; +Cc: linux-mm

Hi,

On 02/06/2017 11:17 AM, Mel Gorman wrote:

> On Sun, Feb 05, 2017 at 12:46:20PM +0000, Shantanu Goel wrote:
>> On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep() requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from /proc/vmstat looked this way after a day and a half of uptime:
>>
>> compact_migrate_scanned 240496
>> compact_free_scanned 76238632
>> compact_isolated 123472
>> compact_stall 1791
>> compact_fail 29
>> compact_success 1762
>> compact_daemon_wake 0
>>
>>
>> After applying the patch and about 10 hours of uptime the state looks like this:
>>
>> compact_migrate_scanned 59927299
>> compact_free_scanned 2021075136
>> compact_isolated 640926
>> compact_stall 4
>> compact_fail 2
>> compact_success 2
>> compact_daemon_wake 5160
>>
> This should be in the changelog of the patch itself and the patch should
> be inline instead of being an attachment.

Will do and resubmit in a separate email.

>> Thanks,
>> Shantanu
>>  From 46f2e4b02ac263bf50d69cdab3bcbd7bcdea7415 Mon Sep 17 00:00:00 2001
>> From: Shantanu Goel <sgoel01@yahoo.com>
>> Date: Sat, 4 Feb 2017 19:07:53 -0500
>> Subject: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
>>
>> The check in prepare_kswapd_sleep needs to match the one in balance_pgdat
>> since the latter will return as soon as any one of the zones in the
>> classzone is above the watermark.  This is specially important for
>> higher order allocations since balance_pgdat will typically reset
>> the order to zero relying on compaction to create the higher order
>> pages.  Without this patch, prepare_kswapd_sleep fails to wake up
>> kcompactd since the zone balance check fails.
>>
>> Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
> I don't recall specifically why I made that change but I've no objections
> to the patch so;
>
> Acked-by: Mel Gorman <mgorman@techsingularity.net>
>
> However, note that there is a slight risk that kswapd will sleep for a
> short interval early due to a very small zone such as ZONE_DMA. If this
> is a general problem then it'll manifest as less kswapd reclaim and more
> direct reclaim. If it turns out this is an issue then a revert will not
> be the right fix. Instead, all the checks for zone_balance will need to
> account for the only balanced zone being a tiny percentage of memory in
> the node.
>

I see your point.  Perhaps we can introduce a constraint that
ensures the balanced zones constitute say 1/4 or 1/2 of
memory in the classzone?  I believe there used to be such
a constraint at one time for higher order allocations.


Thanks,
Shantanu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-07  0:16     ` Shantanu Goel
@ 2017-02-07  9:54       ` Mel Gorman
  2017-02-10 13:11       ` Vlastimil Babka
  1 sibling, 0 replies; 10+ messages in thread
From: Mel Gorman @ 2017-02-07  9:54 UTC (permalink / raw)
  To: Shantanu Goel; +Cc: linux-mm

On Mon, Feb 06, 2017 at 07:16:46PM -0500, Shantanu Goel wrote:
> > However, note that there is a slight risk that kswapd will sleep for a
> > short interval early due to a very small zone such as ZONE_DMA. If this
> > is a general problem then it'll manifest as less kswapd reclaim and more
> > direct reclaim. If it turns out this is an issue then a revert will not
> > be the right fix. Instead, all the checks for zone_balance will need to
> > account for the only balanced zone being a tiny percentage of memory in
> > the node.
> > 
> 
> I see your point.  Perhaps we can introduce a constraint that
> ensures the balanced zones constitute say 1/4 or 1/2 of
> memory in the classzone?  I believe there used to be such
> a constraint at one time for higher order allocations.
> 

There was but it was fairly complex and I'd rather avoid it if at all
possible and certainly not without data backing it up.

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep
  2017-02-07  0:16     ` Shantanu Goel
  2017-02-07  9:54       ` Mel Gorman
@ 2017-02-10 13:11       ` Vlastimil Babka
  1 sibling, 0 replies; 10+ messages in thread
From: Vlastimil Babka @ 2017-02-10 13:11 UTC (permalink / raw)
  To: Shantanu Goel, Mel Gorman; +Cc: linux-mm

On 02/07/2017 01:16 AM, Shantanu Goel wrote:
> Hi,
>
> On 02/06/2017 11:17 AM, Mel Gorman wrote:
>
>> On Sun, Feb 05, 2017 at 12:46:20PM +0000, Shantanu Goel wrote:
>>> On 4.9.7 kswapd is failing to wake up kcompactd due to a mismatch in the zone balance check between balance_pgdat() and prepare_kswapd_sleep().  balance_pgdat() returns as soon as a single zone satisfies the allocation but prepare_kswapd_sleep() requires all zones to do the same.  This causes prepare_kswapd_sleep() to never succeed except in the order == 0 case and consequently, wakeup_kcompactd() is never called.  On my machine prior to apply this patch, the state of compaction from /proc/vmstat looked this way after a day and a half of uptime:
>>>
>>> compact_migrate_scanned 240496
>>> compact_free_scanned 76238632
>>> compact_isolated 123472
>>> compact_stall 1791
>>> compact_fail 29
>>> compact_success 1762
>>> compact_daemon_wake 0
>>>
>>>
>>> After applying the patch and about 10 hours of uptime the state looks like this:
>>>
>>> compact_migrate_scanned 59927299
>>> compact_free_scanned 2021075136
>>> compact_isolated 640926
>>> compact_stall 4
>>> compact_fail 2
>>> compact_success 2
>>> compact_daemon_wake 5160

I've just seen similar results in a test, so you can add:

Tested-by: Vlastimil Babka <vbabka@suse.cz>

Thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2017-02-10 13:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <719282122.1183240.1486298780546.ref@mail.yahoo.com>
2017-02-05 12:46 ` [PATCH] vmscan: fix zone balance check in prepare_kswapd_sleep Shantanu Goel
2017-02-06  3:19   ` Hillf Danton
2017-02-06  8:31   ` Michal Hocko
2017-02-06 11:51     ` Vlastimil Babka
2017-02-06 16:17   ` Mel Gorman
2017-02-06 17:43     ` Vlastimil Babka
2017-02-06 22:24       ` Mel Gorman
2017-02-07  0:16     ` Shantanu Goel
2017-02-07  9:54       ` Mel Gorman
2017-02-10 13:11       ` Vlastimil Babka

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.