summaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-05-20 19:56:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commitea7ab982b6bdb7ce218fd3a7850bb2e2b414fdd0 (patch)
tree19949422efc2cdc40558810b3f54636ee9ee2a46 /mm/compaction.c
parentb6459cc154e804f0de0d61fa023c4946b742cc96 (diff)
mm, compaction: change COMPACT_ constants into enum
Compaction code is doing weird dances between COMPACT_FOO -> int -> unsigned long But there doesn't seem to be any reason for that. All functions which return/use one of those constants are not expecting any other value so it really makes sense to define an enum for them and make it clear that no other values are expected. This is a pure cleanup and shouldn't introduce any functional changes. Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com> Cc: David Rientjes <rientjes@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Vladimir Davydov <vdavydov@virtuozzo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index eda3c2244f30..e721d252c5d2 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1229,7 +1229,7 @@ static inline bool is_via_compact_memory(int order)
1229 return order == -1; 1229 return order == -1;
1230} 1230}
1231 1231
1232static int __compact_finished(struct zone *zone, struct compact_control *cc, 1232static enum compact_result __compact_finished(struct zone *zone, struct compact_control *cc,
1233 const int migratetype) 1233 const int migratetype)
1234{ 1234{
1235 unsigned int order; 1235 unsigned int order;
@@ -1292,8 +1292,9 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc,
1292 return COMPACT_NO_SUITABLE_PAGE; 1292 return COMPACT_NO_SUITABLE_PAGE;
1293} 1293}
1294 1294
1295static int compact_finished(struct zone *zone, struct compact_control *cc, 1295static enum compact_result compact_finished(struct zone *zone,
1296 const int migratetype) 1296 struct compact_control *cc,
1297 const int migratetype)
1297{ 1298{
1298 int ret; 1299 int ret;
1299 1300
@@ -1312,7 +1313,7 @@ static int compact_finished(struct zone *zone, struct compact_control *cc,
1312 * COMPACT_PARTIAL - If the allocation would succeed without compaction 1313 * COMPACT_PARTIAL - If the allocation would succeed without compaction
1313 * COMPACT_CONTINUE - If compaction should run now 1314 * COMPACT_CONTINUE - If compaction should run now
1314 */ 1315 */
1315static unsigned long __compaction_suitable(struct zone *zone, int order, 1316static enum compact_result __compaction_suitable(struct zone *zone, int order,
1316 unsigned int alloc_flags, 1317 unsigned int alloc_flags,
1317 int classzone_idx) 1318 int classzone_idx)
1318{ 1319{
@@ -1358,11 +1359,11 @@ static unsigned long __compaction_suitable(struct zone *zone, int order,
1358 return COMPACT_CONTINUE; 1359 return COMPACT_CONTINUE;
1359} 1360}
1360 1361
1361unsigned long compaction_suitable(struct zone *zone, int order, 1362enum compact_result compaction_suitable(struct zone *zone, int order,
1362 unsigned int alloc_flags, 1363 unsigned int alloc_flags,
1363 int classzone_idx) 1364 int classzone_idx)
1364{ 1365{
1365 unsigned long ret; 1366 enum compact_result ret;
1366 1367
1367 ret = __compaction_suitable(zone, order, alloc_flags, classzone_idx); 1368 ret = __compaction_suitable(zone, order, alloc_flags, classzone_idx);
1368 trace_mm_compaction_suitable(zone, order, ret); 1369 trace_mm_compaction_suitable(zone, order, ret);
@@ -1372,9 +1373,9 @@ unsigned long compaction_suitable(struct zone *zone, int order,
1372 return ret; 1373 return ret;
1373} 1374}
1374 1375
1375static int compact_zone(struct zone *zone, struct compact_control *cc) 1376static enum compact_result compact_zone(struct zone *zone, struct compact_control *cc)
1376{ 1377{
1377 int ret; 1378 enum compact_result ret;
1378 unsigned long start_pfn = zone->zone_start_pfn; 1379 unsigned long start_pfn = zone->zone_start_pfn;
1379 unsigned long end_pfn = zone_end_pfn(zone); 1380 unsigned long end_pfn = zone_end_pfn(zone);
1380 const int migratetype = gfpflags_to_migratetype(cc->gfp_mask); 1381 const int migratetype = gfpflags_to_migratetype(cc->gfp_mask);
@@ -1530,11 +1531,11 @@ out:
1530 return ret; 1531 return ret;
1531} 1532}
1532 1533
1533static unsigned long compact_zone_order(struct zone *zone, int order, 1534static enum compact_result compact_zone_order(struct zone *zone, int order,
1534 gfp_t gfp_mask, enum migrate_mode mode, int *contended, 1535 gfp_t gfp_mask, enum migrate_mode mode, int *contended,
1535 unsigned int alloc_flags, int classzone_idx) 1536 unsigned int alloc_flags, int classzone_idx)
1536{ 1537{
1537 unsigned long ret; 1538 enum compact_result ret;
1538 struct compact_control cc = { 1539 struct compact_control cc = {
1539 .nr_freepages = 0, 1540 .nr_freepages = 0,
1540 .nr_migratepages = 0, 1541 .nr_migratepages = 0,
@@ -1572,7 +1573,7 @@ int sysctl_extfrag_threshold = 500;
1572 * 1573 *
1573 * This is the main entry point for direct page compaction. 1574 * This is the main entry point for direct page compaction.
1574 */ 1575 */
1575unsigned long try_to_compact_pages(gfp_t gfp_mask, unsigned int order, 1576enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
1576 unsigned int alloc_flags, const struct alloc_context *ac, 1577 unsigned int alloc_flags, const struct alloc_context *ac,
1577 enum migrate_mode mode, int *contended) 1578 enum migrate_mode mode, int *contended)
1578{ 1579{
@@ -1580,7 +1581,7 @@ unsigned long try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
1580 int may_perform_io = gfp_mask & __GFP_IO; 1581 int may_perform_io = gfp_mask & __GFP_IO;
1581 struct zoneref *z; 1582 struct zoneref *z;
1582 struct zone *zone; 1583 struct zone *zone;
1583 int rc = COMPACT_DEFERRED; 1584 enum compact_result rc = COMPACT_DEFERRED;
1584 int all_zones_contended = COMPACT_CONTENDED_LOCK; /* init for &= op */ 1585 int all_zones_contended = COMPACT_CONTENDED_LOCK; /* init for &= op */
1585 1586
1586 *contended = COMPACT_CONTENDED_NONE; 1587 *contended = COMPACT_CONTENDED_NONE;
@@ -1594,7 +1595,7 @@ unsigned long try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
1594 /* Compact each zone in the list */ 1595 /* Compact each zone in the list */
1595 for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx, 1596 for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx,
1596 ac->nodemask) { 1597 ac->nodemask) {
1597 int status; 1598 enum compact_result status;
1598 int zone_contended; 1599 int zone_contended;
1599 1600
1600 if (compaction_deferred(zone, order)) 1601 if (compaction_deferred(zone, order))