• Michal Hocko's avatar
    memcg: do not create memsw files if swap accounting is disabled · 2d11085e
    Michal Hocko authored
    Zhouping Liu has reported that memsw files are exported even though swap
    accounting is runtime disabled if MEMCG_SWAP is enabled.  This behavior
    has been introduced by commit af36f906 ("memcg: always create memsw
    files if CGROUP_MEM_RES_CTLR_SWAP") and it causes any attempt to open
    the file to return EOPNOTSUPP.  Although EOPNOTSUPP should say be clear
    that memsw operations are not supported in the given configuration it is
    fair to say that this behavior could be quite confusing.
    
    Let's tear memsw files out of default cgroup files and add them only if
    the swap accounting is really enabled (either by MEMCG_SWAP_ENABLED or
    swapaccount=1 boot parameter).  We can hook into mem_cgroup_init which
    is called when the memcg subsystem is initialized and which happens
    after boot command line is processed.
    Signed-off-by: default avatarMichal Hocko <mhocko@suse.cz>
    Reported-by: default avatarZhouping Liu <zliu@redhat.com>
    Tested-by: default avatarZhouping Liu <zliu@redhat.com>
    Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Li Zefan <lizefan@huawei.com>
    Cc: CAI Qian <caiqian@redhat.com>
    Cc: Tejun Heo <tj@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    2d11085e
memcontrol.c 180 KB