The userspace solution for control groups Linux Kongress 2010 - - PowerPoint PPT Presentation

the userspace solution for control groups
SMART_READER_LITE
LIVE PREVIEW

The userspace solution for control groups Linux Kongress 2010 - - PowerPoint PPT Presentation

The userspace solution for control groups Linux Kongress 2010 Dhaval Giani dhaval.giani@gmail.com RETIS Lab, Scuola Superiore SantAnna September 2010 Dhaval Giani The userspace solution for control groups Control Groups What are cgroups?


slide-1
SLIDE 1

The userspace solution for control groups

Linux Kongress 2010 Dhaval Giani dhaval.giani@gmail.com

RETIS Lab, Scuola Superiore Sant’Anna

September 2010

Dhaval Giani The userspace solution for control groups

slide-2
SLIDE 2

Control Groups

What are cgroups?

Dhaval Giani The userspace solution for control groups

slide-3
SLIDE 3

Control Groups

What are cgroups? Well, the last talk should have covered it

Dhaval Giani The userspace solution for control groups

slide-4
SLIDE 4

Control Groups

cgroups should die.

  • Peter Zijlstra

Dhaval Giani The userspace solution for control groups

slide-5
SLIDE 5

Control Groups

Next time something is added to the kernel please mark it as ”Hey, please don’t use it, this is only here so that you don’t use it. Thanks!” Maybe then dumb-ass folks like me will notice and refrain from using it.

  • Lennart Poettering

Dhaval Giani The userspace solution for control groups

slide-6
SLIDE 6

libcgroup

Looks to provide a programming interface without the programmer having to care about how cgroups are setup.

Dhaval Giani The userspace solution for control groups

slide-7
SLIDE 7

libcgroup

Looks to provide a programming interface without the programmer having to care about how cgroups are setup. Tools

Dhaval Giani The userspace solution for control groups

slide-8
SLIDE 8

libcgroup

Looks to provide a programming interface without the programmer having to care about how cgroups are setup. Tools Library

Dhaval Giani The userspace solution for control groups

slide-9
SLIDE 9

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots.

Dhaval Giani The userspace solution for control groups

slide-10
SLIDE 10

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies

Dhaval Giani The userspace solution for control groups

slide-11
SLIDE 11

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies

Dhaval Giani The userspace solution for control groups

slide-12
SLIDE 12

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup

Dhaval Giani The userspace solution for control groups

slide-13
SLIDE 13

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup cgred - Automatic classification daemon originally based on user classfication.

Dhaval Giani The userspace solution for control groups

slide-14
SLIDE 14

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup cgred - Automatic classification daemon originally based on user classfication. Now enhanced for process based classification as well.

Dhaval Giani The userspace solution for control groups

slide-15
SLIDE 15

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup cgred - Automatic classification daemon originally based on user classfication. Now enhanced for process based classification as well. cgset/cgget - List cgroup values

Dhaval Giani The userspace solution for control groups

slide-16
SLIDE 16

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup cgred - Automatic classification daemon originally based on user classfication. Now enhanced for process based classification as well. cgset/cgget - List cgroup values lscgroup - List all cgroups

Dhaval Giani The userspace solution for control groups

slide-17
SLIDE 17

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup cgred - Automatic classification daemon originally based on user classfication. Now enhanced for process based classification as well. cgset/cgget - List cgroup values lscgroup - List all cgroups Some more

Dhaval Giani The userspace solution for control groups

slide-18
SLIDE 18

libcgroup - tools

cgconfigparser - Used for parsing a configuration file and maintaining persistence across reboots. cgclear - Used to destroy all control group hierarchies unless you use Fedora where it does not touch systemd hierarchies cgexec - Used to start a process in a cgroup cgred - Automatic classification daemon originally based on user classfication. Now enhanced for process based classification as well. cgset/cgget - List cgroup values lscgroup - List all cgroups Some more cgsnapshot - Under review right now, to generate configurations from current setup.

Dhaval Giani The userspace solution for control groups

slide-19
SLIDE 19

libcgroup - tools

Basically trying to cover a good set of requirements from the administrator’s point of view.

Dhaval Giani The userspace solution for control groups

slide-20
SLIDE 20

libcgroup - library

Three main types of API

Dhaval Giani The userspace solution for control groups

slide-21
SLIDE 21

libcgroup - library

Three main types of API cgroup manipulation API

Dhaval Giani The userspace solution for control groups

slide-22
SLIDE 22

libcgroup - library

Three main types of API cgroup manipulation API data structure manipulation API

Dhaval Giani The userspace solution for control groups

slide-23
SLIDE 23

libcgroup - library

Three main types of API cgroup manipulation API data structure manipulation API configuration API

Dhaval Giani The userspace solution for control groups

slide-24
SLIDE 24

libcgroup API

The manipulation API

Dhaval Giani The userspace solution for control groups

slide-25
SLIDE 25

libcgroup API

The manipulation API cgroup init

Dhaval Giani The userspace solution for control groups

slide-26
SLIDE 26

libcgroup API

The manipulation API cgroup init cgroup create cgroup

Dhaval Giani The userspace solution for control groups

slide-27
SLIDE 27

libcgroup API

The manipulation API cgroup init cgroup create cgroup cgroup modify cgroup

Dhaval Giani The userspace solution for control groups

slide-28
SLIDE 28

libcgroup API

The manipulation API cgroup init cgroup create cgroup cgroup modify cgroup cgroup delete cgroup

Dhaval Giani The userspace solution for control groups

slide-29
SLIDE 29

libcgroup API

The manipulation API cgroup init cgroup create cgroup cgroup modify cgroup cgroup delete cgroup cgroup get cgroup

Dhaval Giani The userspace solution for control groups

slide-30
SLIDE 30

libcgroup API

The manipulation API cgroup init cgroup create cgroup cgroup modify cgroup cgroup delete cgroup cgroup get cgroup some more

Dhaval Giani The userspace solution for control groups

slide-31
SLIDE 31

libcgroup API

Used to modify the cgroup data structure

Dhaval Giani The userspace solution for control groups

slide-32
SLIDE 32

libcgroup API

Used to modify the cgroup data structure which is the main data structure describing the cgroup

Dhaval Giani The userspace solution for control groups

slide-33
SLIDE 33

libcgroup API

Used to modify the cgroup data structure which is the main data structure describing the cgroup cgroup new cgroup

Dhaval Giani The userspace solution for control groups

slide-34
SLIDE 34

libcgroup API

Used to modify the cgroup data structure which is the main data structure describing the cgroup cgroup new cgroup cgroup add controller

Dhaval Giani The userspace solution for control groups

slide-35
SLIDE 35

libcgroup API

Used to modify the cgroup data structure which is the main data structure describing the cgroup cgroup new cgroup cgroup add controller cgroup add value family

Dhaval Giani The userspace solution for control groups

slide-36
SLIDE 36

libcgroup API

Used to modify the cgroup data structure which is the main data structure describing the cgroup cgroup new cgroup cgroup add controller cgroup add value family cgroup [sg]et uid gid

Dhaval Giani The userspace solution for control groups

slide-37
SLIDE 37

libcgroup API

Used by cgconfigparser and cgclear.

Dhaval Giani The userspace solution for control groups

slide-38
SLIDE 38

libcgroup API

Used by cgconfigparser and cgclear. Used to load the configuration file, both for the superuser and the regular user (the so called cascaded configurations).

Dhaval Giani The userspace solution for control groups

slide-39
SLIDE 39

libcgroup API

Used by cgconfigparser and cgclear. Used to load the configuration file, both for the superuser and the regular user (the so called cascaded configurations). Not yet implemented for cgclear, but its on its way.

Dhaval Giani The userspace solution for control groups

slide-40
SLIDE 40

Issues

Written by kernel developers!

Dhaval Giani The userspace solution for control groups

slide-41
SLIDE 41

Issues

Written by kernel developers! So thread safe

Dhaval Giani The userspace solution for control groups

slide-42
SLIDE 42

Issues

Written by kernel developers! So thread safe as opposed to thread aware!

Dhaval Giani The userspace solution for control groups

slide-43
SLIDE 43

Issues

Written by kernel developers! So thread safe as opposed to thread aware! The locking model is being modified at git://libcg.git.sf.net/gitroot/libcg/ libcgroup-context.git

Dhaval Giani The userspace solution for control groups

slide-44
SLIDE 44

Issues

Key Goal - Subsystem Independent Programming.

Dhaval Giani The userspace solution for control groups

slide-45
SLIDE 45

Issues

Key Goal - Subsystem Independent Programming. Or Programmer should not care how subsystems are mounted.

Dhaval Giani The userspace solution for control groups

slide-46
SLIDE 46

Subsystem Independent Programming

Programmer does not need to bother where cgroups are mounted

Dhaval Giani The userspace solution for control groups

slide-47
SLIDE 47

Subsystem Independent Programming

Programmer does not need to bother where cgroups are mounted But the how still has to be bothered about

Dhaval Giani The userspace solution for control groups

slide-48
SLIDE 48

Subsystem Independent Programming

Programmer does not need to bother where cgroups are mounted But the how still has to be bothered about Blame the cgroup developers for that

Dhaval Giani The userspace solution for control groups

slide-49
SLIDE 49

Subsystem Independent Programming

Consider the following two scenarios

Dhaval Giani The userspace solution for control groups

slide-50
SLIDE 50

Subsystem Independent Programming

Consider the following two scenarios mount -t cgroup -o memory,cpuset cgroup /cgroup

Dhaval Giani The userspace solution for control groups

slide-51
SLIDE 51

Subsystem Independent Programming

Consider the following two scenarios mount -t cgroup -o memory,cpuset cgroup /cgroup and

Dhaval Giani The userspace solution for control groups

slide-52
SLIDE 52

Subsystem Independent Programming

Consider the following two scenarios mount -t cgroup -o memory,cpuset cgroup /cgroup and mount -t cgroup -o cpuset cpuset /cgroup/cpuset mount -t cgroup -o memory memory /cgroup/memory

Dhaval Giani The userspace solution for control groups

slide-53
SLIDE 53

Subsystem Independent Programming

Consider the following two scenarios mount -t cgroup -o memory,cpuset cgroup /cgroup and mount -t cgroup -o cpuset cpuset /cgroup/cpuset mount -t cgroup -o memory memory /cgroup/memory What is the main difference between the two from a programmer’s point of view?

Dhaval Giani The userspace solution for control groups

slide-54
SLIDE 54

Subsystem Independent Programming

Simple solution

Dhaval Giani The userspace solution for control groups

slide-55
SLIDE 55

Subsystem Independent Programming

Simple solution Copy the values from the parent

Dhaval Giani The userspace solution for control groups

slide-56
SLIDE 56

Subsystem Independent Programming

Consider another scenario

Dhaval Giani The userspace solution for control groups

slide-57
SLIDE 57

Subsystem Independent Programming

Consider another scenario mount -t cgroup -o cpu,cpuset cgroup /cgroup

Dhaval Giani The userspace solution for control groups

slide-58
SLIDE 58

Subsystem Independent Programming

Consider another scenario mount -t cgroup -o cpu,cpuset cgroup /cgroup Well, the simple solution does fail quite spectacularly

Dhaval Giani The userspace solution for control groups

slide-59
SLIDE 59

Subsystem Independent Programming

We do have another problem

Dhaval Giani The userspace solution for control groups

slide-60
SLIDE 60

Subsystem Independent Programming

We do have another problem Programmer still needs to know the internals of the subsystem he wants to manipulate

Dhaval Giani The userspace solution for control groups

slide-61
SLIDE 61

Subsystem Independent Programming

Layer 2

Dhaval Giani The userspace solution for control groups

slide-62
SLIDE 62

Subsystem Independent Programming

Layer 2 Subsystem specific programming

Dhaval Giani The userspace solution for control groups

slide-63
SLIDE 63

Subsystem Independent Programming

Layer 2 Subsystem specific programming Possibility of callbacks

Dhaval Giani The userspace solution for control groups

slide-64
SLIDE 64

Subsystem Independent Programming

Layer 2 Subsystem specific programming Possibility of callbacks Hiding some of the subsystem complexity

Dhaval Giani The userspace solution for control groups

slide-65
SLIDE 65

Subsystem Independent Programming

But is that the complete solution?

Dhaval Giani The userspace solution for control groups

slide-66
SLIDE 66

Subsystem Independent Programming

But is that the complete solution? Not really

Dhaval Giani The userspace solution for control groups

slide-67
SLIDE 67

Subsystem Independent Programming

But is that the complete solution? Not really We need to modify both the kernel and the userspace!

Dhaval Giani The userspace solution for control groups

slide-68
SLIDE 68

libcgroup

Not a bad start, but still a long way to go!

Dhaval Giani The userspace solution for control groups

slide-69
SLIDE 69

Questions?

Dhaval Giani The userspace solution for control groups

slide-70
SLIDE 70

Thank you!

Dhaval Giani The userspace solution for control groups