[Devel] [PATCH RHEL7 COMMIT] ms/mm/memcontrol.c: fix a -Wunused-function warning

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jul 5 18:37:02 MSK 2023


The commit is pushed to "branch-rh7-3.10.0-1160.90.1.vz7.200.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.90.1.vz7.200.4
------>
commit 15d6023b570d8f32f9c41b7add01cd2c7ec3bd0d
Author: Qian Cai <cai at lca.pw>
Date:   Wed Jul 5 14:39:51 2023 +0800

    ms/mm/memcontrol.c: fix a -Wunused-function warning
    
    mem_cgroup_id_get() was introduced in commit 73f576c04b94 ("mm:memcontrol:
    fix cgroup creation failure after many small jobs").
    
    Later, it no longer has any user since the commits,
    
    1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from offline cgroup")
    58fa2a5512d9 ("mm: memcontrol: add sanity checks for memcg->id.ref on get/put")
    
    so safe to remove it.
    
    Link: http://lkml.kernel.org/r/1568648453-5482-1-git-send-email-cai@lca.pw
    Signed-off-by: Qian Cai <cai at lca.pw>
    Acked-by: Michal Hocko <mhocko at suse.com>
    Cc: Johannes Weiner <hannes at cmpxchg.org>
    Cc: Vladimir Davydov <vdavydov.dev at gmail.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    
    https://jira.vzint.dev/browse/PSBM-147036
    
    (cherry picked from commit 4d0e3230a56a75bf26d74b3f4b6cb05a0e9fae60)
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    
    =================
    Patchset description:
    memcg: release id when offlinging cgroup
    
    We see that container user can deplete memory cgroup ids on the system
    (64k) and prevent further memory cgroup creation. In crash collected by
    our customer in such a situation we see that mem_cgroup_idr is full of
    cgroups from one container with same exact path (cgroup of docker
    service), cgroups are not released because they have kmem charges, this
    kmem charge is for a tmpfs dentry allocated from this cgroup. (And on
    vz7 kernel it seems that such a dentry is only released after umounting
    tmpfs or removing the corresponding file from tmpfs.)
    
    So there is a valid way to hold kmem cgroup for a long time. Similar
    thing was mentioned in mainstream with page cache holding kmem cgroup
    for a long time. And they proposed a way to deal with it - just release
    cgroup id early so that one can allocate new cgroups immediately.
    
    Reproduce:
    https://git.vzint.dev/users/ptikhomirov/repos/helpers/browse/memcg-related/test-mycg-tmpfs.sh
    
    After this fix the number of memory cgroups in /proc/cgroups can now
    show > 64k as we allow to leave memory cgroups hanging while releasing
    their ids.
    
    Note: Maybe it's a bad idea to allow container to eat kernel
    memory with such a hanging cgroups, but yet I don't have better ideas.
    
    https://jira.vzint.dev/browse/PSBM-147473
    https://jira.vzint.dev/browse/PSBM-147036
---
 mm/memcontrol.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3d4d2fb2bfc6..de84dd1ee210 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6714,11 +6714,6 @@ static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
 	}
 }
 
-static inline void mem_cgroup_id_get(struct mem_cgroup *memcg)
-{
-	mem_cgroup_id_get_many(memcg, 1);
-}
-
 static inline void mem_cgroup_id_put(struct mem_cgroup *memcg)
 {
 	mem_cgroup_id_put_many(memcg, 1);


More information about the Devel mailing list