The commit is pushed to "branch-rh7-3.10.0-693.11.6.vz7.42.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.6.vz7.42.4
------>
commit 980cb5adaaa6f98851a3364612530d0247c5ce81
Author: Johannes Weiner <han...@cmpxchg.org>
Date:   Wed Jan 31 18:48:01 2018 +0300

    ms/mm: memcontrol: simplify detecting when the memory+swap limit is hit
    
    When attempting to charge pages, we first charge the memory counter and
    then the memory+swap counter.  If one of the counters is at its limit, we
    enter reclaim, but if it's the memory+swap counter, reclaim shouldn't swap
    because that wouldn't change the situation.  However, if the counters have
    the same limits, we never get to the memory+swap limit.  To know whether
    reclaim should swap or not, there is a state flag that indicates whether
    the limits are equal and whether hitting the memory limit implies hitting
    the memory+swap limit.
    
    Just try the memory+swap counter first.
    
    Signed-off-by: Johannes Weiner <han...@cmpxchg.org>
    Reviewed-by: Vladimir Davydov <vdavy...@parallels.com>
    Acked-by: Michal Hocko <mho...@suse.cz>
    Cc: Dave Hansen <d...@sr71.net>
    Cc: Greg Thelen <gthe...@google.com>
    Signed-off-by: Andrew Morton <a...@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>
    
    https://jira.sw.ru/browse/PSBM-80732
    (cherry picked from commit 3fbe724424fb104aaca9973389b4a9df428c3e2a)
    Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 mm/memcontrol.c | 32 +++++---------------------------
 1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f7036e71edde..5396157488ec 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -340,9 +340,6 @@ struct mem_cgroup {
        /* OOM-Killer disable */
        int             oom_kill_disable;
 
-       /* set when res.limit == memsw.limit */
-       bool            memsw_is_minimum;
-
 #ifdef CONFIG_CLEANCACHE
        /*
         * cleancache_disabled_toggle: toggled by writing to
@@ -2163,8 +2160,6 @@ static unsigned long mem_cgroup_reclaim(struct mem_cgroup 
*memcg,
 
        if (flags & MEM_CGROUP_RECLAIM_NOSWAP)
                noswap = true;
-       if (!(flags & MEM_CGROUP_RECLAIM_SHRINK) && memcg->memsw_is_minimum)
-               noswap = true;
 
        for (loop = 0; loop < MEM_CGROUP_MAX_RECLAIM_LOOPS; loop++) {
                if (loop)
@@ -3849,7 +3844,6 @@ static int mem_cgroup_resize_limit(struct mem_cgroup 
*memcg,
 {
        unsigned long curusage;
        unsigned long oldusage;
-       unsigned long memswlimit;
        bool enlarge = false;
        int retry_count;
        int ret;
@@ -3870,23 +3864,14 @@ static int mem_cgroup_resize_limit(struct mem_cgroup 
*memcg,
                        break;
                }
                mutex_lock(&memcg_limit_mutex);
-               memswlimit = memcg->memsw.limit;
-               if (limit > memswlimit) {
+               if (limit > memcg->memsw.limit) {
                        mutex_unlock(&memcg_limit_mutex);
                        ret = -EINVAL;
                        break;
                }
-
                if (limit > memcg->memory.limit)
                        enlarge = true;
-
                ret = page_counter_limit(&memcg->memory, limit);
-               if (!ret) {
-                       if (memswlimit == limit)
-                               memcg->memsw_is_minimum = true;
-                       else
-                               memcg->memsw_is_minimum = false;
-               }
                mutex_unlock(&memcg_limit_mutex);
 
                if (!ret)
@@ -3913,7 +3898,6 @@ static int mem_cgroup_resize_memsw_limit(struct 
mem_cgroup *memcg,
 {
        unsigned long curusage;
        unsigned long oldusage;
-       unsigned long memlimit, memswlimit;
        bool enlarge = false;
        int retry_count;
        int ret;
@@ -3929,23 +3913,17 @@ static int mem_cgroup_resize_memsw_limit(struct 
mem_cgroup *memcg,
                        ret = -EINTR;
                        break;
                }
+
                mutex_lock(&memcg_limit_mutex);
-               memlimit = memcg->memory.limit;
-               if (limit < memlimit) {
+               if (limit < memcg->memory.limit) {
                        mutex_unlock(&memcg_limit_mutex);
                        ret = -EINVAL;
                        break;
                }
-               memswlimit = memcg->memsw.limit;
-               if (limit > memswlimit)
+
+               if (limit > memcg->memsw.limit)
                        enlarge = true;
                ret = page_counter_limit(&memcg->memsw, limit);
-               if (!ret) {
-                       if (memlimit == limit)
-                               memcg->memsw_is_minimum = true;
-                       else
-                               memcg->memsw_is_minimum = false;
-               }
                mutex_unlock(&memcg_limit_mutex);
 
                if (!ret)
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to