aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <khlebnikov@openvz.org>2012-05-29 18:07:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:26 -0400
commitc56d5c7dfeb5cc754e17fa3d423086a3c551c219 (patch)
tree4c89ad9692dbd3a2e0eaf96de0162a5d3066925e /mm/vmscan.c
parent074291fea8bcedeabf295360e2ddd9bbb5830b4a (diff)
mm/vmscan: push lruvec pointer into inactive_list_is_low()
Switch mem_cgroup_inactive_anon_is_low() to lruvec pointers, mem_cgroup_get_lruvec_size() is more effective than mem_cgroup_zone_nr_lru_pages() Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Mel Gorman <mel@csn.ul.ie> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 5318faa6a251..79e2ead21c57 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1488,13 +1488,12 @@ static int inactive_anon_is_low_global(struct zone *zone)
1488 1488
1489/** 1489/**
1490 * inactive_anon_is_low - check if anonymous pages need to be deactivated 1490 * inactive_anon_is_low - check if anonymous pages need to be deactivated
1491 * @zone: zone to check 1491 * @lruvec: LRU vector to check
1492 * @sc: scan control of this context
1493 * 1492 *
1494 * Returns true if the zone does not have enough inactive anon pages, 1493 * Returns true if the zone does not have enough inactive anon pages,
1495 * meaning some active anon pages need to be deactivated. 1494 * meaning some active anon pages need to be deactivated.
1496 */ 1495 */
1497static int inactive_anon_is_low(struct mem_cgroup_zone *mz) 1496static int inactive_anon_is_low(struct lruvec *lruvec)
1498{ 1497{
1499 /* 1498 /*
1500 * If we don't have swap space, anonymous page deactivation 1499 * If we don't have swap space, anonymous page deactivation
@@ -1504,13 +1503,12 @@ static int inactive_anon_is_low(struct mem_cgroup_zone *mz)
1504 return 0; 1503 return 0;
1505 1504
1506 if (!mem_cgroup_disabled()) 1505 if (!mem_cgroup_disabled())
1507 return mem_cgroup_inactive_anon_is_low(mz->mem_cgroup, 1506 return mem_cgroup_inactive_anon_is_low(lruvec);
1508 mz->zone);
1509 1507
1510 return inactive_anon_is_low_global(mz->zone); 1508 return inactive_anon_is_low_global(lruvec_zone(lruvec));
1511} 1509}
1512#else 1510#else
1513static inline int inactive_anon_is_low(struct mem_cgroup_zone *mz) 1511static inline int inactive_anon_is_low(struct lruvec *lruvec)
1514{ 1512{
1515 return 0; 1513 return 0;
1516} 1514}
@@ -1528,7 +1526,7 @@ static int inactive_file_is_low_global(struct zone *zone)
1528 1526
1529/** 1527/**
1530 * inactive_file_is_low - check if file pages need to be deactivated 1528 * inactive_file_is_low - check if file pages need to be deactivated
1531 * @mz: memory cgroup and zone to check 1529 * @lruvec: LRU vector to check
1532 * 1530 *
1533 * When the system is doing streaming IO, memory pressure here 1531 * When the system is doing streaming IO, memory pressure here
1534 * ensures that active file pages get deactivated, until more 1532 * ensures that active file pages get deactivated, until more
@@ -1540,21 +1538,20 @@ static int inactive_file_is_low_global(struct zone *zone)
1540 * This uses a different ratio than the anonymous pages, because 1538 * This uses a different ratio than the anonymous pages, because
1541 * the page cache uses a use-once replacement algorithm. 1539 * the page cache uses a use-once replacement algorithm.
1542 */ 1540 */
1543static int inactive_file_is_low(struct mem_cgroup_zone *mz) 1541static int inactive_file_is_low(struct lruvec *lruvec)
1544{ 1542{
1545 if (!mem_cgroup_disabled()) 1543 if (!mem_cgroup_disabled())
1546 return mem_cgroup_inactive_file_is_low(mz->mem_cgroup, 1544 return mem_cgroup_inactive_file_is_low(lruvec);
1547 mz->zone);
1548 1545
1549 return inactive_file_is_low_global(mz->zone); 1546 return inactive_file_is_low_global(lruvec_zone(lruvec));
1550} 1547}
1551 1548
1552static int inactive_list_is_low(struct mem_cgroup_zone *mz, int file) 1549static int inactive_list_is_low(struct lruvec *lruvec, int file)
1553{ 1550{
1554 if (file) 1551 if (file)
1555 return inactive_file_is_low(mz); 1552 return inactive_file_is_low(lruvec);
1556 else 1553 else
1557 return inactive_anon_is_low(mz); 1554 return inactive_anon_is_low(lruvec);
1558} 1555}
1559 1556
1560static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, 1557static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
@@ -1564,7 +1561,10 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
1564 int file = is_file_lru(lru); 1561 int file = is_file_lru(lru);
1565 1562
1566 if (is_active_lru(lru)) { 1563 if (is_active_lru(lru)) {
1567 if (inactive_list_is_low(mz, file)) 1564 struct lruvec *lruvec = mem_cgroup_zone_lruvec(mz->zone,
1565 mz->mem_cgroup);
1566
1567 if (inactive_list_is_low(lruvec, file))
1568 shrink_active_list(nr_to_scan, mz, sc, lru); 1568 shrink_active_list(nr_to_scan, mz, sc, lru);
1569 return 0; 1569 return 0;
1570 } 1570 }
@@ -1793,6 +1793,9 @@ static void shrink_mem_cgroup_zone(struct mem_cgroup_zone *mz,
1793 unsigned long nr_reclaimed, nr_scanned; 1793 unsigned long nr_reclaimed, nr_scanned;
1794 unsigned long nr_to_reclaim = sc->nr_to_reclaim; 1794 unsigned long nr_to_reclaim = sc->nr_to_reclaim;
1795 struct blk_plug plug; 1795 struct blk_plug plug;
1796 struct lruvec *lruvec;
1797
1798 lruvec = mem_cgroup_zone_lruvec(mz->zone, mz->mem_cgroup);
1796 1799
1797restart: 1800restart:
1798 nr_reclaimed = 0; 1801 nr_reclaimed = 0;
@@ -1831,7 +1834,7 @@ restart:
1831 * Even if we did not try to evict anon pages at all, we want to 1834 * Even if we did not try to evict anon pages at all, we want to
1832 * rebalance the anon lru active/inactive ratio. 1835 * rebalance the anon lru active/inactive ratio.
1833 */ 1836 */
1834 if (inactive_anon_is_low(mz)) 1837 if (inactive_anon_is_low(lruvec))
1835 shrink_active_list(SWAP_CLUSTER_MAX, mz, 1838 shrink_active_list(SWAP_CLUSTER_MAX, mz,
1836 sc, LRU_ACTIVE_ANON); 1839 sc, LRU_ACTIVE_ANON);
1837 1840
@@ -2264,12 +2267,13 @@ static void age_active_anon(struct zone *zone, struct scan_control *sc)
2264 2267
2265 memcg = mem_cgroup_iter(NULL, NULL, NULL); 2268 memcg = mem_cgroup_iter(NULL, NULL, NULL);
2266 do { 2269 do {
2270 struct lruvec *lruvec = mem_cgroup_zone_lruvec(zone, memcg);
2267 struct mem_cgroup_zone mz = { 2271 struct mem_cgroup_zone mz = {
2268 .mem_cgroup = memcg, 2272 .mem_cgroup = memcg,
2269 .zone = zone, 2273 .zone = zone,
2270 }; 2274 };
2271 2275
2272 if (inactive_anon_is_low(&mz)) 2276 if (inactive_anon_is_low(lruvec))
2273 shrink_active_list(SWAP_CLUSTER_MAX, &mz, 2277 shrink_active_list(SWAP_CLUSTER_MAX, &mz,
2274 sc, LRU_ACTIVE_ANON); 2278 sc, LRU_ACTIVE_ANON);
2275 2279