Why does RHEL6 allocate a number of size-2097152 slabs on boot?

Latest response

With RHEL6 came a long-awaited feature called cgroups, which are used to partition system resources amongst different users, applications etc.

 

Find out more about cgroups in Red Hat's Resource Management Guide here:

http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/index.html

 

In stock RHEL6, there is an amount of memory allocated to  2M slab objects (SUnreclaim in /proc/meminfo; size-2097152 in  /proc/slabinfo).  For every 1GB of system RAM, 8x2MB slabs are required to manage memory cgroups.

 

A page_cgroup page is associated with every page descriptor; meaning that for each 1GB of physical RAM, (8) 2MB slabs are required to manage memory cgroups.

 

If you're not using cgroups and you'd like to make use of this RAM, add the below to the kernel command line (followed by a reboot), which disables memory cgroups system-wide:

        cgroup_disable=memory

snippet of code from 'include/linux/page_cgroup.h'
--------------------------------------------------

/*
* Page Cgroup can be considered as an extended mem_map.
* A page_cgroup page is associated with every page descriptor. The
* page_cgroup helps us identify information about the cgroup
* All page cgroups are allocated at boot or memory hotplug event,
* then the page cgroup for pfn always exists.

As a note, a feature request has been submitted to reduce the memory overhead required by memory cgroups.

Responses

To build on Jeremy's note -- he mentions to add "cgroup_disable=memory" to the kernel command line. You can do this across system reboots by editing /boot/grub/grub.conf and placing it in the "kernel" directive listed for your running kernel. Here's an example for my installation--yours will be different.

title Red Hat Enterprise Linux 6 (2.6.32-71.29.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.29.1.el6.x86_64 ro root=/dev/mapper/vg_philjpc-lv_root rd_LVM_LV=vg_philjpc/lv_root rd_LVM_LV=vg_philjpc/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=128M rhgb quiet cgroup_disable=memory
initrd /initramfs-2.6.32-71.29.1.el6.x86_64.img

You can view the kernel's cgroup configuration on bootup by looking at the kernel ring buffer with dmesg. This is on a system with the default configuration:

[root@philj-pc grub]# dmesg | grep -i cgroup
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
allocated 78643200 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
Initializing cgroup subsys ns
Initializing cgroup subsys cpuacct
Initializing cgroup subsys memory
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Initializing cgroup subsys net_cls
Initializing cgroup subsys blkio