* [PATCH] mm: fix special case -1 order check in compact_finished
@ 2011-05-30 12:38 Michal Hocko
2011-05-30 12:53 ` Mel Gorman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michal Hocko @ 2011-05-30 12:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: Mel Gorman, linux-mm, LKML
56de7263 (mm: compaction: direct compact when a high-order allocation
fails) introduced a check for cc->order == -1 in compact_finished. We
should continue compacting in that case because the request came from
userspace and there is no particular order to compact for.
The check is, however, done after zone_watermark_ok which uses order as
a right hand argument for shifts. Not only watermark check is pointless
if we can break out without it but it also uses 1 << -1 which is not
well defined (at least from C standard). Let's move the -1 check above
zone_watermark_ok.
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Cc: Mel Gorman <mgorman@suse.de>
---
compaction.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: linus_tree/mm/compaction.c
===================================================================
--- linus_tree.orig/mm/compaction.c 2011-05-30 14:19:58.000000000 +0200
+++ linus_tree/mm/compaction.c 2011-05-30 14:20:40.000000000 +0200
@@ -420,13 +420,6 @@ static int compact_finished(struct zone
if (cc->free_pfn <= cc->migrate_pfn)
return COMPACT_COMPLETE;
- /* Compaction run is not finished if the watermark is not met */
- watermark = low_wmark_pages(zone);
- watermark += (1 << cc->order);
-
- if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
- return COMPACT_CONTINUE;
-
/*
* order == -1 is expected when compacting via
* /proc/sys/vm/compact_memory
@@ -434,6 +427,13 @@ static int compact_finished(struct zone
if (cc->order == -1)
return COMPACT_CONTINUE;
+ /* Compaction run is not finished if the watermark is not met */
+ watermark = low_wmark_pages(zone);
+ watermark += (1 << cc->order);
+
+ if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
+ return COMPACT_CONTINUE;
+
/* Direct compactor: Is a suitable page free? */
for (order = cc->order; order < MAX_ORDER; order++) {
/* Job done if page is free of the right migratetype */
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
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] 7+ messages in thread
* Re: [PATCH] mm: fix special case -1 order check in compact_finished
2011-05-30 12:38 [PATCH] mm: fix special case -1 order check in compact_finished Michal Hocko
@ 2011-05-30 12:53 ` Mel Gorman
2011-05-30 15:16 ` Minchan Kim
2011-05-31 4:34 ` [PATCH] mm: fix special case -1 order check in compact_finished KAMEZAWA Hiroyuki
2 siblings, 0 replies; 7+ messages in thread
From: Mel Gorman @ 2011-05-30 12:53 UTC (permalink / raw)
To: Michal Hocko; +Cc: Andrew Morton, linux-mm, LKML
On Mon, May 30, 2011 at 02:38:31PM +0200, Michal Hocko wrote:
> 56de7263 (mm: compaction: direct compact when a high-order allocation
> fails) introduced a check for cc->order == -1 in compact_finished. We
> should continue compacting in that case because the request came from
> userspace and there is no particular order to compact for.
>
> The check is, however, done after zone_watermark_ok which uses order as
> a right hand argument for shifts. Not only watermark check is pointless
> if we can break out without it but it also uses 1 << -1 which is not
> well defined (at least from C standard). Let's move the -1 check above
> zone_watermark_ok.
>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> Cc: Mel Gorman <mgorman@suse.de>
Acked-by: Mel Gorman <mgorman@suse.de>
--
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] 7+ messages in thread
* Re: [PATCH] mm: fix special case -1 order check in compact_finished
2011-05-30 12:38 [PATCH] mm: fix special case -1 order check in compact_finished Michal Hocko
2011-05-30 12:53 ` Mel Gorman
@ 2011-05-30 15:16 ` Minchan Kim
2011-05-30 15:24 ` [PATCH v2] mm: compaction: fix special case -1 order checks Michal Hocko
2011-05-31 4:34 ` [PATCH] mm: fix special case -1 order check in compact_finished KAMEZAWA Hiroyuki
2 siblings, 1 reply; 7+ messages in thread
From: Minchan Kim @ 2011-05-30 15:16 UTC (permalink / raw)
To: Michal Hocko; +Cc: Andrew Morton, Mel Gorman, linux-mm, LKML
Sorry for breaking thread.
I resend.
On Mon, May 30, 2011 at 02:38:31PM +0200, Michal Hocko wrote:
> 56de7263 (mm: compaction: direct compact when a high-order allocation
> fails) introduced a check for cc->order == -1 in compact_finished. We
> should continue compacting in that case because the request came from
> userspace and there is no particular order to compact for.
>
> The check is, however, done after zone_watermark_ok which uses order as
> a right hand argument for shifts. Not only watermark check is pointless
> if we can break out without it but it also uses 1 << -1 which is not
> well defined (at least from C standard). Let's move the -1 check above
> zone_watermark_ok.
>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> Cc: Mel Gorman <mgorman@suse.de>
> ---
> compaction.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
> Index: linus_tree/mm/compaction.c
> ===================================================================
> --- linus_tree.orig/mm/compaction.c 2011-05-30 14:19:58.000000000 +0200
> +++ linus_tree/mm/compaction.c 2011-05-30 14:20:40.000000000 +0200
> @@ -420,13 +420,6 @@ static int compact_finished(struct zone
> if (cc->free_pfn <= cc->migrate_pfn)
> return COMPACT_COMPLETE;
>
> - /* Compaction run is not finished if the watermark is not met */
> - watermark = low_wmark_pages(zone);
> - watermark += (1 << cc->order);
> -
> - if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
> - return COMPACT_CONTINUE;
> -
> /*
> * order == -1 is expected when compacting via
> * /proc/sys/vm/compact_memory
> @@ -434,6 +427,13 @@ static int compact_finished(struct zone
> if (cc->order == -1)
> return COMPACT_CONTINUE;
>
> + /* Compaction run is not finished if the watermark is not met */
> + watermark = low_wmark_pages(zone);
> + watermark += (1 << cc->order);
> +
> + if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
> + return COMPACT_CONTINUE;
> +
> /* Direct compactor: Is a suitable page free? */
> for (order = cc->order; order < MAX_ORDER; order++) {
> /* Job done if page is free of the right migratetype */
It looks good to me.
Let's think about another place, compaction_suitable.
It has same problem so we can move the check right before zone_watermark_ok.
As I look it more, I thought we need free pages for compaction so we would
be better to give up early if we can't get enough free pages. But I changed
my mind. It's a totally user request and we can get free pages in migration
progress(ex, other big memory hogger might free his big rss).
So my conclusion is that we should do *best effort* than early give up.
If you agree with me, how about resending patch with compaction_suitable fix?
> --
> Michal Hocko
> SUSE Labs
> SUSE LINUX s.r.o.
> Lihovarska 1060/12
> 190 00 Praha 9
> Czech Republic
>
> --
> 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>
--
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] 7+ messages in thread
* [PATCH v2] mm: compaction: fix special case -1 order checks
2011-05-30 15:16 ` Minchan Kim
@ 2011-05-30 15:24 ` Michal Hocko
2011-05-30 15:37 ` Minchan Kim
2011-06-02 10:38 ` Mel Gorman
0 siblings, 2 replies; 7+ messages in thread
From: Michal Hocko @ 2011-05-30 15:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: Minchan Kim, Mel Gorman, linux-mm, LKML
On Tue 31-05-11 00:16:33, Minchan Kim wrote:
> > /* Direct compactor: Is a suitable page free? */
> > for (order = cc->order; order < MAX_ORDER; order++) {
> > /* Job done if page is free of the right migratetype */
>
> It looks good to me.
> Let's think about another place, compaction_suitable.
Good spotted.
> It has same problem so we can move the check right before zone_watermark_ok.
> As I look it more, I thought we need free pages for compaction so we would
> be better to give up early if we can't get enough free pages. But I changed
> my mind. It's a totally user request and we can get free pages in migration
> progress(ex, other big memory hogger might free his big rss).
> So my conclusion is that we should do *best effort* than early give up.
Agreed
> If you agree with me, how about resending patch with compaction_suitable fix?
Here we go. Thanks
---
mm: compaction: fix special case -1 order checks
56de7263 (mm: compaction: direct compact when a high-order allocation
fails) introduced a check for cc->order == -1 in compact_finished. We
should continue compacting in that case because the request came from
userspace and there is no particular order to compact for.
Similar check has been added by 82478fb7 (mm: compaction:
prevent division-by-zero during user-requested compaction) for
compaction_suitable.
The check is, however, done after zone_watermark_ok which uses order as
a right hand argument for shifts. Not only watermark check is pointless
if we can break out without it but it also uses 1 << -1 which is not
well defined (at least from C standard). Let's move the -1 check above
zone_watermark_ok.
[Minchan Kim <minchan.kim@gmail.com> - caught compaction_suitable]
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Cc: Mel Gorman <mgorman@suse.de>
---
compaction.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: linus_tree/mm/compaction.c
===================================================================
--- linus_tree.orig/mm/compaction.c 2011-05-30 14:19:58.000000000 +0200
+++ linus_tree/mm/compaction.c 2011-05-30 17:16:02.000000000 +0200
@@ -420,13 +420,6 @@ static int compact_finished(struct zone
if (cc->free_pfn <= cc->migrate_pfn)
return COMPACT_COMPLETE;
- /* Compaction run is not finished if the watermark is not met */
- watermark = low_wmark_pages(zone);
- watermark += (1 << cc->order);
-
- if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
- return COMPACT_CONTINUE;
-
/*
* order == -1 is expected when compacting via
* /proc/sys/vm/compact_memory
@@ -434,6 +427,13 @@ static int compact_finished(struct zone
if (cc->order == -1)
return COMPACT_CONTINUE;
+ /* Compaction run is not finished if the watermark is not met */
+ watermark = low_wmark_pages(zone);
+ watermark += (1 << cc->order);
+
+ if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
+ return COMPACT_CONTINUE;
+
/* Direct compactor: Is a suitable page free? */
for (order = cc->order; order < MAX_ORDER; order++) {
/* Job done if page is free of the right migratetype */
@@ -461,6 +461,13 @@ unsigned long compaction_suitable(struct
unsigned long watermark;
/*
+ * order == -1 is expected when compacting via
+ * /proc/sys/vm/compact_memory
+ */
+ if (order == -1)
+ return COMPACT_CONTINUE;
+
+ /*
* Watermarks for order-0 must be met for compaction. Note the 2UL.
* This is because during migration, copies of pages need to be
* allocated and for a short time, the footprint is higher
@@ -470,13 +477,6 @@ unsigned long compaction_suitable(struct
return COMPACT_SKIPPED;
/*
- * order == -1 is expected when compacting via
- * /proc/sys/vm/compact_memory
- */
- if (order == -1)
- return COMPACT_CONTINUE;
-
- /*
* fragmentation index determines if allocation failures are due to
* low memory or external fragmentation
*
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
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] 7+ messages in thread
* Re: [PATCH v2] mm: compaction: fix special case -1 order checks
2011-05-30 15:24 ` [PATCH v2] mm: compaction: fix special case -1 order checks Michal Hocko
@ 2011-05-30 15:37 ` Minchan Kim
2011-06-02 10:38 ` Mel Gorman
1 sibling, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-05-30 15:37 UTC (permalink / raw)
To: Michal Hocko; +Cc: Andrew Morton, Mel Gorman, linux-mm, LKML
On Mon, May 30, 2011 at 05:24:50PM +0200, Michal Hocko wrote:
> On Tue 31-05-11 00:16:33, Minchan Kim wrote:
> > > /* Direct compactor: Is a suitable page free? */
> > > for (order = cc->order; order < MAX_ORDER; order++) {
> > > /* Job done if page is free of the right migratetype */
> >
> > It looks good to me.
> > Let's think about another place, compaction_suitable.
>
> Good spotted.
>
> > It has same problem so we can move the check right before zone_watermark_ok.
> > As I look it more, I thought we need free pages for compaction so we would
> > be better to give up early if we can't get enough free pages. But I changed
> > my mind. It's a totally user request and we can get free pages in migration
> > progress(ex, other big memory hogger might free his big rss).
> > So my conclusion is that we should do *best effort* than early give up.
>
> Agreed
>
> > If you agree with me, how about resending patch with compaction_suitable fix?
>
> Here we go. Thanks
>
> ---
> mm: compaction: fix special case -1 order checks
>
> 56de7263 (mm: compaction: direct compact when a high-order allocation
> fails) introduced a check for cc->order == -1 in compact_finished. We
> should continue compacting in that case because the request came from
> userspace and there is no particular order to compact for.
> Similar check has been added by 82478fb7 (mm: compaction:
> prevent division-by-zero during user-requested compaction) for
> compaction_suitable.
>
> The check is, however, done after zone_watermark_ok which uses order as
> a right hand argument for shifts. Not only watermark check is pointless
> if we can break out without it but it also uses 1 << -1 which is not
> well defined (at least from C standard). Let's move the -1 check above
> zone_watermark_ok.
>
> [Minchan Kim <minchan.kim@gmail.com> - caught compaction_suitable]
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Thanks.
--
Kind regards
Minchan Kim
--
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] 7+ messages in thread
* Re: [PATCH] mm: fix special case -1 order check in compact_finished
2011-05-30 12:38 [PATCH] mm: fix special case -1 order check in compact_finished Michal Hocko
2011-05-30 12:53 ` Mel Gorman
2011-05-30 15:16 ` Minchan Kim
@ 2011-05-31 4:34 ` KAMEZAWA Hiroyuki
2 siblings, 0 replies; 7+ messages in thread
From: KAMEZAWA Hiroyuki @ 2011-05-31 4:34 UTC (permalink / raw)
To: Michal Hocko; +Cc: Andrew Morton, Mel Gorman, linux-mm, LKML
On Mon, 30 May 2011 14:38:31 +0200
Michal Hocko <mhocko@suse.cz> wrote:
> 56de7263 (mm: compaction: direct compact when a high-order allocation
> fails) introduced a check for cc->order == -1 in compact_finished. We
> should continue compacting in that case because the request came from
> userspace and there is no particular order to compact for.
>
> The check is, however, done after zone_watermark_ok which uses order as
> a right hand argument for shifts. Not only watermark check is pointless
> if we can break out without it but it also uses 1 << -1 which is not
> well defined (at least from C standard). Let's move the -1 check above
> zone_watermark_ok.
>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> Cc: Mel Gorman <mgorman@suse.de>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hioryu@jp.fujitsu.com>
--
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] 7+ messages in thread
* Re: [PATCH v2] mm: compaction: fix special case -1 order checks
2011-05-30 15:24 ` [PATCH v2] mm: compaction: fix special case -1 order checks Michal Hocko
2011-05-30 15:37 ` Minchan Kim
@ 2011-06-02 10:38 ` Mel Gorman
1 sibling, 0 replies; 7+ messages in thread
From: Mel Gorman @ 2011-06-02 10:38 UTC (permalink / raw)
To: Michal Hocko; +Cc: Andrew Morton, Minchan Kim, linux-mm, LKML
On Mon, May 30, 2011 at 05:24:50PM +0200, Michal Hocko wrote:
> <SNIP>
> mm: compaction: fix special case -1 order checks
>
> 56de7263 (mm: compaction: direct compact when a high-order allocation
> fails) introduced a check for cc->order == -1 in compact_finished. We
> should continue compacting in that case because the request came from
> userspace and there is no particular order to compact for.
> Similar check has been added by 82478fb7 (mm: compaction:
> prevent division-by-zero during user-requested compaction) for
> compaction_suitable.
>
> The check is, however, done after zone_watermark_ok which uses order as
> a right hand argument for shifts. Not only watermark check is pointless
> if we can break out without it but it also uses 1 << -1 which is not
> well defined (at least from C standard). Let's move the -1 check above
> zone_watermark_ok.
>
> [Minchan Kim <minchan.kim@gmail.com> - caught compaction_suitable]
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> Cc: Mel Gorman <mgorman@suse.de>
Acked-by: Mel Gorman <mgorman@suse.de>
--
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] 7+ messages in thread
end of thread, other threads:[~2011-06-02 10:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-30 12:38 [PATCH] mm: fix special case -1 order check in compact_finished Michal Hocko
2011-05-30 12:53 ` Mel Gorman
2011-05-30 15:16 ` Minchan Kim
2011-05-30 15:24 ` [PATCH v2] mm: compaction: fix special case -1 order checks Michal Hocko
2011-05-30 15:37 ` Minchan Kim
2011-06-02 10:38 ` Mel Gorman
2011-05-31 4:34 ` [PATCH] mm: fix special case -1 order check in compact_finished KAMEZAWA Hiroyuki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox