Questions tagged [cgroup]

cgroups (control groups) is a Linux kernel feature to limit, account and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups.

cgroups (control groups) is a Linux kernel feature to limit, account and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups. This work was started by engineers at Google (primarily Paul Menage and Rohit Seth) in 2006 under the name "process containers"; in late 2007 it was renamed to Control Groups (due to the confusion caused by multiple meanings of the term "container" in the Linux kernel) and merged to kernel version 2.6.24. Since then, many new features and controllers have been added.

One of the design goals of cgroups was to provide a unified interface to many different use cases, from controlling single processes (like nice) to whole operating system-level virtualization (like OpenVZ, Linux-VServer, LXC). Cgroups provides:

  • Resource limiting: groups can be set to not exceed a set memory limit — this also includes file system cache.
  • Prioritization: some groups may get a larger share of CPU or disk I/O throughput.
  • Accounting: to measure how much resources certain systems use for e.g. billing purposes.
  • Isolation: separate namespaces for groups, so they don't see each other's processes, network connections or files.
  • Control: freezing groups or checkpointing and restarting.

Source Wikipedia

129 questions
28
votes
3 answers

How to find out cgroup of a particular process?

Is there any method to get cgroup of process? The only one package that I know (cgroup-bin), just provide some manipulations with cgroups and allow to change cgroup of process/list of processes, but no capabilities to know information about cgroup…
zerospiel
  • 417
  • 1
  • 5
  • 10
25
votes
4 answers

How can I create and use Linux cgroups as a non-root user?

How can I create and use cgroups as a non-root user? For example, can I, entirely as a non-root user: create a cgroup with access to one CPU create a new process in that cgroup ? I first asked here but I didn't receive a complete answer. I also…
Adam Monsen
  • 695
  • 1
  • 7
  • 21
23
votes
2 answers

loop device in a Linux container?

I'm attempting to use a loop device inside a container, to mount some image file: > sudo losetup /dev/loop0 test.img losetup: /dev/loop0: failed to set up loop device: No such file or directory /dev/loop0 indeed doesn't exist, and > sudo mknod…
Johannes Ernst
  • 1,037
  • 4
  • 16
  • 26
18
votes
3 answers

Systemd fails to run in a docker container when using cgroupv2 (--cgroupns=private)

I will attach the minimized test case below. However, it is a simple Dockerfile that has these lines: VOLUME ["/sys/fs/cgroup"] CMD ["/lib/systemd/systemd"] It is Debian:buster-slim based image, and runs systemd inside the container. Effectively, I…
Stephen
  • 293
  • 1
  • 2
  • 4
14
votes
1 answer

How does CPU affinity interact with cgroups in Linux?

I'm trying to run multi-threaded benchmarks on a set of isolated CPUs. To cut a long story short, I initially tried with isolcpus and taskset, but hit problems. Now I'm playing with cgroups/csets. I think the "simple" cset shield use-case should…
Edd Barrett
  • 943
  • 3
  • 9
  • 19
10
votes
1 answer

Cgroup - no space left on device

I have Debian 7 box and little issue: mkdir /cgroups/test echo 500 > /cgroups/test/cpu.shares echo 3167 > /cgroups/test/tasks bash: echo: write error: No space left on device How can I fix it? In fstab: cgroup /cgroups cgroup defaults 0 0 I have…
Guest
  • 103
  • 1
  • 5
10
votes
3 answers

Why are applications in a memory-limited LXC container writing large files to disk being killed by the OOM?

EDIT2: This problem appears to exist as well under 3.8.0-25-generic #37-Ubuntu SMP EDIT: I modified the question from the original title of "Why would the Linux Out of Memory manager be triggered by writing to a file with dd?" to better reflect that…
UsAaR33
  • 1,036
  • 3
  • 11
  • 20
8
votes
2 answers

How do I set cgroup limits for systemd user slices?

I would like to limit usage of a system on a per user basis. Since Systemd has native support for cgroups, I think using user slices is the way to go. The problem is: I can't figure out how to set individual limits. I can edit the user.slice unit…
Steve F
  • 321
  • 1
  • 2
  • 9
7
votes
1 answer

List of controllers empty with cgroup v2

I am trying to learn how cgroups v2 work. I did this: mount -t cgroup2 none /mnt/cgroup2 That gave me a list of objects in /mnt/cgroup2 root@ubuntu-s-1vcpu-1gb-lon1-01:~# ls -la /mnt/cgroup2/ total 4 dr-xr-xr-x 5 root root 0 Sep 2 16:04…
ACC
  • 249
  • 1
  • 4
  • 12
7
votes
1 answer

htop cgroup column widen

How can I see full length of text CGROUP column in htop? I cannot enlarge it.
plaidshirt
  • 261
  • 3
  • 11
7
votes
1 answer

Why are cgroups (blkio serviced bytes) and iotop producing diverging results

I work with lxc user space tools on ubuntu 14.04 and I want to perform some stress tests and benchmarking within a container. I know that free and htop are not working properly in a container. I am using dd and bonnie++ within a container to stress…
7
votes
2 answers

How to do network accounting using cgroups

I am trying to get network statistics for groups of processes. As far as I know, complex network accounting on linux is normally done using the accounting infrastructure of netfilter/iptables. As I'd like to have inheritance for such groups cgroups…
t-8ch
  • 71
  • 2
5
votes
1 answer

The memory usage reported in cgroup differs from the free command

Why would the free command be reporting a much different mem usage number vs cgroup? $ free -b total used free shared buff/cache available Mem: 2096914432 520863744 1112170496 35389440 463880192 …
offbynull
  • 203
  • 2
  • 7
5
votes
2 answers

Why do user and system cpu in cpuacct.stat not add up to cpuacct.usage?

Question relates to Linux cgroups cpu accounting. I noticed this at the container level, but it persists up to top level. For instance: # cat /sys/fs/cgroup/cpu/cpuacct.stat /sys/fs/cgroup/cpu/cpuacct.usage user 34618 system 18038 743932863030 The…
Bryan
  • 334
  • 2
  • 8
5
votes
0 answers

Use of cores with `isolcpus` and `cpuset`

I have a Red Hat Enterprise Linux Server release 6.9 (Santiago) (I don't manage it). In the GRUB config file I have, let's say, isolcpus=2-32 (out of 36 cores). I also have a cgroup with cpuset=2-32 assigned via cgset.conf to all important processes…
Arkadiy
  • 208
  • 1
  • 8
1
2 3
8 9