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.5
------>
commit 21981083cfc6eefc4f110dcd556fdf235800d711
Author: Vladimir Davydov <vdavy...@parallels.com>
Date:   Mon May 25 14:27:45 2015 +0400

    ub: do not apply memcg limits on attaching via sys_setluid
    
    We apply ub limits to the underlying memcg on every attach in order to
    active kmem accounting. Actually, it's saner to do that once on create
    instead of on eacy sys_setluid call. This patch therefore moves
    ub_update_mem_cgroup_limits call from ub_mem_cgroup_attach_task to
    get_beancounter_by_name.
    
    Also, rename ub_update_mem_cgroup_limits to ub_update_memcg ot match
    ub_sync_memcg.
    
    Signed-off-by: Vladimir Davydov <vdavy...@parallels.com>
---
 include/bc/beancounter.h |  3 +--
 kernel/bc/beancounter.c  | 22 +++++++++-------------
 kernel/bc/sys.c          |  2 +-
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/include/bc/beancounter.h b/include/bc/beancounter.h
index e0ef5ec..a706843 100644
--- a/include/bc/beancounter.h
+++ b/include/bc/beancounter.h
@@ -317,8 +317,7 @@ extern void __uncharge_beancounter_locked(struct 
user_beancounter *ub,
 extern void uncharge_warn(struct user_beancounter *ub, const char *resource,
                unsigned long val, unsigned long held);
 
-extern int ub_update_mem_cgroup_limits(struct user_beancounter *ub);
-
+extern int ub_update_memcg(struct user_beancounter *ub);
 extern void ub_sync_memcg(struct user_beancounter *ub);
 extern void ub_page_stat(struct user_beancounter *ub,
                         const nodemask_t *nodemask,
diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index d94fb32..fb0530b 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -109,9 +109,6 @@ static void ub_cgroup_close(struct cgroup *root, struct 
cgroup *cg)
                cgroup_kernel_close(cg);
 }
 
-extern int mem_cgroup_apply_beancounter(struct cgroup *cg,
-                                       struct user_beancounter *ub);
-
 static int ub_mem_cgroup_attach_task(struct user_beancounter *ub,
                                     struct task_struct *tsk)
 {
@@ -121,12 +118,7 @@ static int ub_mem_cgroup_attach_task(struct 
user_beancounter *ub,
        cg = ub_cgroup_open(mem_cgroup_root, ub);
        if (IS_ERR(cg))
                return PTR_ERR(cg);
-       if (ub != get_ub0())
-               ret = mem_cgroup_apply_beancounter(cg, ub);
-       else
-               ret = 0;
-       if (!ret)
-               ret = cgroup_kernel_attach(cg, tsk);
+       ret = cgroup_kernel_attach(cg, tsk);
        ub_cgroup_close(mem_cgroup_root, cg);
        return ret;
 }
@@ -186,7 +178,12 @@ fail_blkio:
        goto out;
 }
 
-int ub_update_mem_cgroup_limits(struct user_beancounter *ub)
+extern void mem_cgroup_sync_beancounter(struct cgroup *cg,
+                                       struct user_beancounter *ub);
+extern int mem_cgroup_apply_beancounter(struct cgroup *cg,
+                                       struct user_beancounter *ub);
+
+int ub_update_memcg(struct user_beancounter *ub)
 {
        struct cgroup *cg;
        int ret;
@@ -202,9 +199,6 @@ int ub_update_mem_cgroup_limits(struct user_beancounter *ub)
        return ret;
 }
 
-extern void mem_cgroup_sync_beancounter(struct cgroup *cg,
-                                       struct user_beancounter *ub);
-
 void ub_sync_memcg(struct user_beancounter *ub)
 {
        struct cgroup *cg;
@@ -383,6 +377,8 @@ struct user_beancounter *get_beancounter_by_name(const char 
*name, int create)
                                return NULL;
                        pr_warn_once("Allocating UB with syslimits is 
deprecated!\n");
                        init_beancounter_syslimits(cgroup_ub(cg));
+                       if (ub_update_memcg(cgroup_ub(cg)) != 0)
+                               pr_warn("Failed to init UB %s limits\n", name);
                }
        } else {
                cg = cgroup_kernel_open(ub_cgroup_root, 0, name);
diff --git a/kernel/bc/sys.c b/kernel/bc/sys.c
index 875f05e..096aa97 100644
--- a/kernel/bc/sys.c
+++ b/kernel/bc/sys.c
@@ -99,7 +99,7 @@ long do_setublimit(uid_t uid, unsigned long resource,
        init_beancounter_precharge(ub, resource);
        spin_unlock_irqrestore(&ub->ub_lock, flags);
 
-       error = ub_update_mem_cgroup_limits(ub);
+       error = ub_update_memcg(ub);
 
        put_beancounter(ub);
 out:
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to