diff options
author | Minchan Kim <minchan@kernel.org> | 2013-02-22 19:33:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:15 -0500 |
commit | 194159fbcc0d6ac1351837d3cd7a27a4af0219a6 (patch) | |
tree | a5a960a4c8698001db50a987015131bb5d256c6e | |
parent | c60514b6314137a9505c60966fda2094b22a2fda (diff) |
mm: remove MIGRATE_ISOLATE check in hotpath
Several functions test MIGRATE_ISOLATE and some of those are hotpath but
MIGRATE_ISOLATE is used only if we enable CONFIG_MEMORY_ISOLATION(ie,
CMA, memory-hotplug and memory-failure) which are not common config
option. So let's not add unnecessary overhead and code when we don't
enable CONFIG_MEMORY_ISOLATION.
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/mmzone.h | 2 | ||||
-rw-r--r-- | include/linux/page-isolation.h | 19 | ||||
-rw-r--r-- | mm/compaction.c | 6 | ||||
-rw-r--r-- | mm/page_alloc.c | 16 | ||||
-rw-r--r-- | mm/vmstat.c | 2 |
5 files changed, 38 insertions, 7 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 73b64a38b984..4f4c8c26fa9d 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -57,7 +57,9 @@ enum { | |||
57 | */ | 57 | */ |
58 | MIGRATE_CMA, | 58 | MIGRATE_CMA, |
59 | #endif | 59 | #endif |
60 | #ifdef CONFIG_MEMORY_ISOLATION | ||
60 | MIGRATE_ISOLATE, /* can't allocate from here */ | 61 | MIGRATE_ISOLATE, /* can't allocate from here */ |
62 | #endif | ||
61 | MIGRATE_TYPES | 63 | MIGRATE_TYPES |
62 | }; | 64 | }; |
63 | 65 | ||
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h index a92061e08d48..3fff8e774067 100644 --- a/include/linux/page-isolation.h +++ b/include/linux/page-isolation.h | |||
@@ -1,6 +1,25 @@ | |||
1 | #ifndef __LINUX_PAGEISOLATION_H | 1 | #ifndef __LINUX_PAGEISOLATION_H |
2 | #define __LINUX_PAGEISOLATION_H | 2 | #define __LINUX_PAGEISOLATION_H |
3 | 3 | ||
4 | #ifdef CONFIG_MEMORY_ISOLATION | ||
5 | static inline bool is_migrate_isolate_page(struct page *page) | ||
6 | { | ||
7 | return get_pageblock_migratetype(page) == MIGRATE_ISOLATE; | ||
8 | } | ||
9 | static inline bool is_migrate_isolate(int migratetype) | ||
10 | { | ||
11 | return migratetype == MIGRATE_ISOLATE; | ||
12 | } | ||
13 | #else | ||
14 | static inline bool is_migrate_isolate_page(struct page *page) | ||
15 | { | ||
16 | return false; | ||
17 | } | ||
18 | static inline bool is_migrate_isolate(int migratetype) | ||
19 | { | ||
20 | return false; | ||
21 | } | ||
22 | #endif | ||
4 | 23 | ||
5 | bool has_unmovable_pages(struct zone *zone, struct page *page, int count, | 24 | bool has_unmovable_pages(struct zone *zone, struct page *page, int count, |
6 | bool skip_hwpoisoned_pages); | 25 | bool skip_hwpoisoned_pages); |
diff --git a/mm/compaction.c b/mm/compaction.c index 5d5b0b259bc9..ef53f352b606 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/sysctl.h> | 15 | #include <linux/sysctl.h> |
16 | #include <linux/sysfs.h> | 16 | #include <linux/sysfs.h> |
17 | #include <linux/balloon_compaction.h> | 17 | #include <linux/balloon_compaction.h> |
18 | #include <linux/page-isolation.h> | ||
18 | #include "internal.h" | 19 | #include "internal.h" |
19 | 20 | ||
20 | #ifdef CONFIG_COMPACTION | 21 | #ifdef CONFIG_COMPACTION |
@@ -215,7 +216,10 @@ static bool suitable_migration_target(struct page *page) | |||
215 | int migratetype = get_pageblock_migratetype(page); | 216 | int migratetype = get_pageblock_migratetype(page); |
216 | 217 | ||
217 | /* Don't interfere with memory hot-remove or the min_free_kbytes blocks */ | 218 | /* Don't interfere with memory hot-remove or the min_free_kbytes blocks */ |
218 | if (migratetype == MIGRATE_ISOLATE || migratetype == MIGRATE_RESERVE) | 219 | if (migratetype == MIGRATE_RESERVE) |
220 | return false; | ||
221 | |||
222 | if (is_migrate_isolate(migratetype)) | ||
219 | return false; | 223 | return false; |
220 | 224 | ||
221 | /* If the page is a large free page, then allow migration */ | 225 | /* If the page is a large free page, then allow migration */ |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 07fe78d01ffd..e3fb290194c0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -673,7 +673,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, | |||
673 | /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ | 673 | /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ |
674 | __free_one_page(page, zone, 0, mt); | 674 | __free_one_page(page, zone, 0, mt); |
675 | trace_mm_page_pcpu_drain(page, 0, mt); | 675 | trace_mm_page_pcpu_drain(page, 0, mt); |
676 | if (likely(get_pageblock_migratetype(page) != MIGRATE_ISOLATE)) { | 676 | if (likely(!is_migrate_isolate_page(page))) { |
677 | __mod_zone_page_state(zone, NR_FREE_PAGES, 1); | 677 | __mod_zone_page_state(zone, NR_FREE_PAGES, 1); |
678 | if (is_migrate_cma(mt)) | 678 | if (is_migrate_cma(mt)) |
679 | __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, 1); | 679 | __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, 1); |
@@ -691,7 +691,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order, | |||
691 | zone->pages_scanned = 0; | 691 | zone->pages_scanned = 0; |
692 | 692 | ||
693 | __free_one_page(page, zone, order, migratetype); | 693 | __free_one_page(page, zone, order, migratetype); |
694 | if (unlikely(migratetype != MIGRATE_ISOLATE)) | 694 | if (unlikely(!is_migrate_isolate(migratetype))) |
695 | __mod_zone_freepage_state(zone, 1 << order, migratetype); | 695 | __mod_zone_freepage_state(zone, 1 << order, migratetype); |
696 | spin_unlock(&zone->lock); | 696 | spin_unlock(&zone->lock); |
697 | } | 697 | } |
@@ -923,7 +923,9 @@ static int fallbacks[MIGRATE_TYPES][4] = { | |||
923 | [MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, MIGRATE_RESERVE }, | 923 | [MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, MIGRATE_RESERVE }, |
924 | #endif | 924 | #endif |
925 | [MIGRATE_RESERVE] = { MIGRATE_RESERVE }, /* Never used */ | 925 | [MIGRATE_RESERVE] = { MIGRATE_RESERVE }, /* Never used */ |
926 | #ifdef CONFIG_MEMORY_ISOLATION | ||
926 | [MIGRATE_ISOLATE] = { MIGRATE_RESERVE }, /* Never used */ | 927 | [MIGRATE_ISOLATE] = { MIGRATE_RESERVE }, /* Never used */ |
928 | #endif | ||
927 | }; | 929 | }; |
928 | 930 | ||
929 | /* | 931 | /* |
@@ -1149,7 +1151,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, | |||
1149 | list_add_tail(&page->lru, list); | 1151 | list_add_tail(&page->lru, list); |
1150 | if (IS_ENABLED(CONFIG_CMA)) { | 1152 | if (IS_ENABLED(CONFIG_CMA)) { |
1151 | mt = get_pageblock_migratetype(page); | 1153 | mt = get_pageblock_migratetype(page); |
1152 | if (!is_migrate_cma(mt) && mt != MIGRATE_ISOLATE) | 1154 | if (!is_migrate_cma(mt) && !is_migrate_isolate(mt)) |
1153 | mt = migratetype; | 1155 | mt = migratetype; |
1154 | } | 1156 | } |
1155 | set_freepage_migratetype(page, mt); | 1157 | set_freepage_migratetype(page, mt); |
@@ -1333,7 +1335,7 @@ void free_hot_cold_page(struct page *page, int cold) | |||
1333 | * excessively into the page allocator | 1335 | * excessively into the page allocator |
1334 | */ | 1336 | */ |
1335 | if (migratetype >= MIGRATE_PCPTYPES) { | 1337 | if (migratetype >= MIGRATE_PCPTYPES) { |
1336 | if (unlikely(migratetype == MIGRATE_ISOLATE)) { | 1338 | if (unlikely(is_migrate_isolate(migratetype))) { |
1337 | free_one_page(zone, page, 0, migratetype); | 1339 | free_one_page(zone, page, 0, migratetype); |
1338 | goto out; | 1340 | goto out; |
1339 | } | 1341 | } |
@@ -1407,7 +1409,7 @@ static int __isolate_free_page(struct page *page, unsigned int order) | |||
1407 | zone = page_zone(page); | 1409 | zone = page_zone(page); |
1408 | mt = get_pageblock_migratetype(page); | 1410 | mt = get_pageblock_migratetype(page); |
1409 | 1411 | ||
1410 | if (mt != MIGRATE_ISOLATE) { | 1412 | if (!is_migrate_isolate(mt)) { |
1411 | /* Obey watermarks as if the page was being allocated */ | 1413 | /* Obey watermarks as if the page was being allocated */ |
1412 | watermark = low_wmark_pages(zone) + (1 << order); | 1414 | watermark = low_wmark_pages(zone) + (1 << order); |
1413 | if (!zone_watermark_ok(zone, 0, watermark, 0, 0)) | 1415 | if (!zone_watermark_ok(zone, 0, watermark, 0, 0)) |
@@ -1426,7 +1428,7 @@ static int __isolate_free_page(struct page *page, unsigned int order) | |||
1426 | struct page *endpage = page + (1 << order) - 1; | 1428 | struct page *endpage = page + (1 << order) - 1; |
1427 | for (; page < endpage; page += pageblock_nr_pages) { | 1429 | for (; page < endpage; page += pageblock_nr_pages) { |
1428 | int mt = get_pageblock_migratetype(page); | 1430 | int mt = get_pageblock_migratetype(page); |
1429 | if (mt != MIGRATE_ISOLATE && !is_migrate_cma(mt)) | 1431 | if (!is_migrate_isolate(mt) && !is_migrate_cma(mt)) |
1430 | set_pageblock_migratetype(page, | 1432 | set_pageblock_migratetype(page, |
1431 | MIGRATE_MOVABLE); | 1433 | MIGRATE_MOVABLE); |
1432 | } | 1434 | } |
@@ -2904,7 +2906,9 @@ static void show_migration_types(unsigned char type) | |||
2904 | #ifdef CONFIG_CMA | 2906 | #ifdef CONFIG_CMA |
2905 | [MIGRATE_CMA] = 'C', | 2907 | [MIGRATE_CMA] = 'C', |
2906 | #endif | 2908 | #endif |
2909 | #ifdef CONFIG_MEMORY_ISOLATION | ||
2907 | [MIGRATE_ISOLATE] = 'I', | 2910 | [MIGRATE_ISOLATE] = 'I', |
2911 | #endif | ||
2908 | }; | 2912 | }; |
2909 | char tmp[MIGRATE_TYPES + 1]; | 2913 | char tmp[MIGRATE_TYPES + 1]; |
2910 | char *p = tmp; | 2914 | char *p = tmp; |
diff --git a/mm/vmstat.c b/mm/vmstat.c index e3475f5fd983..c9d1f68120cd 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -628,7 +628,9 @@ static char * const migratetype_names[MIGRATE_TYPES] = { | |||
628 | #ifdef CONFIG_CMA | 628 | #ifdef CONFIG_CMA |
629 | "CMA", | 629 | "CMA", |
630 | #endif | 630 | #endif |
631 | #ifdef CONFIG_MEMORY_ISOLATION | ||
631 | "Isolate", | 632 | "Isolate", |
633 | #endif | ||
632 | }; | 634 | }; |
633 | 635 | ||
634 | static void *frag_start(struct seq_file *m, loff_t *pos) | 636 | static void *frag_start(struct seq_file *m, loff_t *pos) |