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

138 questions
2
votes
1 answer

Limiting a process' network access on Linux?

I've been researching how to sandbox processes, and I came across cgroups, which looked promising. I'm not super interested in using virtualization or strace for this, since I want programs to run as fast as possible. I'm also aware of…
HFLW
  • 123
  • 4
2
votes
1 answer

OpenNebula-managed libvirt not allowing access to /dev/kvm

I have a fresh Open Nebula 3.2.1 installation which I'm trying to get working and manage some freshly-installed debian squeeze kvm hosts. My problem is that when Open Nebula deploys VMs the KVM process does not have access to the /dev/kvm device on…
MikeyB
  • 39,291
  • 10
  • 105
  • 189
2
votes
2 answers

How can I be notified when the limit of a cgroup is hit?

I want to use cgroups to limit resources in linux http://en.wikipedia.org/wiki/Cgroups How can I be notified when a limit if hit. For example if I limit a process to 2 gigs or ram how will I know when that is reached if I am not actively monitoring…
ckliborn
  • 2,778
  • 4
  • 25
  • 37
2
votes
2 answers

Isolating CPUs on AWS/GCP: error mounting cpuset

I have two 32 vCPU instances on AWS/GCP. I'm trying to set up cpu shielding so that CPUs 0, 1 are used by the system, and cpus 2-31 are shielded and only used explicitly by userspace threads. System info: Distributor ID: Ubuntu Description: …
2
votes
1 answer

How to use cgroup v2 to limit memory and cpu per user group?

With cgroup v1, I can have group configuration in cgconfig.conf and assign groups to different users in cgrules.conf However, it seems to me that cgconfig and cgrules can't be used along with cgroup v2. The only way I know to use cgroup v2 is to…
Lei Yu
  • 21
  • 2
2
votes
1 answer

Limit php-fpm memory usage on a constrained server

I "move" this question from superuser as I think it's more appropiate here. I've actually found sort-of duplicate questions, but none has solved my problem. General scope I have a Nextcloud (php) instance running in a Olimex LIME2 home server, which…
raneq
  • 21
  • 3
2
votes
1 answer

systemd: how do I create a new .slice file?

I'm struggling to understand how to set up a new slice on my debian 10 system. I have created a file, system-db.slice by copying system.slice and changing a couple of things: # This file is part of systemd. # # systemd is free software; you can…
j4nd3r53n
  • 226
  • 3
  • 14
2
votes
0 answers

How can I control how systemd assigns a service to a slice?

I have been searching for a while for information about how services are assigned to slices - it seems to be a very elusive subject, or maybe I'm not asking the right questions. I've come across How does systemd put sshd processes in slices?, which…
j4nd3r53n
  • 226
  • 3
  • 14
2
votes
1 answer

Unable to set a v1 cgroup limit

I have a pids.max limit set to 400, I want to set it to max It is found in /sys/fs/cgroup/pids/pids.max, sudo cgget -g pids:/ /: pids.current: 278 pids.max: 400 I would think that I could set it by running the following command, but pids.max stays…
Azeirah
  • 161
  • 6
2
votes
0 answers

ClamAV for the host running docker containers - inotify/fanotify limits

I'm implementing anti-virus solution for Linux with ClamAV daemon running in On-Access mode, watching the created/opened files for malicious content at the host system AND in docker containers, running at the host. What limitations I've found so…
mva
  • 141
  • 4
1
vote
2 answers

cgroup rt support in Debian Buster (Kernel 4.19.0)

Is it possible to enable the cgroup rt support in Debian Buster (kernel 4.19.0) without recompiling the kernel? Perhaps with a grub configuration parameter? Thanks. Background: Docker logs this warnings: Your kernel does not support cgroup rt…
erunima
  • 31
  • 3
1
vote
1 answer

How to restrict access to GPU?

I'm configuring a small GPU server under Ubuntu 18.04. It should support both interactive and batch jobs. It is dedicated to run machine learning tasks by a small team. We have also some tasks for massive parallel data processing on CPU-only. My…
wl2776
  • 181
  • 1
  • 9
1
vote
1 answer

What's the recommended way to deal with controled processes if CGroups fails?

I've been using the service unit bellow to start a couple of process that happens to have a high CPU and disk bandwidth usage when running. Since the processes I want to limit don't have a way to indicate how much resources they should take, I've…
rraallvv
  • 123
  • 6
1
vote
2 answers

systemd deletes sub-cgroups started by other services

I have a service (HTCondor batch system), which is started as service unit within cpu,cpuacct and memory cgroup slices (CentOS 7 @ 3.10.0-*). The service starts sub-processes (~~> batch jobs) for which it creates sub-slices, i.e., subdividing its…
THX
  • 243
  • 2
  • 10
1
vote
1 answer

Page cache usage listed in cgroup's memory.stat file

A cgroup's memory.stat file lists the page cache usage for that cgroup (in cache and total_cache fields). How is the page cache usage derived? For example, file a.txt is opened by both cgroup A and B. Do A and B both maintain their own cache of…
offbynull
  • 223
  • 1
  • 3
  • 7