diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-30 18:09:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-30 18:09:47 -0500 |
commit | 13ddd1667e7f01071cdf120132238ffca004a88e (patch) | |
tree | 6cd3cae74cc6a7e9d5e5292600623c8533a3fa7c | |
parent | 289104c9a45cf27e80fa7b04286ada22f4e964fe (diff) | |
parent | 03eac8b22194becd77d253fc546429ebb544aebf (diff) |
Merge branch 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo:
"Nothing too interesting. Documentation updates and trivial changes;
however, this pull request does containt he previusly discussed
dropping of __must_check from strscpy()"
* 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
Documentation: Fix 'file_mapped' -> 'mapped_file'
string: drop __must_check from strscpy() and restore strscpy() usages in cgroup
cgroup, docs: document the root cgroup behavior of cpu and io controllers
cgroup-v2.txt: fix typos
cgroup: Update documentation reference
Documentation/cgroup-v1: fix outdated programming details
cgroup, docs: document cgroup v2 device controller
-rw-r--r-- | Documentation/cgroup-v1/cgroups.txt | 7 | ||||
-rw-r--r-- | Documentation/cgroup-v1/memory.txt | 4 | ||||
-rw-r--r-- | Documentation/cgroup-v2.txt | 77 | ||||
-rw-r--r-- | include/linux/cgroup-defs.h | 2 | ||||
-rw-r--r-- | include/linux/string.h | 2 | ||||
-rw-r--r-- | kernel/cgroup/cgroup.c | 6 |
6 files changed, 76 insertions, 22 deletions
diff --git a/Documentation/cgroup-v1/cgroups.txt b/Documentation/cgroup-v1/cgroups.txt index 308e5ff7207a..059f7063eea6 100644 --- a/Documentation/cgroup-v1/cgroups.txt +++ b/Documentation/cgroup-v1/cgroups.txt | |||
@@ -523,12 +523,7 @@ Accessing a task's cgroup pointer may be done in the following ways: | |||
523 | Each subsystem should: | 523 | Each subsystem should: |
524 | 524 | ||
525 | - add an entry in linux/cgroup_subsys.h | 525 | - add an entry in linux/cgroup_subsys.h |
526 | - define a cgroup_subsys object called <name>_subsys | 526 | - define a cgroup_subsys object called <name>_cgrp_subsys |
527 | |||
528 | If a subsystem can be compiled as a module, it should also have in its | ||
529 | module initcall a call to cgroup_load_subsys(), and in its exitcall a | ||
530 | call to cgroup_unload_subsys(). It should also set its_subsys.module = | ||
531 | THIS_MODULE in its .c file. | ||
532 | 527 | ||
533 | Each subsystem may export the following methods. The only mandatory | 528 | Each subsystem may export the following methods. The only mandatory |
534 | methods are css_alloc/free. Any others that are null are presumed to | 529 | methods are css_alloc/free. Any others that are null are presumed to |
diff --git a/Documentation/cgroup-v1/memory.txt b/Documentation/cgroup-v1/memory.txt index cefb63639070..a4af2e124e24 100644 --- a/Documentation/cgroup-v1/memory.txt +++ b/Documentation/cgroup-v1/memory.txt | |||
@@ -524,9 +524,9 @@ Note: | |||
524 | Only anonymous and swap cache memory is listed as part of 'rss' stat. | 524 | Only anonymous and swap cache memory is listed as part of 'rss' stat. |
525 | This should not be confused with the true 'resident set size' or the | 525 | This should not be confused with the true 'resident set size' or the |
526 | amount of physical memory used by the cgroup. | 526 | amount of physical memory used by the cgroup. |
527 | 'rss + file_mapped" will give you resident set size of cgroup. | 527 | 'rss + mapped_file" will give you resident set size of cgroup. |
528 | (Note: file and shmem may be shared among other cgroups. In that case, | 528 | (Note: file and shmem may be shared among other cgroups. In that case, |
529 | file_mapped is accounted only when the memory cgroup is owner of page | 529 | mapped_file is accounted only when the memory cgroup is owner of page |
530 | cache.) | 530 | cache.) |
531 | 531 | ||
532 | 5.3 swappiness | 532 | 5.3 swappiness |
diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index 2cddab7efb20..74cdeaed9f7a 100644 --- a/Documentation/cgroup-v2.txt +++ b/Documentation/cgroup-v2.txt | |||
@@ -53,10 +53,14 @@ v1 is available under Documentation/cgroup-v1/. | |||
53 | 5-3-2. Writeback | 53 | 5-3-2. Writeback |
54 | 5-4. PID | 54 | 5-4. PID |
55 | 5-4-1. PID Interface Files | 55 | 5-4-1. PID Interface Files |
56 | 5-5. RDMA | 56 | 5-5. Device |
57 | 5-5-1. RDMA Interface Files | 57 | 5-6. RDMA |
58 | 5-6. Misc | 58 | 5-6-1. RDMA Interface Files |
59 | 5-6-1. perf_event | 59 | 5-7. Misc |
60 | 5-7-1. perf_event | ||
61 | 5-N. Non-normative information | ||
62 | 5-N-1. CPU controller root cgroup process behaviour | ||
63 | 5-N-2. IO controller root cgroup process behaviour | ||
60 | 6. Namespace | 64 | 6. Namespace |
61 | 6-1. Basics | 65 | 6-1. Basics |
62 | 6-2. The Root and Views | 66 | 6-2. The Root and Views |
@@ -279,7 +283,7 @@ thread mode, the following conditions must be met. | |||
279 | exempt from this requirement. | 283 | exempt from this requirement. |
280 | 284 | ||
281 | Topology-wise, a cgroup can be in an invalid state. Please consider | 285 | Topology-wise, a cgroup can be in an invalid state. Please consider |
282 | the following toplogy:: | 286 | the following topology:: |
283 | 287 | ||
284 | A (threaded domain) - B (threaded) - C (domain, just created) | 288 | A (threaded domain) - B (threaded) - C (domain, just created) |
285 | 289 | ||
@@ -420,7 +424,9 @@ The root cgroup is exempt from this restriction. Root contains | |||
420 | processes and anonymous resource consumption which can't be associated | 424 | processes and anonymous resource consumption which can't be associated |
421 | with any other cgroups and requires special treatment from most | 425 | with any other cgroups and requires special treatment from most |
422 | controllers. How resource consumption in the root cgroup is governed | 426 | controllers. How resource consumption in the root cgroup is governed |
423 | is up to each controller. | 427 | is up to each controller (for more information on this topic please |
428 | refer to the Non-normative information section in the Controllers | ||
429 | chapter). | ||
424 | 430 | ||
425 | Note that the restriction doesn't get in the way if there is no | 431 | Note that the restriction doesn't get in the way if there is no |
426 | enabled controller in the cgroup's "cgroup.subtree_control". This is | 432 | enabled controller in the cgroup's "cgroup.subtree_control". This is |
@@ -1063,10 +1069,10 @@ PAGE_SIZE multiple when read back. | |||
1063 | reached the limit and allocation was about to fail. | 1069 | reached the limit and allocation was about to fail. |
1064 | 1070 | ||
1065 | Depending on context result could be invocation of OOM | 1071 | Depending on context result could be invocation of OOM |
1066 | killer and retrying allocation or failing alloction. | 1072 | killer and retrying allocation or failing allocation. |
1067 | 1073 | ||
1068 | Failed allocation in its turn could be returned into | 1074 | Failed allocation in its turn could be returned into |
1069 | userspace as -ENOMEM or siletly ignored in cases like | 1075 | userspace as -ENOMEM or silently ignored in cases like |
1070 | disk readahead. For now OOM in memory cgroup kills | 1076 | disk readahead. For now OOM in memory cgroup kills |
1071 | tasks iff shortage has happened inside page fault. | 1077 | tasks iff shortage has happened inside page fault. |
1072 | 1078 | ||
@@ -1191,7 +1197,7 @@ PAGE_SIZE multiple when read back. | |||
1191 | cgroups. The default is "max". | 1197 | cgroups. The default is "max". |
1192 | 1198 | ||
1193 | Swap usage hard limit. If a cgroup's swap usage reaches this | 1199 | Swap usage hard limit. If a cgroup's swap usage reaches this |
1194 | limit, anonymous meomry of the cgroup will not be swapped out. | 1200 | limit, anonymous memory of the cgroup will not be swapped out. |
1195 | 1201 | ||
1196 | 1202 | ||
1197 | Usage Guidelines | 1203 | Usage Guidelines |
@@ -1429,6 +1435,30 @@ through fork() or clone(). These will return -EAGAIN if the creation | |||
1429 | of a new process would cause a cgroup policy to be violated. | 1435 | of a new process would cause a cgroup policy to be violated. |
1430 | 1436 | ||
1431 | 1437 | ||
1438 | Device controller | ||
1439 | ----------------- | ||
1440 | |||
1441 | Device controller manages access to device files. It includes both | ||
1442 | creation of new device files (using mknod), and access to the | ||
1443 | existing device files. | ||
1444 | |||
1445 | Cgroup v2 device controller has no interface files and is implemented | ||
1446 | on top of cgroup BPF. To control access to device files, a user may | ||
1447 | create bpf programs of the BPF_CGROUP_DEVICE type and attach them | ||
1448 | to cgroups. On an attempt to access a device file, corresponding | ||
1449 | BPF programs will be executed, and depending on the return value | ||
1450 | the attempt will succeed or fail with -EPERM. | ||
1451 | |||
1452 | A BPF_CGROUP_DEVICE program takes a pointer to the bpf_cgroup_dev_ctx | ||
1453 | structure, which describes the device access attempt: access type | ||
1454 | (mknod/read/write) and device (type, major and minor numbers). | ||
1455 | If the program returns 0, the attempt fails with -EPERM, otherwise | ||
1456 | it succeeds. | ||
1457 | |||
1458 | An example of BPF_CGROUP_DEVICE program may be found in the kernel | ||
1459 | source tree in the tools/testing/selftests/bpf/dev_cgroup.c file. | ||
1460 | |||
1461 | |||
1432 | RDMA | 1462 | RDMA |
1433 | ---- | 1463 | ---- |
1434 | 1464 | ||
@@ -1481,6 +1511,35 @@ always be filtered by cgroup v2 path. The controller can still be | |||
1481 | moved to a legacy hierarchy after v2 hierarchy is populated. | 1511 | moved to a legacy hierarchy after v2 hierarchy is populated. |
1482 | 1512 | ||
1483 | 1513 | ||
1514 | Non-normative information | ||
1515 | ------------------------- | ||
1516 | |||
1517 | This section contains information that isn't considered to be a part of | ||
1518 | the stable kernel API and so is subject to change. | ||
1519 | |||
1520 | |||
1521 | CPU controller root cgroup process behaviour | ||
1522 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
1523 | |||
1524 | When distributing CPU cycles in the root cgroup each thread in this | ||
1525 | cgroup is treated as if it was hosted in a separate child cgroup of the | ||
1526 | root cgroup. This child cgroup weight is dependent on its thread nice | ||
1527 | level. | ||
1528 | |||
1529 | For details of this mapping see sched_prio_to_weight array in | ||
1530 | kernel/sched/core.c file (values from this array should be scaled | ||
1531 | appropriately so the neutral - nice 0 - value is 100 instead of 1024). | ||
1532 | |||
1533 | |||
1534 | IO controller root cgroup process behaviour | ||
1535 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
1536 | |||
1537 | Root cgroup processes are hosted in an implicit leaf child node. | ||
1538 | When distributing IO resources this implicit child node is taken into | ||
1539 | account as if it was a normal child cgroup of the root cgroup with a | ||
1540 | weight value of 200. | ||
1541 | |||
1542 | |||
1484 | Namespace | 1543 | Namespace |
1485 | ========= | 1544 | ========= |
1486 | 1545 | ||
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 8b7fd8eeccee..9f242b876fde 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h | |||
@@ -561,7 +561,7 @@ struct cftype { | |||
561 | 561 | ||
562 | /* | 562 | /* |
563 | * Control Group subsystem type. | 563 | * Control Group subsystem type. |
564 | * See Documentation/cgroups/cgroups.txt for details | 564 | * See Documentation/cgroup-v1/cgroups.txt for details |
565 | */ | 565 | */ |
566 | struct cgroup_subsys { | 566 | struct cgroup_subsys { |
567 | struct cgroup_subsys_state *(*css_alloc)(struct cgroup_subsys_state *parent_css); | 567 | struct cgroup_subsys_state *(*css_alloc)(struct cgroup_subsys_state *parent_css); |
diff --git a/include/linux/string.h b/include/linux/string.h index cfd83eb2f926..96115bf561b4 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
@@ -28,7 +28,7 @@ extern char * strncpy(char *,const char *, __kernel_size_t); | |||
28 | size_t strlcpy(char *, const char *, size_t); | 28 | size_t strlcpy(char *, const char *, size_t); |
29 | #endif | 29 | #endif |
30 | #ifndef __HAVE_ARCH_STRSCPY | 30 | #ifndef __HAVE_ARCH_STRSCPY |
31 | ssize_t __must_check strscpy(char *, const char *, size_t); | 31 | ssize_t strscpy(char *, const char *, size_t); |
32 | #endif | 32 | #endif |
33 | #ifndef __HAVE_ARCH_STRCAT | 33 | #ifndef __HAVE_ARCH_STRCAT |
34 | extern char * strcat(char *, const char *); | 34 | extern char * strcat(char *, const char *); |
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 7e4c44538119..8cda3bc3ae22 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
@@ -1397,7 +1397,7 @@ static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, | |||
1397 | cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name, | 1397 | cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name, |
1398 | cft->name); | 1398 | cft->name); |
1399 | else | 1399 | else |
1400 | strlcpy(buf, cft->name, CGROUP_FILE_NAME_MAX); | 1400 | strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX); |
1401 | return buf; | 1401 | return buf; |
1402 | } | 1402 | } |
1403 | 1403 | ||
@@ -1864,9 +1864,9 @@ void init_cgroup_root(struct cgroup_root *root, struct cgroup_sb_opts *opts) | |||
1864 | 1864 | ||
1865 | root->flags = opts->flags; | 1865 | root->flags = opts->flags; |
1866 | if (opts->release_agent) | 1866 | if (opts->release_agent) |
1867 | strlcpy(root->release_agent_path, opts->release_agent, PATH_MAX); | 1867 | strscpy(root->release_agent_path, opts->release_agent, PATH_MAX); |
1868 | if (opts->name) | 1868 | if (opts->name) |
1869 | strlcpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN); | 1869 | strscpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN); |
1870 | if (opts->cpuset_clone_children) | 1870 | if (opts->cpuset_clone_children) |
1871 | set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags); | 1871 | set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags); |
1872 | } | 1872 | } |