linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/compaction : check the watermark when cc->order is -1
@ 2011-12-31  6:18 Huang Shijie
  2012-01-05 10:53 ` Mel Gorman
  0 siblings, 1 reply; 3+ messages in thread
From: Huang Shijie @ 2011-12-31  6:18 UTC (permalink / raw)
  To: akpm; +Cc: mgorman, linux-mm, Huang Shijie

We get cc->order is -1 when user echos to /proc/sys/vm/compact_memory.
In this case, we should check that if we have enough pages for
the compaction in the zone.

If we do not check this, in our MX6Q board(arm), i ever observed
COMPACT_CLUSTER_MAX pages were compaction failed in per migrate_pages().
That's mean we can not alloc any pages by the free scanner in the zone.

This patch checks the watermark to avoid this problem.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 mm/compaction.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 899d956..0f12cc9 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -442,8 +442,13 @@ static int compact_finished(struct zone *zone,
 	 * order == -1 is expected when compacting via
 	 * /proc/sys/vm/compact_memory
 	 */
-	if (cc->order == -1)
+	if (cc->order == -1) {
+		/* Check if we have enough pages now. */
+		watermark = low_wmark_pages(zone) + COMPACT_CLUSTER_MAX * 2;
+		if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
+			return COMPACT_SKIPPED;
 		return COMPACT_CONTINUE;
+	}
 
 	/* Compaction run is not finished if the watermark is not met */
 	watermark = low_wmark_pages(zone);
@@ -482,8 +487,13 @@ unsigned long compaction_suitable(struct zone *zone, int order)
 	 * order == -1 is expected when compacting via
 	 * /proc/sys/vm/compact_memory
 	 */
-	if (order == -1)
+	if (order == -1) {
+		/* Check if we have enough pages now. */
+		watermark = low_wmark_pages(zone) + COMPACT_CLUSTER_MAX * 2;
+		if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
+			return COMPACT_SKIPPED;
 		return COMPACT_CONTINUE;
+	}
 
 	/*
 	 * Watermarks for order-0 must be met for compaction. Note the 2UL.
-- 
1.7.3.2


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/compaction : check the watermark when cc->order is -1
  2011-12-31  6:18 [PATCH] mm/compaction : check the watermark when cc->order is -1 Huang Shijie
@ 2012-01-05 10:53 ` Mel Gorman
  2012-01-05 11:21   ` Huang Shijie
  0 siblings, 1 reply; 3+ messages in thread
From: Mel Gorman @ 2012-01-05 10:53 UTC (permalink / raw)
  To: Huang Shijie; +Cc: akpm, linux-mm

On Sat, Dec 31, 2011 at 02:18:43PM +0800, Huang Shijie wrote:
> We get cc->order is -1 when user echos to /proc/sys/vm/compact_memory.
> In this case, we should check that if we have enough pages for
> the compaction in the zone.
> 
> If we do not check this, in our MX6Q board(arm), i ever observed
> COMPACT_CLUSTER_MAX pages were compaction failed in per migrate_pages().
> That's mean we can not alloc any pages by the free scanner in the zone.
> 
> This patch checks the watermark to avoid this problem.
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
>  mm/compaction.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 899d956..0f12cc9 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -442,8 +442,13 @@ static int compact_finished(struct zone *zone,
>  	 * order == -1 is expected when compacting via
>  	 * /proc/sys/vm/compact_memory
>  	 */
> -	if (cc->order == -1)
> +	if (cc->order == -1) {
> +		/* Check if we have enough pages now. */
> +		watermark = low_wmark_pages(zone) + COMPACT_CLUSTER_MAX * 2;
> +		if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
> +			return COMPACT_SKIPPED;
>  		return COMPACT_CONTINUE;
> +	}
>  

We already do the watermark check in compact_finished. Would moving
the cc->order == -1 check below it not be functionally equivalent? This
would be preferable to duplicating the code for the watermark check.

Same for the second check in your patch.

-- 
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/compaction : check the watermark when cc->order is -1
  2012-01-05 10:53 ` Mel Gorman
@ 2012-01-05 11:21   ` Huang Shijie
  0 siblings, 0 replies; 3+ messages in thread
From: Huang Shijie @ 2012-01-05 11:21 UTC (permalink / raw)
  To: Mel Gorman; +Cc: akpm, linux-mm


> On Sat, Dec 31, 2011 at 02:18:43PM +0800, Huang Shijie wrote:
>> We get cc->order is -1 when user echos to /proc/sys/vm/compact_memory.
>> In this case, we should check that if we have enough pages for
>> the compaction in the zone.
>>
>> If we do not check this, in our MX6Q board(arm), i ever observed
>> COMPACT_CLUSTER_MAX pages were compaction failed in per migrate_pages().
>> That's mean we can not alloc any pages by the free scanner in the zone.
>>
>> This patch checks the watermark to avoid this problem.
>>
>> Signed-off-by: Huang Shijie<b32955@freescale.com>
>> ---
>>   mm/compaction.c |   14 ++++++++++++--
>>   1 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/compaction.c b/mm/compaction.c
>> index 899d956..0f12cc9 100644
>> --- a/mm/compaction.c
>> +++ b/mm/compaction.c
>> @@ -442,8 +442,13 @@ static int compact_finished(struct zone *zone,
>>   	 * order == -1 is expected when compacting via
>>   	 * /proc/sys/vm/compact_memory
>>   	 */
>> -	if (cc->order == -1)
>> +	if (cc->order == -1) {
>> +		/* Check if we have enough pages now. */
>> +		watermark = low_wmark_pages(zone) + COMPACT_CLUSTER_MAX * 2;
>> +		if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
>> +			return COMPACT_SKIPPED;
>>   		return COMPACT_CONTINUE;
>> +	}
>>
> We already do the watermark check in compact_finished. Would moving
> the cc->order == -1 check below it not be functionally equivalent? This


Now, I think these code for compact_finish() is not needed. These lines 
can be removed.

The watermark check in the compaction_suitable() is enough to avoid the 
problem.


Huang Shijie

> would be preferable to duplicating the code for the watermark check.
>
> Same for the second check in your patch.
>


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2012-01-05 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-31  6:18 [PATCH] mm/compaction : check the watermark when cc->order is -1 Huang Shijie
2012-01-05 10:53 ` Mel Gorman
2012-01-05 11:21   ` Huang Shijie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).