summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-01-30 18:09:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-01-30 18:09:47 -0500
commit13ddd1667e7f01071cdf120132238ffca004a88e (patch)
tree6cd3cae74cc6a7e9d5e5292600623c8533a3fa7c
parent289104c9a45cf27e80fa7b04286ada22f4e964fe (diff)
parent03eac8b22194becd77d253fc546429ebb544aebf (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.txt7
-rw-r--r--Documentation/cgroup-v1/memory.txt4
-rw-r--r--Documentation/cgroup-v2.txt77
-rw-r--r--include/linux/cgroup-defs.h2
-rw-r--r--include/linux/string.h2
-rw-r--r--kernel/cgroup/cgroup.c6
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:
523Each subsystem should: 523Each 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
528If a subsystem can be compiled as a module, it should also have in its
529module initcall a call to cgroup_load_subsys(), and in its exitcall a
530call to cgroup_unload_subsys(). It should also set its_subsys.module =
531THIS_MODULE in its .c file.
532 527
533Each subsystem may export the following methods. The only mandatory 528Each subsystem may export the following methods. The only mandatory
534methods are css_alloc/free. Any others that are null are presumed to 529methods 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
5325.3 swappiness 5325.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
281Topology-wise, a cgroup can be in an invalid state. Please consider 285Topology-wise, a cgroup can be in an invalid state. Please consider
282the following toplogy:: 286the 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
420processes and anonymous resource consumption which can't be associated 424processes and anonymous resource consumption which can't be associated
421with any other cgroups and requires special treatment from most 425with any other cgroups and requires special treatment from most
422controllers. How resource consumption in the root cgroup is governed 426controllers. How resource consumption in the root cgroup is governed
423is up to each controller. 427is up to each controller (for more information on this topic please
428refer to the Non-normative information section in the Controllers
429chapter).
424 430
425Note that the restriction doesn't get in the way if there is no 431Note that the restriction doesn't get in the way if there is no
426enabled controller in the cgroup's "cgroup.subtree_control". This is 432enabled 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
1197Usage Guidelines 1203Usage Guidelines
@@ -1429,6 +1435,30 @@ through fork() or clone(). These will return -EAGAIN if the creation
1429of a new process would cause a cgroup policy to be violated. 1435of a new process would cause a cgroup policy to be violated.
1430 1436
1431 1437
1438Device controller
1439-----------------
1440
1441Device controller manages access to device files. It includes both
1442creation of new device files (using mknod), and access to the
1443existing device files.
1444
1445Cgroup v2 device controller has no interface files and is implemented
1446on top of cgroup BPF. To control access to device files, a user may
1447create bpf programs of the BPF_CGROUP_DEVICE type and attach them
1448to cgroups. On an attempt to access a device file, corresponding
1449BPF programs will be executed, and depending on the return value
1450the attempt will succeed or fail with -EPERM.
1451
1452A BPF_CGROUP_DEVICE program takes a pointer to the bpf_cgroup_dev_ctx
1453structure, which describes the device access attempt: access type
1454(mknod/read/write) and device (type, major and minor numbers).
1455If the program returns 0, the attempt fails with -EPERM, otherwise
1456it succeeds.
1457
1458An example of BPF_CGROUP_DEVICE program may be found in the kernel
1459source tree in the tools/testing/selftests/bpf/dev_cgroup.c file.
1460
1461
1432RDMA 1462RDMA
1433---- 1463----
1434 1464
@@ -1481,6 +1511,35 @@ always be filtered by cgroup v2 path. The controller can still be
1481moved to a legacy hierarchy after v2 hierarchy is populated. 1511moved to a legacy hierarchy after v2 hierarchy is populated.
1482 1512
1483 1513
1514Non-normative information
1515-------------------------
1516
1517This section contains information that isn't considered to be a part of
1518the stable kernel API and so is subject to change.
1519
1520
1521CPU controller root cgroup process behaviour
1522~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1523
1524When distributing CPU cycles in the root cgroup each thread in this
1525cgroup is treated as if it was hosted in a separate child cgroup of the
1526root cgroup. This child cgroup weight is dependent on its thread nice
1527level.
1528
1529For details of this mapping see sched_prio_to_weight array in
1530kernel/sched/core.c file (values from this array should be scaled
1531appropriately so the neutral - nice 0 - value is 100 instead of 1024).
1532
1533
1534IO controller root cgroup process behaviour
1535~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1536
1537Root cgroup processes are hosted in an implicit leaf child node.
1538When distributing IO resources this implicit child node is taken into
1539account as if it was a normal child cgroup of the root cgroup with a
1540weight value of 200.
1541
1542
1484Namespace 1543Namespace
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 */
566struct cgroup_subsys { 566struct 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);
28size_t strlcpy(char *, const char *, size_t); 28size_t strlcpy(char *, const char *, size_t);
29#endif 29#endif
30#ifndef __HAVE_ARCH_STRSCPY 30#ifndef __HAVE_ARCH_STRSCPY
31ssize_t __must_check strscpy(char *, const char *, size_t); 31ssize_t strscpy(char *, const char *, size_t);
32#endif 32#endif
33#ifndef __HAVE_ARCH_STRCAT 33#ifndef __HAVE_ARCH_STRCAT
34extern char * strcat(char *, const char *); 34extern 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}