aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMinchan Kim <minchan.kim@gmail.com>2011-10-31 20:06:47 -0400
committerLuis Henriques <luis.henriques@canonical.com>2012-08-13 09:10:27 -0400
commit04dc67d115ca2a3400b384197685b393b86afc0c (patch)
tree283e5861a4b6e047ae0831e7e62d11d5d3ca7c2c /mm
parent7d3a80c5e03f6c9896623d9a1b22bc5d5855d8a2 (diff)
mm: change isolate mode from #define to bitwise type
BugLink: http://bugs.launchpad.net/bugs/1031926 commit 4356f21d09283dc6d39a6f7287a65ddab61e2808 upstream. Stable note: Not tracked in Bugzilla. This patch makes later patches easier to apply but has no other impact. 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> Signed-off-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/compaction.c3
-rw-r--r--mm/memcontrol.c3
-rw-r--r--mm/vmscan.c37
3 files changed, 24 insertions, 19 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index d6ba0377e26..26521a12f22 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -371,7 +371,8 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
371 } 371 }
372 372
373 /* Try isolate the page */ 373 /* Try isolate the page */
374 if (__isolate_lru_page(page, ISOLATE_BOTH, 0) != 0) 374 if (__isolate_lru_page(page,
375 ISOLATE_ACTIVE|ISOLATE_INACTIVE, 0) != 0)
375 continue; 376 continue;
376 377
377 VM_BUG_ON(PageTransCompound(page)); 378 VM_BUG_ON(PageTransCompound(page));
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ffb99b4e752..57cdf5ad692 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1251,7 +1251,8 @@ mem_cgroup_get_reclaim_stat_from_page(struct page *page)
1251unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 1251unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
1252 struct list_head *dst, 1252 struct list_head *dst,
1253 unsigned long *scanned, int order, 1253 unsigned long *scanned, int order,
1254 int mode, struct zone *z, 1254 isolate_mode_t mode,
1255 struct zone *z,
1255 struct mem_cgroup *mem_cont, 1256 struct mem_cgroup *mem_cont,
1256 int active, int file) 1257 int active, int file)
1257{ 1258{
diff --git a/mm/vmscan.c b/mm/vmscan.c
index b146b427cda..9267ba1b664 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 */
1015int __isolate_lru_page(struct page *page, int mode, int file) 1015int __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 */
1077static unsigned long isolate_lru_pages(unsigned long nr_to_scan, 1081static 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,
1201static unsigned long isolate_pages_global(unsigned long nr, 1206static 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.