Skip to contentSkip to conversation

compaction: fix build error in CMA && !COMPACTION

PATCH In review Minchan Kim 2 participants 3 messages Dec 20, 2012 – Dec 21, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compaction: fix build error in CMA && !COMPACTION

isolate_freepages_block and isolate_migratepages_range is used for CMA as well as compaction so it breaks build for CONFIG_CMA && !CONFIG_COMPACTION.

This patch fixes it.

Cc Mel Gorman <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 mm/compaction.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
mm/compaction.c +20 -6
index 5ad7f4f..70f4443 100644
@@ -17,6 +17,21 @@
 #include <linux/balloon_compaction.h>
 #include "internal.h"
 
+#ifdef CONFIG_COMPACTION
+static inline void count_compact_event(enum vm_event_item item)
+{
+	count_vm_event(item);
+}
+
+static inline void count_compact_events(enum vm_event_item item, long delta)
+{
+	count_vm_events(item, delta);
+}
+#else
+#define count_compact_event(item)
+#define count_compact_events(item, delta)
+#endif
+
 #if defined CONFIG_COMPACTION || defined CONFIG_CMA
 
 #define CREATE_TRACE_POINTS
@@ -303,10 +318,9 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
 	if (blockpfn == end_pfn)
 		update_pageblock_skip(cc, valid_page, total_isolated, false);
 
-	count_vm_events(COMPACTFREE_SCANNED, nr_scanned);
+	count_compact_events(COMPACTFREE_SCANNED, nr_scanned);
 	if (total_isolated)
-		count_vm_events(COMPACTISOLATED, total_isolated);
-
+		count_compact_events(COMPACTISOLATED, total_isolated);
 	return total_isolated;
 }
 
@@ -613,9 +627,9 @@ next_pageblock:
 
 	trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated);
 
-	count_vm_events(COMPACTMIGRATE_SCANNED, nr_scanned);
+	count_compact_events(COMPACTMIGRATE_SCANNED, nr_scanned);
 	if (nr_isolated)
-		count_vm_events(COMPACTISOLATED, nr_isolated);
+		count_compact_events(COMPACTISOLATED, nr_isolated);
 
 	return low_pfn;
 }
@@ -1110,7 +1124,7 @@ unsigned long try_to_compact_pages(struct zonelist *zonelist,
 	if (!order || !may_enter_fs || !may_perform_io)
 		return rc;
 
-	count_vm_event(COMPACTSTALL);
+	count_compact_event(COMPACTSTALL);
 
 #ifdef CONFIG_CMA
 	if (allocflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE)
Signature · 7 lines
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 26 lines · Minchan Kim

isolate_freepages_block and isolate_migratepages_range is used for CMA as well as compaction so it breaks build for CONFIG_CMA && !CONFIG_COMPACTION.

This patch fixes it.

Cc Mel Gorman <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 mm/compaction.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
mm/compaction.c +5 -0
index 5ad7f4f..70f4443 100644
@@ -17,6 +17,21 @@
 #include <linux/balloon_compaction.h>
 #include "internal.h"
 
+#ifdef CONFIG_COMPACTION
+static inline void count_compact_event(enum vm_event_item item)
+{
+	count_vm_event(item);
+}

mm/compaction.c line 34

Quoted 10 lines
mm/compaction.c +10 -0
+
+static inline void count_compact_events(enum vm_event_item item, long delta)
+{
+	count_vm_events(item, delta);
+}
+#else
+#define count_compact_event(item)
+#define count_compact_events(item, delta)
+#endif
+

That should be

do {} while (0)

otherwise a block like this

if (foo)
count_compact_event(COMPACTFREE_SCANNED)
bar;

will get parsed as

if (foo)

	bar;

which is wrong.

Now that I look at the do {} while (0) thing it is also strictly speaking wrong for count_vm_numa_events() too because it would do the wrong thing for

count_compact_events(COMPACTFREE_SCANNED, foo++);

There happens to be no examples where we depend on such side-effects but I've taken a TODO item to fix it up in the New Year.

Signature · 8 lines
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 48 lines · Mel Gorman
Quoted 26 lines · Minchan Kim

isolate_freepages_block and isolate_migratepages_range is used for CMA as well as compaction so it breaks build for CONFIG_CMA && !CONFIG_COMPACTION.

This patch fixes it.

Cc Mel Gorman <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 mm/compaction.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
mm/compaction.c +5 -0
index 5ad7f4f..70f4443 100644
@@ -17,6 +17,21 @@
 #include <linux/balloon_compaction.h>
 #include "internal.h"
 
+#ifdef CONFIG_COMPACTION
+static inline void count_compact_event(enum vm_event_item item)
+{
+	count_vm_event(item);
+}

mm/compaction.c line 34

Quoted 10 lines
mm/compaction.c +10 -0
+
+static inline void count_compact_events(enum vm_event_item item, long delta)
+{
+	count_vm_events(item, delta);
+}
+#else
+#define count_compact_event(item)
+#define count_compact_events(item, delta)
+#endif
+

That should be

do {} while (0)

otherwise a block like this

if (foo)
count_compact_event(COMPACTFREE_SCANNED)
bar;

Quoted 6 lines

will get parsed as

if (foo)

	bar;

which is wrong.

Indeed.

Quoted 3 lines

Now that I look at the do {} while (0) thing it is also strictly speaking wrong for count_vm_numa_events() too because it would do the wrong thing for

If I noticed it, I should named it as count_vm_compact_events for the consistency.

Quoted 4 lines

count_compact_events(COMPACTFREE_SCANNED, foo++);

There happens to be no examples where we depend on such side-effects but

Agreed.

Quoted 1 line

I've taken a TODO item to fix it up in the New Year.

Andrew picked up the patch with your fix. Please correct it for New Year's present. :)

Thanks, Mel.

Quoted 10 lines
Signature · 9 lines
-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards,
Minchan Kim

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