History

slub: make sysfs directories for memcg sub-caches optional

SLUB creates a per-cache directory under /sys/kernel/slab which hosts a bunch of debug files. Usually, there aren't that many caches on a system and this doesn't really matter; however, if memcg is in use, each cache can have per-cgroup sub-caches. SLUB creates the same directories for these sub-caches under /sys/kernel/slab/$CACHE/cgroup. Unfortunately, because there can be a lot of cgroups, active or draining, the product of the numbers of caches, cgroups and files in each directory can reach a very high number - hundreds of thousands is commonplace. Millions and beyond aren't difficult to reach either. What's under /sys/kernel/slab is primarily for debugging and the information and control on the a root cache already cover its sub-caches. While having a separate directory for each sub-cache can be helpful for development, it doesn't make much sense to pay this amount of overhead by default. This patch introduces a boot parameter slub_memcg_sysfs which determines whether to create sysfs directories for per-memcg sub-caches. It also adds CONFIG_SLUB_MEMCG_SYSFS_ON which determines the boot parameter's default value and defaults to 0. [akpm@linux-foundation.org: kset_unregister(NULL) is legal] Link: http://lkml.kernel.org/r/20170204145203.GB26958@mtj.duckdns.org Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Tejun Heo committed 9 years ago

Commit 1663f261 parent 17cc4df3 files · +46 −2Browse files

Showing the changes to init (1 of 3 files). Show all

Unified · Split

init/Kconfig+14−0
@@ -1779,6 +1779,20 @@ config SLUB_DEBUG · 1778 unmodified lines
17791779 SLUB sysfs support. /sys/slab will not exist and there will be
17801780 no support for cache validation etc.
17811781
1782+config SLUB_MEMCG_SYSFS_ON
1783+ default n
1784+ bool "Enable memcg SLUB sysfs support by default" if EXPERT
1785+ depends on SLUB && SYSFS && MEMCG
1786+ help
1787+ SLUB creates a directory under /sys/kernel/slab for each
1788+ allocation cache to host info and debug files. If memory
1789+ cgroup is enabled, each cache can have per memory cgroup
1790+ caches. SLUB can create the same sysfs directories for these
1791+ caches under /sys/kernel/slab/CACHE/cgroup but it can lead
1792+ to a very high number of debug files being created. This is
1793+ controlled by slub_memcg_sysfs boot parameter and this
1794+ config option determines the parameter's default value.
1795+
17821796 config COMPAT_BRK
17831797 bool "Disable heap randomization"
17841798 default y