[Devel] [PATCH RHEL7 COMMIT] memcg/ub: fix limit > RESOURCE_MAX case
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Jun 29 06:37:26 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.22
------>
commit e651dfc30632e241a0ce5758c9a4c5e9d4a6935b
Author: Vladimir Davydov <vdavydov at parallels.com>
Date: Mon Jun 29 17:37:26 2015 +0400
memcg/ub: fix limit > RESOURCE_MAX case
A memcg limit can be greater than RESOURCE_MAX (LLONG_MAX), because it
is rounded up to PAGE_SIZE. As a result, we will show huge numbers in
meminfo for unlimited containers instead of the host's configuration.
Fix this by making all limit-vs-RESOURCE_MAX comparisons use
greater-or-equal sign.
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
mm/memcontrol.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index cb153ac..50eefe3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1648,7 +1648,7 @@ unsigned long mem_cgroup_total_pages(struct mem_cgroup *memcg, bool swap)
limit = swap ? res_counter_read_u64(&memcg->memsw, RES_LIMIT) :
res_counter_read_u64(&memcg->res, RES_LIMIT);
- if (limit == RESOURCE_MAX)
+ if (limit >= RESOURCE_MAX)
return ULONG_MAX;
return min_t(unsigned long long, ULONG_MAX, limit >> PAGE_SHIFT);
}
@@ -5388,7 +5388,7 @@ void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
p->maxheld = res_counter_read_u64(&memcg->res, RES_MAX_USAGE) >> PAGE_SHIFT;
p->failcnt = atomic_long_read(&memcg->mem_failcnt);
lim = res_counter_read_u64(&memcg->res, RES_LIMIT);
- lim = lim == RESOURCE_MAX ? UB_MAXVALUE :
+ lim = lim >= RESOURCE_MAX ? UB_MAXVALUE :
min_t(unsigned long long, lim >> PAGE_SHIFT, UB_MAXVALUE);
p->barrier = p->limit = lim;
@@ -5396,7 +5396,7 @@ void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
k->maxheld = res_counter_read_u64(&memcg->kmem, RES_MAX_USAGE);
k->failcnt = res_counter_read_u64(&memcg->kmem, RES_FAILCNT);
lim = res_counter_read_u64(&memcg->kmem, RES_LIMIT);
- lim = lim == RESOURCE_MAX ? UB_MAXVALUE :
+ lim = lim >= RESOURCE_MAX ? UB_MAXVALUE :
min_t(unsigned long long, lim, UB_MAXVALUE);
k->barrier = k->limit = lim;
@@ -5410,7 +5410,7 @@ void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
maxheld = memcg->swap_max >> PAGE_SHIFT;
s->failcnt = atomic_long_read(&memcg->swap_failcnt);
lim = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
- lim = lim == RESOURCE_MAX ? UB_MAXVALUE :
+ lim = lim >= RESOURCE_MAX ? UB_MAXVALUE :
min_t(unsigned long long, lim >> PAGE_SHIFT, UB_MAXVALUE);
if (lim != UB_MAXVALUE)
lim -= p->limit;
@@ -5425,7 +5425,7 @@ void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
o->maxheld = res_counter_read_u64(&memcg->memsw, RES_MAX_USAGE) >> PAGE_SHIFT;
o->failcnt = atomic_long_read(&memcg->oom_kill_cnt);
lim = memcg->oom_guarantee;
- lim = lim == RESOURCE_MAX ? UB_MAXVALUE :
+ lim = lim >= RESOURCE_MAX ? UB_MAXVALUE :
min_t(unsigned long long, lim >> PAGE_SHIFT, UB_MAXVALUE);
o->barrier = o->limit = lim;
}
@@ -5486,7 +5486,7 @@ int mem_cgroup_apply_beancounter(struct mem_cgroup *memcg,
if (mem != mem_old) {
/* first, reset memsw limit since it cannot be < mem limit */
- if (memsw_old != RESOURCE_MAX) {
+ if (memsw_old < RESOURCE_MAX) {
memsw_old = RESOURCE_MAX;
ret = mem_cgroup_resize_memsw_limit(memcg, memsw_old);
if (ret)
More information about the Devel
mailing list