[Devel] [PATCH RHEL7 COMMIT] net/af_unix: charge buffers to kmemcg

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 31 02:14:09 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.9
------>
commit 5bdbd39e859d7cc3277ca3aece13914c9de6bacb
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Tue May 31 13:14:09 2016 +0400

    net/af_unix: charge buffers to kmemcg
    
    Unix sockets can consume a significant amount of system memory, hence
    they should be accounted to kmemcg.
    
    Since unix socket buffers are always allocated from process context,
    all we need to do to charge them to kmemcg is set __GFP_ACCOUNT in
    sock->sk_allocation mask.
    
    https://jira.sw.ru/browse/PSBM-34562
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 0e629f5..1da93a4 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -761,6 +761,7 @@ static struct sock *unix_create1(struct net *net, struct socket *sock)
 	lockdep_set_class(&sk->sk_receive_queue.lock,
 				&af_unix_sk_receive_queue_lock_key);
 
+	sk->sk_allocation	= GFP_KERNEL_ACCOUNT;
 	sk->sk_write_space	= unix_write_space;
 	sk->sk_max_ack_backlog	= net->unx.sysctl_max_dgram_qlen;
 	sk->sk_destruct		= unix_sock_destructor;


More information about the Devel mailing list