You are not logged in.

#1 2018-10-28 21:35:15

waldauf
Member
Registered: 2012-07-15
Posts: 137

Limit RAM and CPUs for Chromium (browsers) with cgroups

Sometimes my Chromium eats a lot of RAM and CPUs. I would like to limit its processes. I read how to do it with cgroup managing in Arch and RedHat wiki pages and some other sites. According that I configured my:

$ cat /etc/cgconfig.conf 
mount {
  cpu     = /sys/fs/cgroup/browsers;
  cpuacct = /sys/fs/cgroup/browsers;
  memory  = /sys/fs/cgroup/browsers;
}

group browsers {
#  perm {
#    # Who can manage limits
#    admin {
#      uid = root;
#      gid = users;
#    }
#    # Who can add tasks to this group
#    task {
#      uid = waldauf;
#      gid = users;
#    }
#  }
  cpu {
#   # Set the relative share of CPU resources equal to 25%
    cpu.shares = "256";
  }   
#   # Use max 4 CPUs at time
#  cpuset {
#    cpuset.cpus="0-4"
#  }
  cpuacct {
    cpuacct.usage="0";
  }
  memory {
#   # Allocate at most 1 GB of memory to tasks
    memory.limit_in_bytes = "8G";
#   # Apply a soft limit of 512 MB to tasks
    memory.soft_limit_in_bytes = "6G";
  }   
}

and

$ cat /etc/cgrules.conf
### LIMIT FOR CHROMIUM
# user:process                                subsystems      group
waldauf:/usr/lib/chromium/chromium            cpu,memory      browsers

When I checked configuration I got this error message:

$ sudo cgconfigparser -l /etc/cgconfig.conf
Error: cannot create directory /sys/fs/cgroup/browsers
cgconfigparser; error loading /etc/cgconfig.conf: Cgroup, operation not allowed

After that I commented mount{} then parser run alright. I restarted cgconfig.service in systemd. But in /sys/fs/cgroup/ is not created new browsers cgroup.

$ sudo systemctl restart cgconfig.service
$ ll /sys/fs/cgroup 
total 0
dr-xr-xr-x 2 root root  0 Oct 27 18:55 blkio/
lrwxrwxrwx 1 root root 11 Oct 27 18:55 cpu -> cpu,cpuacct/
dr-xr-xr-x 3 root root  0 Oct 27 18:55 cpu,cpuacct/
lrwxrwxrwx 1 root root 11 Oct 27 18:55 cpuacct -> cpu,cpuacct/
~

What next I tried:
* Create cgroup direcotry in system's /tmp directory. But I got:

sudo cgconfigparser -l /etc/cgconfig.conf
Error: cannot mount cpu to /tmp/cgroup/browsers: Device or resource busy
cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed

* The same error I got createing new tmpfs mount /tmp/cgroup.


Can I ask you for the kick which moves me in the right way? :]

Offline

Board footer

Powered by FluxBB