diff options
-rw-r--r-- | Documentation/cgroups/memory.txt | 1 | ||||
-rw-r--r-- | include/linux/memcontrol.h | 10 | ||||
-rw-r--r-- | mm/memcontrol.c | 51 | ||||
-rw-r--r-- | mm/vmscan.c | 4 |
4 files changed, 25 insertions, 41 deletions
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index 06eb6d957c83..cc0ebc5241b3 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt | |||
@@ -418,7 +418,6 @@ total_unevictable - sum of all children's "unevictable" | |||
418 | 418 | ||
419 | # The following additional stats are dependent on CONFIG_DEBUG_VM. | 419 | # The following additional stats are dependent on CONFIG_DEBUG_VM. |
420 | 420 | ||
421 | inactive_ratio - VM internal parameter. (see mm/page_alloc.c) | ||
422 | recent_rotated_anon - VM internal parameter. (see mm/vmscan.c) | 421 | recent_rotated_anon - VM internal parameter. (see mm/vmscan.c) |
423 | recent_rotated_file - VM internal parameter. (see mm/vmscan.c) | 422 | recent_rotated_file - VM internal parameter. (see mm/vmscan.c) |
424 | recent_scanned_anon - VM internal parameter. (see mm/vmscan.c) | 423 | recent_scanned_anon - VM internal parameter. (see mm/vmscan.c) |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 05206aac5965..b87068a1a09e 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -106,8 +106,10 @@ extern void mem_cgroup_end_migration(struct mem_cgroup *memcg, | |||
106 | /* | 106 | /* |
107 | * For memory reclaim. | 107 | * For memory reclaim. |
108 | */ | 108 | */ |
109 | int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg); | 109 | int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, |
110 | int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg); | 110 | struct zone *zone); |
111 | int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg, | ||
112 | struct zone *zone); | ||
111 | int mem_cgroup_select_victim_node(struct mem_cgroup *memcg); | 113 | int mem_cgroup_select_victim_node(struct mem_cgroup *memcg); |
112 | unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, | 114 | unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, |
113 | int nid, int zid, unsigned int lrumask); | 115 | int nid, int zid, unsigned int lrumask); |
@@ -295,13 +297,13 @@ static inline bool mem_cgroup_disabled(void) | |||
295 | } | 297 | } |
296 | 298 | ||
297 | static inline int | 299 | static inline int |
298 | mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg) | 300 | mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone) |
299 | { | 301 | { |
300 | return 1; | 302 | return 1; |
301 | } | 303 | } |
302 | 304 | ||
303 | static inline int | 305 | static inline int |
304 | mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg) | 306 | mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg, struct zone *zone) |
305 | { | 307 | { |
306 | return 1; | 308 | return 1; |
307 | } | 309 | } |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index f6c4beb4db56..ce7b35d024e9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1104,15 +1104,19 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg) | |||
1104 | return ret; | 1104 | return ret; |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | static int calc_inactive_ratio(struct mem_cgroup *memcg, unsigned long *present_pages) | 1107 | int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone) |
1108 | { | 1108 | { |
1109 | unsigned long active; | 1109 | unsigned long inactive_ratio; |
1110 | int nid = zone_to_nid(zone); | ||
1111 | int zid = zone_idx(zone); | ||
1110 | unsigned long inactive; | 1112 | unsigned long inactive; |
1113 | unsigned long active; | ||
1111 | unsigned long gb; | 1114 | unsigned long gb; |
1112 | unsigned long inactive_ratio; | ||
1113 | 1115 | ||
1114 | inactive = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_INACTIVE_ANON)); | 1116 | inactive = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid, |
1115 | active = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_ACTIVE_ANON)); | 1117 | BIT(LRU_INACTIVE_ANON)); |
1118 | active = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid, | ||
1119 | BIT(LRU_ACTIVE_ANON)); | ||
1116 | 1120 | ||
1117 | gb = (inactive + active) >> (30 - PAGE_SHIFT); | 1121 | gb = (inactive + active) >> (30 - PAGE_SHIFT); |
1118 | if (gb) | 1122 | if (gb) |
@@ -1120,39 +1124,20 @@ static int calc_inactive_ratio(struct mem_cgroup *memcg, unsigned long *present_ | |||
1120 | else | 1124 | else |
1121 | inactive_ratio = 1; | 1125 | inactive_ratio = 1; |
1122 | 1126 | ||
1123 | if (present_pages) { | 1127 | return inactive * inactive_ratio < active; |
1124 | present_pages[0] = inactive; | ||
1125 | present_pages[1] = active; | ||
1126 | } | ||
1127 | |||
1128 | return inactive_ratio; | ||
1129 | } | 1128 | } |
1130 | 1129 | ||
1131 | int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg) | 1130 | int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg, struct zone *zone) |
1132 | { | ||
1133 | unsigned long active; | ||
1134 | unsigned long inactive; | ||
1135 | unsigned long present_pages[2]; | ||
1136 | unsigned long inactive_ratio; | ||
1137 | |||
1138 | inactive_ratio = calc_inactive_ratio(memcg, present_pages); | ||
1139 | |||
1140 | inactive = present_pages[0]; | ||
1141 | active = present_pages[1]; | ||
1142 | |||
1143 | if (inactive * inactive_ratio < active) | ||
1144 | return 1; | ||
1145 | |||
1146 | return 0; | ||
1147 | } | ||
1148 | |||
1149 | int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg) | ||
1150 | { | 1131 | { |
1151 | unsigned long active; | 1132 | unsigned long active; |
1152 | unsigned long inactive; | 1133 | unsigned long inactive; |
1134 | int zid = zone_idx(zone); | ||
1135 | int nid = zone_to_nid(zone); | ||
1153 | 1136 | ||
1154 | inactive = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_INACTIVE_FILE)); | 1137 | inactive = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid, |
1155 | active = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_ACTIVE_FILE)); | 1138 | BIT(LRU_INACTIVE_FILE)); |
1139 | active = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid, | ||
1140 | BIT(LRU_ACTIVE_FILE)); | ||
1156 | 1141 | ||
1157 | return (active > inactive); | 1142 | return (active > inactive); |
1158 | } | 1143 | } |
@@ -4192,8 +4177,6 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, | |||
4192 | } | 4177 | } |
4193 | 4178 | ||
4194 | #ifdef CONFIG_DEBUG_VM | 4179 | #ifdef CONFIG_DEBUG_VM |
4195 | cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL)); | ||
4196 | |||
4197 | { | 4180 | { |
4198 | int nid, zid; | 4181 | int nid, zid; |
4199 | struct mem_cgroup_per_zone *mz; | 4182 | struct mem_cgroup_per_zone *mz; |
diff --git a/mm/vmscan.c b/mm/vmscan.c index a90c603a8d02..132d1ddb2238 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1767,7 +1767,7 @@ static int inactive_anon_is_low(struct zone *zone, struct scan_control *sc) | |||
1767 | if (scanning_global_lru(sc)) | 1767 | if (scanning_global_lru(sc)) |
1768 | low = inactive_anon_is_low_global(zone); | 1768 | low = inactive_anon_is_low_global(zone); |
1769 | else | 1769 | else |
1770 | low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup); | 1770 | low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup, zone); |
1771 | return low; | 1771 | return low; |
1772 | } | 1772 | } |
1773 | #else | 1773 | #else |
@@ -1810,7 +1810,7 @@ static int inactive_file_is_low(struct zone *zone, struct scan_control *sc) | |||
1810 | if (scanning_global_lru(sc)) | 1810 | if (scanning_global_lru(sc)) |
1811 | low = inactive_file_is_low_global(zone); | 1811 | low = inactive_file_is_low_global(zone); |
1812 | else | 1812 | else |
1813 | low = mem_cgroup_inactive_file_is_low(sc->mem_cgroup); | 1813 | low = mem_cgroup_inactive_file_is_low(sc->mem_cgroup, zone); |
1814 | return low; | 1814 | return low; |
1815 | } | 1815 | } |
1816 | 1816 | ||