A number of users made use of cgroups recently by following the four-line script from Lennart Poettering, rather than patching the kernel, to improve Linux desktop performance. Many users (myself included) tried the script but didn’t at the time pay attention to the fact that it was using the cgroups feature.
Cgrpoups is a feature initially developed to limit resource usage in the Linux kernel. But it can do much more, including tweak memory, bandwidth and CPU usage of system processes as well as deny access to system resources.
So what is cgroups? It’s a feature initially developed to limit resource usage in the Linux kernel. Using cgroups, you can tweak the memory, bandwidth, CPU usage and so forth of processes running on your system. Cgroups can also be used to deny access to system resources, and they can help monitor system resources.
Specifically, the kernel has controllers for memory, CPU usage and sets, devices, process control (“freezer”) and networking. For example, you can use the cpuacct controller to control CPU usage, and the cpu controller to manage the actual CPUs used. Processes might be able to have 100 percent of two CPUs on a system, but not four.
Right now this is not entirely a straightforward process. Some distros ship
  with the user-space tools to work with cgroups, others don’t. Ubuntu, for example,
  doesn’t — so install the cgroup-bin package if you’re on Ubuntu. Then, you
  must create a configuration file called /etc/cgconfig.conf and specify mount
  points on the filesystem that correspond with the controllers. For example,
  you might mount the cpu controller under /dev/cgroups/cpu and
  the memory controller under /dev/cgroups/memory. Alternatively,
  you might want to use the blkio subsystem to manage I/O on your system.
Once the controllers are mounted, you must actually create groups that define the parameters of a group. For example, you might want to create a group called “virtual” that has limited access to the blkio subsystem of your machine to ensure VMware doesn’t chew up your disks too badly.
This week, I wanted to just introduce the cgroups feature and concept, since it seems to be less than well known in the Linux community. Next week, I’ll provide a few short examples for using cgroups to manage resources you can adapt to your systems. In the meantime, you might want to look at Red Hat’s Resource Management Guide, which is very complete but also fairly complex. We’ll make it simpler. Stay tuned, it’s going to get fun!
Joe ‘Zonker’
Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at jzb@zonker.net and follow him on Twitter.
  Joe Brockmeier is the editorial director of the Red Hat Blog. He joined Red Hat in 2013 as part of the Open Source and Standards (OSAS) group, now the Open Source Program Office (OSPO). Prior to Red Hat, Brockmeier worked for Citrix on the Apache OpenStack project, and was the first OpenSUSE community manager for Novell between 2008-2010. Brockmeier also has an extensive history in the tech press and publishing, having been editor-in-chief of Linux Magazine, editorial director of Linux.com, and a contributor to LWN.net, ZDNet, UnixReview.com, and many others.
Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.