Cgroups) (Plus Some Systemd Evangelizing) Who Am I?

Cgroups) (Plus Some Systemd Evangelizing) Who Am I?

An introduction to Control Groups (cgroups) (plus some systemd evangelizing) Who am I? Jonathan maw (not James Thomas) [email protected] Responsibilities: ● GENIVI Node Startup Controller ● AGL Distro OS/Common Libs maintainer Automotive experience: since June 2012 cgroup experience: since Sep 01 2015 What are cgroups? /sys/fs/cgroup/ … ↳blkio hierarchical grouping of processes managed by the linux ↳cpu kernel, and exposed through a special filesystem ↳memory ↳net_cls # cat /sys/fs/cgroup/systemd/system.slice/ssh.service/tasks ↳systemd 622 … ↳user.slice ↳system.slice (systemd-cgls) … ↳ssh.service ↳cgroup.clone_children ↳cgroup.procs ↳notify_on_release ↳tasks Why use cgroups? /sys/fs/cgroup/ … ↳blkio subsystems/controllers ↳cpu https://www.kernel.org/doc/Documentation/cgroups/ ↳memory ↳devices Lots of features, the most useful ones I see: ↳systemd ● Control memory usage … ● Control how much CPU time is allocated ↳user.slice ● Control how much device I/O is allowed ↳system.slice ● Control which devices can be accessed … ↳ssh.service Horror story: memory leak in browser kills system ↳cgroup.clone_children ↳cgroup.procs ↳notify_on_release ↳tasks Why I’d recommend systemd Systemd uses cgroups to organise processes (each service is a cgroup, and all processes started by that service use that cgroup) Systemd handles blkio, cpu, device, and memory accounting for you (http://man7. org/linux/man-pages/man5/systemd.cgroup.5.html) [Service] ExecStart=/bin/foo MemoryAccounting=true MemoryLimit=400K (also systemd-cgtop, systemd-cgls) Demonstration top -d1 top -d1 echo “+1000” > /proc/$(pidof top)/oom_score_adj echo “+1000” > /proc/$(pidof top)/oom_score_adj ./memory-hog (OOM kills top, then memory-hog) systemctl start memory-hog (OOM kills memory-hog) cat >/etc/systemd/system/memory-hog.service <<EOF [Unit] Description=Memory Hog Service [Service] ExecStart=/home/user/memory-hog MemoryAccounting=true MemoryLimit=400K An example hierarchy for an HMI system.slice -> weston dbus can-message-app hmiapp.slice -> clock.service map.service navigation.service rtaudio.slice -> alerts.service music.service navigation-assistant.service rt.slice -> rearview.service Why not? systemd: cgroups: ● Doesn’t do every feature of cgroups. ● the subsystem controllers (memory, etc.) ● e.g. if you want cpu scheduling, you may have a performance cost - is it an want to disable systemd’s use of the CPU acceptable cost? controller, and handle CPU scheduling, yourself. ● If you want network priority, you’ll have to handle it yourself. ● alternative: http://libcg.sourceforge.net/ .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us