@@ -138,11 +138,11 @@ With the ability to classify tasks differently for different resources
138
138
the admin can easily set up a script which receives exec notifications
139
139
and depending on who is launching the browser he can
140
140
141
- # echo browser_pid > /mnt /<restype>/<userclass>/tasks
141
+ # echo browser_pid > /sys/fs/cgroup /<restype>/<userclass>/tasks
142
142
143
143
With only a single hierarchy, he now would potentially have to create
144
144
a separate cgroup for every browser launched and associate it with
145
- approp network and other resource class. This may lead to
145
+ appropriate network and other resource class. This may lead to
146
146
proliferation of such cgroups.
147
147
148
148
Also lets say that the administrator would like to give enhanced network
@@ -153,9 +153,9 @@ apps enhanced CPU power,
153
153
With ability to write pids directly to resource classes, it's just a
154
154
matter of :
155
155
156
- # echo pid > /mnt /network/<new_class>/tasks
156
+ # echo pid > /sys/fs/cgroup /network/<new_class>/tasks
157
157
(after some time)
158
- # echo pid > /mnt /network/<orig_class>/tasks
158
+ # echo pid > /sys/fs/cgroup /network/<orig_class>/tasks
159
159
160
160
Without this ability, he would have to split the cgroup into
161
161
multiple separate ones and then associate the new cgroups with the
@@ -310,21 +310,24 @@ subsystem, this is the case for the cpuset.
310
310
To start a new job that is to be contained within a cgroup, using
311
311
the "cpuset" cgroup subsystem, the steps are something like:
312
312
313
- 1) mkdir /dev/cgroup
314
- 2) mount -t cgroup -ocpuset cpuset /dev/cgroup
315
- 3) Create the new cgroup by doing mkdir's and write's (or echo's) in
316
- the /dev/cgroup virtual file system.
317
- 4) Start a task that will be the "founding father" of the new job.
318
- 5) Attach that task to the new cgroup by writing its pid to the
319
- /dev/cgroup tasks file for that cgroup.
320
- 6) fork, exec or clone the job tasks from this founding father task.
313
+ 1) mount -t tmpfs cgroup_root /sys/fs/cgroup
314
+ 2) mkdir /sys/fs/cgroup/cpuset
315
+ 3) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
316
+ 4) Create the new cgroup by doing mkdir's and write's (or echo's) in
317
+ the /sys/fs/cgroup virtual file system.
318
+ 5) Start a task that will be the "founding father" of the new job.
319
+ 6) Attach that task to the new cgroup by writing its pid to the
320
+ /sys/fs/cgroup/cpuset/tasks file for that cgroup.
321
+ 7) fork, exec or clone the job tasks from this founding father task.
321
322
322
323
For example, the following sequence of commands will setup a cgroup
323
324
named "Charlie", containing just CPUs 2 and 3, and Memory Node 1,
324
325
and then start a subshell 'sh' in that cgroup:
325
326
326
- mount -t cgroup cpuset -ocpuset /dev/cgroup
327
- cd /dev/cgroup
327
+ mount -t tmpfs cgroup_root /sys/fs/cgroup
328
+ mkdir /sys/fs/cgroup/cpuset
329
+ mount -t cgroup cpuset -ocpuset /sys/fs/cgroup/cpuset
330
+ cd /sys/fs/cgroup/cpuset
328
331
mkdir Charlie
329
332
cd Charlie
330
333
/bin/echo 2-3 > cpuset.cpus
@@ -345,7 +348,7 @@ Creating, modifying, using the cgroups can be done through the cgroup
345
348
virtual filesystem.
346
349
347
350
To mount a cgroup hierarchy with all available subsystems, type:
348
- # mount -t cgroup xxx /dev /cgroup
351
+ # mount -t cgroup xxx /sys/fs /cgroup
349
352
350
353
The "xxx" is not interpreted by the cgroup code, but will appear in
351
354
/proc/mounts so may be any useful identifying string that you like.
@@ -354,23 +357,32 @@ Note: Some subsystems do not work without some user input first. For instance,
354
357
if cpusets are enabled the user will have to populate the cpus and mems files
355
358
for each new cgroup created before that group can be used.
356
359
360
+ As explained in section `1.2 Why are cgroups needed?' you should create
361
+ different hierarchies of cgroups for each single resource or group of
362
+ resources you want to control. Therefore, you should mount a tmpfs on
363
+ /sys/fs/cgroup and create directories for each cgroup resource or resource
364
+ group.
365
+
366
+ # mount -t tmpfs cgroup_root /sys/fs/cgroup
367
+ # mkdir /sys/fs/cgroup/rg1
368
+
357
369
To mount a cgroup hierarchy with just the cpuset and memory
358
370
subsystems, type:
359
- # mount -t cgroup -o cpuset,memory hier1 /dev/ cgroup
371
+ # mount -t cgroup -o cpuset,memory hier1 /sys/fs/ cgroup/rg1
360
372
361
373
To change the set of subsystems bound to a mounted hierarchy, just
362
374
remount with different options:
363
- # mount -o remount,cpuset,blkio hier1 /dev/ cgroup
375
+ # mount -o remount,cpuset,blkio hier1 /sys/fs/ cgroup/rg1
364
376
365
377
Now memory is removed from the hierarchy and blkio is added.
366
378
367
379
Note this will add blkio to the hierarchy but won't remove memory or
368
380
cpuset, because the new options are appended to the old ones:
369
- # mount -o remount,blkio /dev/ cgroup
381
+ # mount -o remount,blkio /sys/fs/ cgroup/rg1
370
382
371
383
To Specify a hierarchy's release_agent:
372
384
# mount -t cgroup -o cpuset,release_agent="/sbin/cpuset_release_agent" \
373
- xxx /dev/ cgroup
385
+ xxx /sys/fs/ cgroup/rg1
374
386
375
387
Note that specifying 'release_agent' more than once will return failure.
376
388
@@ -379,17 +391,17 @@ when the hierarchy consists of a single (root) cgroup. Supporting
379
391
the ability to arbitrarily bind/unbind subsystems from an existing
380
392
cgroup hierarchy is intended to be implemented in the future.
381
393
382
- Then under /dev/ cgroup you can find a tree that corresponds to the
383
- tree of the cgroups in the system. For instance, /dev/ cgroup
394
+ Then under /sys/fs/ cgroup/rg1 you can find a tree that corresponds to the
395
+ tree of the cgroups in the system. For instance, /sys/fs/ cgroup/rg1
384
396
is the cgroup that holds the whole system.
385
397
386
398
If you want to change the value of release_agent:
387
- # echo "/sbin/new_release_agent" > /dev/ cgroup/release_agent
399
+ # echo "/sbin/new_release_agent" > /sys/fs/ cgroup/rg1 /release_agent
388
400
389
401
It can also be changed via remount.
390
402
391
- If you want to create a new cgroup under /dev/ cgroup:
392
- # cd /dev/ cgroup
403
+ If you want to create a new cgroup under /sys/fs/ cgroup/rg1 :
404
+ # cd /sys/fs/ cgroup/rg1
393
405
# mkdir my_cgroup
394
406
395
407
Now you want to do something with this cgroup.
0 commit comments