aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-08-04 15:20:55 -0400
committerTejun Heo <tj@kernel.org>2015-08-04 15:20:55 -0400
commit6abc8ca19df0078de17dc38340db3002ed489ce7 (patch)
tree126fd69e8b4645e1da77f26ec73ea711e7b2165f
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
cgroup: define controller file conventions
Traditionally, each cgroup controller implemented whatever interface it wanted leading to interfaces which are widely inconsistent. Examining the requirements of the controllers readily yield that there are only a few control schemes shared among all. Two major controllers already had to implement new interface for the unified hierarchy due to significant structural changes. Let's take the chance to establish common conventions throughout all controllers. This patch defines CGROUP_WEIGHT_MIN/DFL/MAX to be used on all weight based control knobs and documents the conventions that controllers should follow on the unified hierarchy. Except for io.weight knob, all existing unified hierarchy knobs are already compliant. A follow-up patch will update io.weight. v2: Added descriptions of min, low and high knobs. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Li Zefan <lizefan@huawei.com> Cc: Peter Zijlstra <peterz@infradead.org>
-rw-r--r--Documentation/cgroups/unified-hierarchy.txt80
-rw-r--r--include/linux/cgroup.h9
2 files changed, 81 insertions, 8 deletions
diff --git a/Documentation/cgroups/unified-hierarchy.txt b/Documentation/cgroups/unified-hierarchy.txt
index 86847a7647ab..1ee9caf29e57 100644
--- a/Documentation/cgroups/unified-hierarchy.txt
+++ b/Documentation/cgroups/unified-hierarchy.txt
@@ -23,10 +23,13 @@ CONTENTS
235. Other Changes 235. Other Changes
24 5-1. [Un]populated Notification 24 5-1. [Un]populated Notification
25 5-2. Other Core Changes 25 5-2. Other Core Changes
26 5-3. Per-Controller Changes 26 5-3. Controller File Conventions
27 5-3-1. blkio 27 5-3-1. Format
28 5-3-2. cpuset 28 5-3-2. Control Knobs
29 5-3-3. memory 29 5-4. Per-Controller Changes
30 5-4-1. blkio
31 5-4-2. cpuset
32 5-4-3. memory
306. Planned Changes 336. Planned Changes
31 6-1. CAP for resource control 34 6-1. CAP for resource control
32 35
@@ -372,14 +375,75 @@ supported and the interface files "release_agent" and
372- The "cgroup.clone_children" file is removed. 375- The "cgroup.clone_children" file is removed.
373 376
374 377
3755-3. Per-Controller Changes 3785-3. Controller File Conventions
376 379
3775-3-1. blkio 3805-3-1. Format
381
382In general, all controller files should be in one of the following
383formats whenever possible.
384
385- Values only files
386
387 VAL0 VAL1...\n
388
389- Flat keyed files
390
391 KEY0 VAL0\n
392 KEY1 VAL1\n
393 ...
394
395- Nested keyed files
396
397 KEY0 SUB_KEY0=VAL00 SUB_KEY1=VAL01...
398 KEY1 SUB_KEY0=VAL10 SUB_KEY1=VAL11...
399 ...
400
401For a writeable file, the format for writing should generally match
402reading; however, controllers may allow omitting later fields or
403implement restricted shortcuts for most common use cases.
404
405For both flat and nested keyed files, only the values for a single key
406can be written at a time. For nested keyed files, the sub key pairs
407may be specified in any order and not all pairs have to be specified.
408
409
4105-3-2. Control Knobs
411
412- Settings for a single feature should generally be implemented in a
413 single file.
414
415- In general, the root cgroup should be exempt from resource control
416 and thus shouldn't have resource control knobs.
417
418- If a controller implements ratio based resource distribution, the
419 control knob should be named "weight" and have the range [1, 10000]
420 and 100 should be the default value. The values are chosen to allow
421 enough and symmetric bias in both directions while keeping it
422 intuitive (the default is 100%).
423
424- If a controller implements an absolute resource guarantee and/or
425 limit, the control knobs should be named "min" and "max"
426 respectively. If a controller implements best effort resource
427 gurantee and/or limit, the control knobs should be named "low" and
428 "high" respectively.
429
430 In the above four control files, the special token "max" should be
431 used to represent upward infinity for both reading and writing.
432
433- If a setting has configurable default value and specific overrides,
434 the default settings should be keyed with "default" and appear as
435 the first entry in the file. Specific entries can use "default" as
436 its value to indicate inheritance of the default value.
437
438
4395-4. Per-Controller Changes
440
4415-4-1. blkio
378 442
379- blk-throttle becomes properly hierarchical. 443- blk-throttle becomes properly hierarchical.
380 444
381 445
3825-3-2. cpuset 4465-4-2. cpuset
383 447
384- Tasks are kept in empty cpusets after hotplug and take on the masks 448- Tasks are kept in empty cpusets after hotplug and take on the masks
385 of the nearest non-empty ancestor, instead of being moved to it. 449 of the nearest non-empty ancestor, instead of being moved to it.
@@ -388,7 +452,7 @@ supported and the interface files "release_agent" and
388 masks of the nearest non-empty ancestor. 452 masks of the nearest non-empty ancestor.
389 453
390 454
3915-3-3. memory 4555-4-3. memory
392 456
393- use_hierarchy is on by default and the cgroup file for the flag is 457- use_hierarchy is on by default and the cgroup file for the flag is
394 not created. 458 not created.
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index a593e299162e..c6bf9d30c270 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -22,6 +22,15 @@
22 22
23#ifdef CONFIG_CGROUPS 23#ifdef CONFIG_CGROUPS
24 24
25/*
26 * All weight knobs on the default hierarhcy should use the following min,
27 * default and max values. The default value is the logarithmic center of
28 * MIN and MAX and allows 100x to be expressed in both directions.
29 */
30#define CGROUP_WEIGHT_MIN 1
31#define CGROUP_WEIGHT_DFL 100
32#define CGROUP_WEIGHT_MAX 10000
33
25/* a css_task_iter should be treated as an opaque object */ 34/* a css_task_iter should be treated as an opaque object */
26struct css_task_iter { 35struct css_task_iter {
27 struct cgroup_subsys *ss; 36 struct cgroup_subsys *ss;