mm: refactor inactive_file_is_low() to use get_lru_size()
authorJohannes Weiner <hannes@cmpxchg.org>
Sat, 23 Feb 2013 00:35:19 +0000 (16:35 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 24 Feb 2013 01:50:20 +0000 (17:50 -0800)
An inactive file list is considered low when its active counterpart is
bigger, regardless of whether it is a global zone LRU list or a memcg
zone LRU list.  The only difference is in how the LRU size is assessed.

get_lru_size() does the right thing for both global and memcg reclaim
situations.

Get rid of inactive_file_is_low_global() and
mem_cgroup_inactive_file_is_low() by using get_lru_size() and compare
the numbers in common code.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/memcontrol.h
mm/memcontrol.c
mm/vmscan.c

index 28bd5fa2ff2eb1c0550891cfa5af551cc03b6c5c..d6183f06d8c182951fac67c17a2c05d2ce9f20fa 100644 (file)
@@ -116,7 +116,6 @@ void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *);
  * For memory reclaim.
  */
 int mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec);
-int mem_cgroup_inactive_file_is_low(struct lruvec *lruvec);
 int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
 unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list);
 void mem_cgroup_update_lru_size(struct lruvec *, enum lru_list, int);
@@ -321,12 +320,6 @@ mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec)
        return 1;
 }
 
-static inline int
-mem_cgroup_inactive_file_is_low(struct lruvec *lruvec)
-{
-       return 1;
-}
-
 static inline unsigned long
 mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
 {
index 60d28e36f0e0f9e57379b4cf0003e6073bfb19a6..af4b04f4d74482f9041333bf0ffd1793ea35d328 100644 (file)
@@ -1396,17 +1396,6 @@ int mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec)
        return inactive * inactive_ratio < active;
 }
 
-int mem_cgroup_inactive_file_is_low(struct lruvec *lruvec)
-{
-       unsigned long active;
-       unsigned long inactive;
-
-       inactive = mem_cgroup_get_lru_size(lruvec, LRU_INACTIVE_FILE);
-       active = mem_cgroup_get_lru_size(lruvec, LRU_ACTIVE_FILE);
-
-       return (active > inactive);
-}
-
 #define mem_cgroup_from_res_counter(counter, member)   \
        container_of(counter, struct mem_cgroup, member)
 
index b7d8015a6d54b32ed653a41864b07da929c07943..396ecee281d08ff0fb4135fb420c88e4dd6f8dc1 100644 (file)
@@ -1579,16 +1579,6 @@ static inline int inactive_anon_is_low(struct lruvec *lruvec)
 }
 #endif
 
-static int inactive_file_is_low_global(struct zone *zone)
-{
-       unsigned long active, inactive;
-
-       active = zone_page_state(zone, NR_ACTIVE_FILE);
-       inactive = zone_page_state(zone, NR_INACTIVE_FILE);
-
-       return (active > inactive);
-}
-
 /**
  * inactive_file_is_low - check if file pages need to be deactivated
  * @lruvec: LRU vector to check
@@ -1605,10 +1595,13 @@ static int inactive_file_is_low_global(struct zone *zone)
  */
 static int inactive_file_is_low(struct lruvec *lruvec)
 {
-       if (!mem_cgroup_disabled())
-               return mem_cgroup_inactive_file_is_low(lruvec);
+       unsigned long inactive;
+       unsigned long active;
+
+       inactive = get_lru_size(lruvec, LRU_INACTIVE_FILE);
+       active = get_lru_size(lruvec, LRU_ACTIVE_FILE);
 
-       return inactive_file_is_low_global(lruvec_zone(lruvec));
+       return active > inactive;
 }
 
 static int inactive_list_is_low(struct lruvec *lruvec, enum lru_list lru)