mm: compaction: make compact_control order signed
authorDan Carpenter <[email protected]>
Wed, 21 Mar 2012 23:33:54 +0000 (16:33 -0700)
committerLinus Torvalds <[email protected]>
Thu, 22 Mar 2012 00:54:56 +0000 (17:54 -0700)
"order" is -1 when compacting via /proc/sys/vm/compact_memory.  Making
it unsigned causes a bug in __compact_pgdat() when we test:

if (cc->order < 0 || !compaction_deferred(zone, cc->order))
compact_zone(zone, cc);

[[email protected]: make __compact_pgdat()'s comparison match other code sites]
Signed-off-by: Dan Carpenter <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Minchan Kim <[email protected]>
Reviewed-by: Rik van Riel <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/compaction.c

index a08bf219f88c8749ab920356220dcbedbc8cfdc6..74a8c825ff289a12079701dfc42be4e1787b8d8f 100644 (file)
@@ -35,7 +35,7 @@ struct compact_control {
        unsigned long migrate_pfn;      /* isolate_migratepages search base */
        bool sync;                      /* Synchronous migration */
 
-       unsigned int order;             /* order a direct compactor needs */
+       int order;                      /* order a direct compactor needs */
        int migratetype;                /* MOVABLE, RECLAIMABLE etc */
        struct zone *zone;
 };
@@ -692,7 +692,7 @@ static int __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc)
                INIT_LIST_HEAD(&cc->freepages);
                INIT_LIST_HEAD(&cc->migratepages);
 
-               if (cc->order < 0 || !compaction_deferred(zone, cc->order))
+               if (cc->order == -1 || !compaction_deferred(zone, cc->order))
                        compact_zone(zone, cc);
 
                if (cc->order > 0) {