diff options
author | Minchan Kim <minchan.kim@gmail.com> | 2011-10-31 20:06:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-31 20:30:44 -0400 |
commit | 4356f21d09283dc6d39a6f7287a65ddab61e2808 (patch) | |
tree | 34822a1662ea83291455834556a4fb5bf98ecd72 /mm | |
parent | b9e84ac1536d35aee03b2601f19694949f0bd506 (diff) |
mm: change isolate mode from #define to bitwise type
Change ISOLATE_XXX macro with bitwise isolate_mode_t type. Normally,
macro isn't recommended as it's type-unsafe and making debugging harder as
symbol cannot be passed throught to the debugger.
Quote from Johannes
" Hmm, it would probably be cleaner to fully convert the isolation mode
into independent flags. INACTIVE, ACTIVE, BOTH is currently a
tri-state among flags, which is a bit ugly."
This patch moves isolate mode from swap.h to mmzone.h by memcontrol.h
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/compaction.c | 3 | ||||
-rw-r--r-- | mm/memcontrol.c | 3 | ||||
-rw-r--r-- | mm/vmscan.c | 37 |
3 files changed, 24 insertions, 19 deletions
diff --git a/mm/compaction.c b/mm/compaction.c index b2977a5d659a..47f717fa4233 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -349,7 +349,8 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, | |||
349 | } | 349 | } |
350 | 350 | ||
351 | /* Try isolate the page */ | 351 | /* Try isolate the page */ |
352 | if (__isolate_lru_page(page, ISOLATE_BOTH, 0) != 0) | 352 | if (__isolate_lru_page(page, |
353 | ISOLATE_ACTIVE|ISOLATE_INACTIVE, 0) != 0) | ||
353 | continue; | 354 | continue; |
354 | 355 | ||
355 | VM_BUG_ON(PageTransCompound(page)); | 356 | VM_BUG_ON(PageTransCompound(page)); |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3508777837c7..2d5755544afe 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1185,7 +1185,8 @@ mem_cgroup_get_reclaim_stat_from_page(struct page *page) | |||
1185 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | 1185 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
1186 | struct list_head *dst, | 1186 | struct list_head *dst, |
1187 | unsigned long *scanned, int order, | 1187 | unsigned long *scanned, int order, |
1188 | int mode, struct zone *z, | 1188 | isolate_mode_t mode, |
1189 | struct zone *z, | ||
1189 | struct mem_cgroup *mem_cont, | 1190 | struct mem_cgroup *mem_cont, |
1190 | int active, int file) | 1191 | int active, int file) |
1191 | { | 1192 | { |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 9fdfce7ba403..ec6dbcb976d1 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1012,23 +1012,27 @@ keep_lumpy: | |||
1012 | * | 1012 | * |
1013 | * returns 0 on success, -ve errno on failure. | 1013 | * returns 0 on success, -ve errno on failure. |
1014 | */ | 1014 | */ |
1015 | int __isolate_lru_page(struct page *page, int mode, int file) | 1015 | int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file) |
1016 | { | 1016 | { |
1017 | bool all_lru_mode; | ||
1017 | int ret = -EINVAL; | 1018 | int ret = -EINVAL; |
1018 | 1019 | ||
1019 | /* Only take pages on the LRU. */ | 1020 | /* Only take pages on the LRU. */ |
1020 | if (!PageLRU(page)) | 1021 | if (!PageLRU(page)) |
1021 | return ret; | 1022 | return ret; |
1022 | 1023 | ||
1024 | all_lru_mode = (mode & (ISOLATE_ACTIVE|ISOLATE_INACTIVE)) == | ||
1025 | (ISOLATE_ACTIVE|ISOLATE_INACTIVE); | ||
1026 | |||
1023 | /* | 1027 | /* |
1024 | * When checking the active state, we need to be sure we are | 1028 | * When checking the active state, we need to be sure we are |
1025 | * dealing with comparible boolean values. Take the logical not | 1029 | * dealing with comparible boolean values. Take the logical not |
1026 | * of each. | 1030 | * of each. |
1027 | */ | 1031 | */ |
1028 | if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode)) | 1032 | if (!all_lru_mode && !PageActive(page) != !(mode & ISOLATE_ACTIVE)) |
1029 | return ret; | 1033 | return ret; |
1030 | 1034 | ||
1031 | if (mode != ISOLATE_BOTH && page_is_file_cache(page) != file) | 1035 | if (!all_lru_mode && !!page_is_file_cache(page) != file) |
1032 | return ret; | 1036 | return ret; |
1033 | 1037 | ||
1034 | /* | 1038 | /* |
@@ -1076,7 +1080,8 @@ int __isolate_lru_page(struct page *page, int mode, int file) | |||
1076 | */ | 1080 | */ |
1077 | static unsigned long isolate_lru_pages(unsigned long nr_to_scan, | 1081 | static unsigned long isolate_lru_pages(unsigned long nr_to_scan, |
1078 | struct list_head *src, struct list_head *dst, | 1082 | struct list_head *src, struct list_head *dst, |
1079 | unsigned long *scanned, int order, int mode, int file) | 1083 | unsigned long *scanned, int order, isolate_mode_t mode, |
1084 | int file) | ||
1080 | { | 1085 | { |
1081 | unsigned long nr_taken = 0; | 1086 | unsigned long nr_taken = 0; |
1082 | unsigned long nr_lumpy_taken = 0; | 1087 | unsigned long nr_lumpy_taken = 0; |
@@ -1201,8 +1206,8 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, | |||
1201 | static unsigned long isolate_pages_global(unsigned long nr, | 1206 | static unsigned long isolate_pages_global(unsigned long nr, |
1202 | struct list_head *dst, | 1207 | struct list_head *dst, |
1203 | unsigned long *scanned, int order, | 1208 | unsigned long *scanned, int order, |
1204 | int mode, struct zone *z, | 1209 | isolate_mode_t mode, |
1205 | int active, int file) | 1210 | struct zone *z, int active, int file) |
1206 | { | 1211 | { |
1207 | int lru = LRU_BASE; | 1212 | int lru = LRU_BASE; |
1208 | if (active) | 1213 | if (active) |
@@ -1448,6 +1453,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, | |||
1448 | unsigned long nr_taken; | 1453 | unsigned long nr_taken; |
1449 | unsigned long nr_anon; | 1454 | unsigned long nr_anon; |
1450 | unsigned long nr_file; | 1455 | unsigned long nr_file; |
1456 | isolate_mode_t reclaim_mode = ISOLATE_INACTIVE; | ||
1451 | 1457 | ||
1452 | while (unlikely(too_many_isolated(zone, file, sc))) { | 1458 | while (unlikely(too_many_isolated(zone, file, sc))) { |
1453 | congestion_wait(BLK_RW_ASYNC, HZ/10); | 1459 | congestion_wait(BLK_RW_ASYNC, HZ/10); |
@@ -1458,15 +1464,15 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, | |||
1458 | } | 1464 | } |
1459 | 1465 | ||
1460 | set_reclaim_mode(priority, sc, false); | 1466 | set_reclaim_mode(priority, sc, false); |
1467 | if (sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM) | ||
1468 | reclaim_mode |= ISOLATE_ACTIVE; | ||
1469 | |||
1461 | lru_add_drain(); | 1470 | lru_add_drain(); |
1462 | spin_lock_irq(&zone->lru_lock); | 1471 | spin_lock_irq(&zone->lru_lock); |
1463 | 1472 | ||
1464 | if (scanning_global_lru(sc)) { | 1473 | if (scanning_global_lru(sc)) { |
1465 | nr_taken = isolate_pages_global(nr_to_scan, | 1474 | nr_taken = isolate_pages_global(nr_to_scan, &page_list, |
1466 | &page_list, &nr_scanned, sc->order, | 1475 | &nr_scanned, sc->order, reclaim_mode, zone, 0, file); |
1467 | sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? | ||
1468 | ISOLATE_BOTH : ISOLATE_INACTIVE, | ||
1469 | zone, 0, file); | ||
1470 | zone->pages_scanned += nr_scanned; | 1476 | zone->pages_scanned += nr_scanned; |
1471 | if (current_is_kswapd()) | 1477 | if (current_is_kswapd()) |
1472 | __count_zone_vm_events(PGSCAN_KSWAPD, zone, | 1478 | __count_zone_vm_events(PGSCAN_KSWAPD, zone, |
@@ -1475,12 +1481,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, | |||
1475 | __count_zone_vm_events(PGSCAN_DIRECT, zone, | 1481 | __count_zone_vm_events(PGSCAN_DIRECT, zone, |
1476 | nr_scanned); | 1482 | nr_scanned); |
1477 | } else { | 1483 | } else { |
1478 | nr_taken = mem_cgroup_isolate_pages(nr_to_scan, | 1484 | nr_taken = mem_cgroup_isolate_pages(nr_to_scan, &page_list, |
1479 | &page_list, &nr_scanned, sc->order, | 1485 | &nr_scanned, sc->order, reclaim_mode, zone, |
1480 | sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? | 1486 | sc->mem_cgroup, 0, file); |
1481 | ISOLATE_BOTH : ISOLATE_INACTIVE, | ||
1482 | zone, sc->mem_cgroup, | ||
1483 | 0, file); | ||
1484 | /* | 1487 | /* |
1485 | * mem_cgroup_isolate_pages() keeps track of | 1488 | * mem_cgroup_isolate_pages() keeps track of |
1486 | * scanned pages on its own. | 1489 | * scanned pages on its own. |