A team engineer Linux of Facebook, Roman Gushchin, has discovered a "serious flaw" in the way the current memory controller works on the Linux kernel. According to him, the existing kernel design causes Slab low usage and the reason behind this is that Slab pages are only used by a cgroup group of memory (control group).
For those who don't know, the Slab partition in the case of the Linux kernel refers to a memory management system that allocates memory to different kernel objects. Slab allocation is an effective memory management system that has the primary job of creating a Slab cache. A Slab cache is a list of slabs that are linked together, with each Slab representing a series of objects. In addition, the cgroup, or control group, is a feature of the Linux kernel that organizes processes in a hierarchical way.
What is the defect?
According to Gushchin, “If there are only a few specific size distributions made by a cgroup or if some active objects (eg dentries) remain after deleting the cgroup, or the cgroup contains an application with a single single-threaded application , which allocates little kernel objects and does it every time in a new one CPU: in all these cases the resulting use of Slab is very low. ”
He also adds that if kernel memory accounting is disabled, the kernel could use free space on the Slab pages for process allocation.
Gushchin says that the kmem controller was initially introduced as an optional feature, which had to be enabled separately for each memory cgroup. Now the feature is enabled by default, which prevents the use of Slab.
The new memory controller suggested by Gushchin
Gushchin's new proposal improves memory usage by distributing Slab pages. In addition, the developer adds that in his new system, accounting runs per object, rather than per page.
You can check out Gushchin's suggested new memory controller here.
If all goes well, the proposed memory controller will be included in the kernel Linux the 2020.