diff options
author | Tejun Heo <tj@kernel.org> | 2015-09-18 11:56:28 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2015-09-18 11:56:28 -0400 |
commit | 49d1dc4b81797f88270832b11e9f73809e7e7209 (patch) | |
tree | ff6548a57a57834e533a4404ddabf30139060ece /include/linux | |
parent | fa128fd735bd236b6b04d3fedfed7a784137c185 (diff) |
cgroup: implement static_key based cgroup_subsys_enabled() and cgroup_subsys_on_dfl()
Whether a subsys is enabled and attached to the default hierarchy
seldom changes and may be tested in the hot paths. This patch
implements static_key based cgroup_subsys_enabled() and
cgroup_subsys_on_dfl() tests.
The following patches will update the users and remove duplicate
mechanisms.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/cgroup.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index eb7ca55f72ef..c3a9f1eb4097 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/seq_file.h> | 18 | #include <linux/seq_file.h> |
19 | #include <linux/kernfs.h> | 19 | #include <linux/kernfs.h> |
20 | #include <linux/jump_label.h> | ||
20 | 21 | ||
21 | #include <linux/cgroup-defs.h> | 22 | #include <linux/cgroup-defs.h> |
22 | 23 | ||
@@ -50,6 +51,26 @@ extern struct css_set init_css_set; | |||
50 | #include <linux/cgroup_subsys.h> | 51 | #include <linux/cgroup_subsys.h> |
51 | #undef SUBSYS | 52 | #undef SUBSYS |
52 | 53 | ||
54 | #define SUBSYS(_x) \ | ||
55 | extern struct static_key_true _x ## _cgrp_subsys_enabled_key; \ | ||
56 | extern struct static_key_true _x ## _cgrp_subsys_on_dfl_key; | ||
57 | #include <linux/cgroup_subsys.h> | ||
58 | #undef SUBSYS | ||
59 | |||
60 | /** | ||
61 | * cgroup_subsys_enabled - fast test on whether a subsys is enabled | ||
62 | * @ss: subsystem in question | ||
63 | */ | ||
64 | #define cgroup_subsys_enabled(ss) \ | ||
65 | static_branch_likely(&ss ## _enabled_key) | ||
66 | |||
67 | /** | ||
68 | * cgroup_subsys_on_dfl - fast test on whether a subsys is on default hierarchy | ||
69 | * @ss: subsystem in question | ||
70 | */ | ||
71 | #define cgroup_subsys_on_dfl(ss) \ | ||
72 | static_branch_likely(&ss ## _on_dfl_key) | ||
73 | |||
53 | bool css_has_online_children(struct cgroup_subsys_state *css); | 74 | bool css_has_online_children(struct cgroup_subsys_state *css); |
54 | struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss); | 75 | struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss); |
55 | struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup, | 76 | struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup, |