• Roman Gushchin's avatar
    mm: memcg: introduce memcontrol-v1.c · 1b1e1344
    Roman Gushchin authored
    Patch series "mm: memcg: separate legacy cgroup v1 code and put under
    config option", v2.
    
    Cgroups v2 have been around for a while and many users have fully adopted
    them, so they never use cgroups v1 features and functionality.  Yet they
    have to "pay" for the cgroup v1 support anyway:
    1) the kernel binary contains an unused cgroup v1 code,
    2) some code paths have additional checks which are not needed,
    3) some common structures like task_struct and mem_cgroup contain unused
       cgroup v1-specific members.
    
    Cgroup v1's memory controller has a number of features that are not
    supported by cgroup v2 and their implementation is pretty much self
    contained.  Most notably, these features are: soft limit reclaim, oom
    handling in userspace, complicated event notification system, charge
    migration.  Cgroup v1-specific code in memcontrol.c is close to 4k lines
    in size and it's intervened with generic and cgroup v2-specific code. 
    It's a burden on developers and maintainers.
    
    This patchset aims to solve these problems by:
    1) moving cgroup v1-specific memcg code to the new mm/memcontrol-v1.c file,
    2) putting definitions shared by memcontrol.c and memcontrol-v1.c into the
       mm/memcontrol-v1.h header,
    3) introducing the CONFIG_MEMCG_V1 config option, turned off by default,
    4) making memcontrol-v1.c to compile only if CONFIG_MEMCG_V1 is set.
    
    If CONFIG_MEMCG_V1 is not set, cgroup v1 memory controller is still available
    for mounting, however no memory-specific control knobs are present.
    
    This patch (of 14):
    
    
    This patch introduces the mm/memcontrol-v1.c source file which will be
    used for all legacy (cgroup v1) memory cgroup code.  It also introduces
    mm/memcontrol-v1.h to keep declarations shared between mm/memcontrol.c and
    mm/memcontrol-v1.c.
    
    As of now, let's compile it if CONFIG_MEMCG is set, similar to
    mm/memcontrol.c.  Later on it can be switched to use a separate config
    option, so that the legacy code won't be compiled if not required.
    
    Link: https://lkml.kernel.org/r/20240625005906.106920-1-roman.gushchin@linux.dev
    Link: https://lkml.kernel.org/r/20240625005906.106920-2-roman.gushchin@linux.devSigned-off-by: default avatarRoman Gushchin <roman.gushchin@linux.dev>
    Acked-by: default avatarMichal Hocko <mhocko@suse.com>
    Acked-by: default avatarShakeel Butt <shakeel.butt@linux.dev>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Muchun Song <muchun.song@linux.dev>
    Cc: Roman Gushchin <roman.gushchin@linux.dev>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    1b1e1344
Makefile 5.04 KB