[Devel] [PATCH RHEL7 COMMIT] net/packet: use try_get_mem_cgroup_from_mm

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jun 17 05:36:25 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.14
------>
commit ca96fe4795f46f7f42c350ba0bba87ef6262e0f2
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Wed Jun 17 16:36:25 2015 +0400

    net/packet: use try_get_mem_cgroup_from_mm
    
    ... instead of home home bred try_get_mem_cgroup_from_current, and zap
    the latter.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 include/linux/memcontrol.h |  1 -
 mm/memcontrol.c            | 14 --------------
 net/packet/af_packet.c     |  2 +-
 3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 5e0e7c1..e09ec92 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -82,7 +82,6 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg)
 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
-extern struct mem_cgroup *try_get_mem_cgroup_from_current(void);
 
 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b883404..08bc82e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -554,20 +554,6 @@ void sock_update_memcg(struct sock *sk)
 }
 EXPORT_SYMBOL(sock_update_memcg);
 
-struct mem_cgroup *try_get_mem_cgroup_from_current(void)
-{
-	struct mem_cgroup *cg;
-
-	rcu_read_lock();
-	cg = mem_cgroup_from_task(current);
-	if (mem_cgroup_is_root(cg) || !css_tryget(&cg->css))
-		cg = NULL;
-	rcu_read_unlock();
-
-	return cg;
-}
-EXPORT_SYMBOL(try_get_mem_cgroup_from_current);
-
 void sock_release_memcg(struct sock *sk)
 {
 	if (mem_cgroup_sockets_enabled && sk->sk_cgrp) {
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 7cd659a..c757455 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2437,7 +2437,7 @@ static struct cg_proto *packet_sk_charge(void)
 	if (!psc)
 		return ERR_PTR(-ENOMEM);
 
-	psc->memcg = try_get_mem_cgroup_from_current();
+	psc->memcg = try_get_mem_cgroup_from_mm(current->mm);
 	if (psc->memcg && memcg_kmem_is_active(psc->memcg)) {
 		/*
 		 * Forcedly charge the maximum amount of data this socket



More information about the Devel mailing list