summaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup_subsys.h
diff options
context:
space:
mode:
authorVipin Sharma <vipinsh@google.com>2021-03-29 21:42:04 -0700
committerTejun Heo <tj@kernel.org>2021-04-04 13:34:46 -0400
commita72232eabdfcfe365a05a3eb392288b78d25a5ca (patch)
tree0eaf6a377328a7d5b30d7f248f8360f7fcb31a34 /include/linux/cgroup_subsys.h
parent2023a53bdf41b7646b1d384b6816af06309f73a5 (diff)
downloadlinux-a72232eabdfcfe365a05a3eb392288b78d25a5ca.tar.gz
linux-a72232eabdfcfe365a05a3eb392288b78d25a5ca.tar.bz2
linux-a72232eabdfcfe365a05a3eb392288b78d25a5ca.zip
cgroup: Add misc cgroup controller
The Miscellaneous cgroup provides the resource limiting and tracking mechanism for the scalar resources which cannot be abstracted like the other cgroup resources. Controller is enabled by the CONFIG_CGROUP_MISC config option. A resource can be added to the controller via enum misc_res_type{} in the include/linux/misc_cgroup.h file and the corresponding name via misc_res_name[] in the kernel/cgroup/misc.c file. Provider of the resource must set its capacity prior to using the resource by calling misc_cg_set_capacity(). Once a capacity is set then the resource usage can be updated using charge and uncharge APIs. All of the APIs to interact with misc controller are in include/linux/misc_cgroup.h. Miscellaneous controller provides 3 interface files. If two misc resources (res_a and res_b) are registered then: misc.capacity A read-only flat-keyed file shown only in the root cgroup. It shows miscellaneous scalar resources available on the platform along with their quantities:: $ cat misc.capacity res_a 50 res_b 10 misc.current A read-only flat-keyed file shown in the non-root cgroups. It shows the current usage of the resources in the cgroup and its children:: $ cat misc.current res_a 3 res_b 0 misc.max A read-write flat-keyed file shown in the non root cgroups. Allowed maximum usage of the resources in the cgroup and its children.:: $ cat misc.max res_a max res_b 4 Limit can be set by:: # echo res_a 1 > misc.max Limit can be set to max by:: # echo res_a max > misc.max Limits can be set more than the capacity value in the misc.capacity file. Signed-off-by: Vipin Sharma <vipinsh@google.com> Reviewed-by: David Rientjes <rientjes@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/cgroup_subsys.h')
-rw-r--r--include/linux/cgroup_subsys.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index acb77dcff3b4..445235487230 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -61,6 +61,10 @@ SUBSYS(pids)
SUBSYS(rdma)
#endif
+#if IS_ENABLED(CONFIG_CGROUP_MISC)
+SUBSYS(misc)
+#endif
+
/*
* The following subsystems are not supported on the default hierarchy.
*/