[Devel] [PATCH RHEL7 COMMIT] ms/net: Make account struct net to memcg

Konstantin Khorenko khorenko at virtuozzo.com
Wed May 27 19:14:18 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.2
------>
commit db11eef7f37eb874364f7049a891b30bce82d487
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Wed May 27 19:14:17 2020 +0300

    ms/net: Make account struct net to memcg
    
    ms commit 30855ffc29b9
    
    The patch adds SLAB_ACCOUNT to flags of net_cachep cache,
    which enables accounting of struct net memory to memcg kmem.
    Since number of net_namespaces may be significant, user
    want to know, how much there were consumed, and control.
    
    Note, that we do not account net_generic to the same memcg,
    where net was accounted, moreover, we don't do this at all (*).
    We do not want the situation, when single memcg memory deficit
    prevents us to register new pernet_operations.
    
    (*)Even despite there is !current process accounting already
    available in linux-next. See kmalloc_memcg() there for the details.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    Signed-off-by: David S. Miller <davem at davemloft.net>
---
 net/core/net_namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 69893c8ae6a02..ee673ead5f04c 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -798,7 +798,7 @@ static int __init net_ns_init(void)
 #ifdef CONFIG_NET_NS
 	net_cachep = kmem_cache_create("net_namespace", sizeof(struct net),
 					SMP_CACHE_BYTES,
-					SLAB_PANIC, NULL);
+					SLAB_PANIC|SLAB_ACCOUNT, NULL);
 
 	/* Create workqueue for cleanup */
 	netns_wq = create_singlethread_workqueue("netns");


More information about the Devel mailing list