[Devel] [PATCH RHEL COMMIT] ms/memcg: enable accounting for scm_fp_list objects

Konstantin Khorenko khorenko at virtuozzo.com
Tue Sep 28 14:16:18 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 9a4a46b61189ffad4fa12f7a70093d297291540c
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Tue Sep 28 14:16:18 2021 +0300

    ms/memcg: enable accounting for scm_fp_list objects
    
    unix sockets allows to send file descriptors via SCM_RIGHTS type messages.
    Each such send call forces kernel to allocate up to 2Kb memory for
    struct scm_fp_list.
    
    It makes sense to account for them to restrict the host's memory
    consumption from inside the memcg-limited container.
    
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
    
    Signed-off-by: David S. Miller <davem at davemloft.net>
    (cherry picked from commit 2c6ad20b581e37d6331010ee1d28b3307c90ba0a)
    https://jira.sw.ru/browse/PSBM-133990
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 net/core/scm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/scm.c b/net/core/scm.c
index ae3085d9aae8..5c356f0dee30 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -79,7 +79,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
 
 	if (!fpl)
 	{
-		fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL);
+		fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL_ACCOUNT);
 		if (!fpl)
 			return -ENOMEM;
 		*fplp = fpl;
@@ -355,7 +355,7 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)
 		return NULL;
 
 	new_fpl = kmemdup(fpl, offsetof(struct scm_fp_list, fp[fpl->count]),
-			  GFP_KERNEL);
+			  GFP_KERNEL_ACCOUNT);
 	if (new_fpl) {
 		for (i = 0; i < fpl->count; i++)
 			get_file(fpl->fp[i]);


More information about the Devel mailing list