Skip to content

Commit c46649d

Browse files
Michal Hockotorvalds
authored andcommitted
mm, compaction: cover all compaction mode in compact_zone
The compiler is complaining after "mm, compaction: change COMPACT_ constants into enum" mm/compaction.c: In function `compact_zone': mm/compaction.c:1350:2: warning: enumeration value `COMPACT_DEFERRED' not handled in switch [-Wswitch] switch (ret) { ^ mm/compaction.c:1350:2: warning: enumeration value `COMPACT_COMPLETE' not handled in switch [-Wswitch] mm/compaction.c:1350:2: warning: enumeration value `COMPACT_NO_SUITABLE_PAGE' not handled in switch [-Wswitch] mm/compaction.c:1350:2: warning: enumeration value `COMPACT_NOT_SUITABLE_ZONE' not handled in switch [-Wswitch] mm/compaction.c:1350:2: warning: enumeration value `COMPACT_CONTENDED' not handled in switch [-Wswitch] compaction_suitable is allowed to return only COMPACT_PARTIAL, COMPACT_SKIPPED and COMPACT_CONTINUE so other cases are simply impossible. Put a VM_BUG_ON to catch an impossible return value. Signed-off-by: Michal Hocko <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Acked-by: Hillf Danton <[email protected]> Cc: David Rientjes <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Vladimir Davydov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ea7ab98 commit c46649d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

mm/compaction.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,15 +1383,12 @@ static enum compact_result compact_zone(struct zone *zone, struct compact_contro
13831383

13841384
ret = compaction_suitable(zone, cc->order, cc->alloc_flags,
13851385
cc->classzone_idx);
1386-
switch (ret) {
1387-
case COMPACT_PARTIAL:
1388-
case COMPACT_SKIPPED:
1389-
/* Compaction is likely to fail */
1386+
/* Compaction is likely to fail */
1387+
if (ret == COMPACT_PARTIAL || ret == COMPACT_SKIPPED)
13901388
return ret;
1391-
case COMPACT_CONTINUE:
1392-
/* Fall through to compaction */
1393-
;
1394-
}
1389+
1390+
/* huh, compaction_suitable is returning something unexpected */
1391+
VM_BUG_ON(ret != COMPACT_CONTINUE);
13951392

13961393
/*
13971394
* Clear pageblock skip if there were failures recently and compaction

0 commit comments

Comments
 (0)