aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 31abd1c2c0c5..de54ea0094a1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1127,6 +1127,24 @@ static int mem_cgroup_count_children(struct mem_cgroup *mem)
1127} 1127}
1128 1128
1129/* 1129/*
1130 * Return the memory (and swap, if configured) limit for a memcg.
1131 */
1132u64 mem_cgroup_get_limit(struct mem_cgroup *memcg)
1133{
1134 u64 limit;
1135 u64 memsw;
1136
1137 limit = res_counter_read_u64(&memcg->res, RES_LIMIT) +
1138 total_swap_pages;
1139 memsw = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
1140 /*
1141 * If memsw is finite and limits the amount of swap space available
1142 * to this memcg, return that limit.
1143 */
1144 return min(limit, memsw);
1145}
1146
1147/*
1130 * Visit the first child (need not be the first child as per the ordering 1148 * Visit the first child (need not be the first child as per the ordering
1131 * of the cgroup list, since we track last_scanned_child) of @mem and use 1149 * of the cgroup list, since we track last_scanned_child) of @mem and use
1132 * that to reclaim free pages from. 1150 * that to reclaim free pages from.