>From 015fdb03bdf2ad8cc1c0c1b72884d0c635cf6852 Mon Sep 17 00:00:00 2001 From: Minchan Kim <minchan@xxxxxxxxxx> Date: Sat, 5 May 2012 08:53:50 +0900 Subject: [PATCH 3/3] compaction: introduce new return value of suitable_migration_target We call twice suitable_migration_target to confirm it's really migration target blocks or not. So adding counting scheme in suitable_migration_target introduces new argument "count_pageblocks". But at least to me, it hurts code readability. This patch introduces new return value of suitable_migration_target so caller can judge when he should count it. IMHO, it helps code readbility and code size is same due to smart compiler. barrios@barrios:~/linux-next$ size mm/compaction.o text data bss dec hex filename 8451 1082 4 9537 2541 mm/compaction.o barrios@barrios:~/linux-next$ size mm/compaction.o.new text data bss dec hex filename 8451 1082 4 9537 2541 mm/compaction.o.new Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx> --- mm/compaction.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 72bd87a..129d9d6 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -397,38 +397,43 @@ static bool rescue_unmovable_pageblock(struct page *page) return true; } +enum result_smt { + GOOD_AS_MIGRATION_TARGET, + FAIL_UNMOVABLE, + FAIL_ETC_REASON, +}; + /* Returns true if the page is within a block suitable for migration to */ -static bool suitable_migration_target(struct page *page, - struct compact_control *cc, - bool count_pageblocks) +static enum result_smt suitable_migration_target(struct page *page, + struct compact_control *cc) { int migratetype = get_pageblock_migratetype(page); /* Don't interfere with memory hot-remove or the min_free_kbytes blocks */ if (migratetype == MIGRATE_ISOLATE || migratetype == MIGRATE_RESERVE) - return false; + return FAIL_ETC_REASON; /* If the page is a large free page, then allow migration */ if (PageBuddy(page) && page_order(page) >= pageblock_order) - return true; + return GOOD_AS_MIGRATION_TARGET; /* If the block is MIGRATE_MOVABLE or MIGRATE_CMA, allow migration */ if (cc->mode != COMPACT_ASYNC_UNMOVABLE && migrate_async_suitable(migratetype)) - return true; + return GOOD_AS_MIGRATION_TARGET; - if (count_pageblocks && cc->mode == COMPACT_ASYNC_MOVABLE && - migratetype == MIGRATE_UNMOVABLE) - cc->nr_pageblocks_skipped++; + if (cc->mode == COMPACT_ASYNC_MOVABLE && + migratetype == MIGRATE_UNMOVABLE) + return FAIL_UNMOVABLE; if (cc->mode != COMPACT_ASYNC_MOVABLE && migratetype == MIGRATE_UNMOVABLE && rescue_unmovable_pageblock(page)) - return true; + return GOOD_AS_MIGRATION_TARGET; /* Otherwise skip the block */ - return false; + return FAIL_ETC_REASON; } /* @@ -471,6 +476,7 @@ static void isolate_freepages(struct zone *zone, for (; pfn > low_pfn && cc->nr_migratepages > nr_freepages; pfn -= pageblock_nr_pages) { unsigned long isolated; + enum result_smt ret; if (!pfn_valid(pfn)) continue; @@ -487,9 +493,12 @@ static void isolate_freepages(struct zone *zone, continue; /* Check the block is suitable for migration */ - if (!suitable_migration_target(page, cc, true)) + ret = suitable_migration_target(page, cc); + if (ret != GOOD_AS_MIGRATION_TARGET) { + if (ret == FAIL_UNMOVABLE) + cc->nr_pageblocks_skipped++; continue; - + } /* * Found a block suitable for isolating free pages from. Now * we disabled interrupts, double check things are ok and @@ -498,7 +507,8 @@ static void isolate_freepages(struct zone *zone, */ isolated = 0; spin_lock_irqsave(&zone->lock, flags); - if (suitable_migration_target(page, cc, false)) { + ret = suitable_migration_target(page, cc); + if (ret == GOOD_AS_MIGRATION_TARGET) { end_pfn = min(pfn + pageblock_nr_pages, zone_end_pfn); isolated = isolate_freepages_block(pfn, end_pfn, freelist, false); -- 1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. 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@xxxxxxxxx"> email@xxxxxxxxx </a>