diff options
author | Tejun Heo <tj@kernel.org> | 2014-05-13 12:16:21 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-05-13 12:16:21 -0400 |
commit | 6770c64e5c8da4705d1f0973bdeb5c2bf4f3a404 (patch) | |
tree | 29e16383df94d4a31f6fec2f49f5ae84c369f911 /mm/memcontrol.c | |
parent | 451af504df0c62f695a69b83c250486e77c66378 (diff) |
cgroup: replace cftype->trigger() with cftype->write()
cftype->trigger() is pointless. It's trivial to ignore the input
buffer from a regular ->write() operation. Convert all ->trigger()
users to ->write() and remove ->trigger().
This patch doesn't introduce any visible behavior changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7098a43f7447..b638a79209ee 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -4887,14 +4887,15 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg) | |||
4887 | return 0; | 4887 | return 0; |
4888 | } | 4888 | } |
4889 | 4889 | ||
4890 | static int mem_cgroup_force_empty_write(struct cgroup_subsys_state *css, | 4890 | static ssize_t mem_cgroup_force_empty_write(struct kernfs_open_file *of, |
4891 | unsigned int event) | 4891 | char *buf, size_t nbytes, |
4892 | loff_t off) | ||
4892 | { | 4893 | { |
4893 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 4894 | struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); |
4894 | 4895 | ||
4895 | if (mem_cgroup_is_root(memcg)) | 4896 | if (mem_cgroup_is_root(memcg)) |
4896 | return -EINVAL; | 4897 | return -EINVAL; |
4897 | return mem_cgroup_force_empty(memcg); | 4898 | return mem_cgroup_force_empty(memcg) ?: nbytes; |
4898 | } | 4899 | } |
4899 | 4900 | ||
4900 | static u64 mem_cgroup_hierarchy_read(struct cgroup_subsys_state *css, | 4901 | static u64 mem_cgroup_hierarchy_read(struct cgroup_subsys_state *css, |
@@ -5220,14 +5221,15 @@ out: | |||
5220 | *memsw_limit = min_memsw_limit; | 5221 | *memsw_limit = min_memsw_limit; |
5221 | } | 5222 | } |
5222 | 5223 | ||
5223 | static int mem_cgroup_reset(struct cgroup_subsys_state *css, unsigned int event) | 5224 | static ssize_t mem_cgroup_reset(struct kernfs_open_file *of, char *buf, |
5225 | size_t nbytes, loff_t off) | ||
5224 | { | 5226 | { |
5225 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 5227 | struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); |
5226 | int name; | 5228 | int name; |
5227 | enum res_type type; | 5229 | enum res_type type; |
5228 | 5230 | ||
5229 | type = MEMFILE_TYPE(event); | 5231 | type = MEMFILE_TYPE(of_cft(of)->private); |
5230 | name = MEMFILE_ATTR(event); | 5232 | name = MEMFILE_ATTR(of_cft(of)->private); |
5231 | 5233 | ||
5232 | switch (name) { | 5234 | switch (name) { |
5233 | case RES_MAX_USAGE: | 5235 | case RES_MAX_USAGE: |
@@ -5252,7 +5254,7 @@ static int mem_cgroup_reset(struct cgroup_subsys_state *css, unsigned int event) | |||
5252 | break; | 5254 | break; |
5253 | } | 5255 | } |
5254 | 5256 | ||
5255 | return 0; | 5257 | return nbytes; |
5256 | } | 5258 | } |
5257 | 5259 | ||
5258 | static u64 mem_cgroup_move_charge_read(struct cgroup_subsys_state *css, | 5260 | static u64 mem_cgroup_move_charge_read(struct cgroup_subsys_state *css, |
@@ -6105,7 +6107,7 @@ static struct cftype mem_cgroup_files[] = { | |||
6105 | { | 6107 | { |
6106 | .name = "max_usage_in_bytes", | 6108 | .name = "max_usage_in_bytes", |
6107 | .private = MEMFILE_PRIVATE(_MEM, RES_MAX_USAGE), | 6109 | .private = MEMFILE_PRIVATE(_MEM, RES_MAX_USAGE), |
6108 | .trigger = mem_cgroup_reset, | 6110 | .write = mem_cgroup_reset, |
6109 | .read_u64 = mem_cgroup_read_u64, | 6111 | .read_u64 = mem_cgroup_read_u64, |
6110 | }, | 6112 | }, |
6111 | { | 6113 | { |
@@ -6123,7 +6125,7 @@ static struct cftype mem_cgroup_files[] = { | |||
6123 | { | 6125 | { |
6124 | .name = "failcnt", | 6126 | .name = "failcnt", |
6125 | .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT), | 6127 | .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT), |
6126 | .trigger = mem_cgroup_reset, | 6128 | .write = mem_cgroup_reset, |
6127 | .read_u64 = mem_cgroup_read_u64, | 6129 | .read_u64 = mem_cgroup_read_u64, |
6128 | }, | 6130 | }, |
6129 | { | 6131 | { |
@@ -6132,7 +6134,7 @@ static struct cftype mem_cgroup_files[] = { | |||
6132 | }, | 6134 | }, |
6133 | { | 6135 | { |
6134 | .name = "force_empty", | 6136 | .name = "force_empty", |
6135 | .trigger = mem_cgroup_force_empty_write, | 6137 | .write = mem_cgroup_force_empty_write, |
6136 | }, | 6138 | }, |
6137 | { | 6139 | { |
6138 | .name = "use_hierarchy", | 6140 | .name = "use_hierarchy", |
@@ -6186,13 +6188,13 @@ static struct cftype mem_cgroup_files[] = { | |||
6186 | { | 6188 | { |
6187 | .name = "kmem.failcnt", | 6189 | .name = "kmem.failcnt", |
6188 | .private = MEMFILE_PRIVATE(_KMEM, RES_FAILCNT), | 6190 | .private = MEMFILE_PRIVATE(_KMEM, RES_FAILCNT), |
6189 | .trigger = mem_cgroup_reset, | 6191 | .write = mem_cgroup_reset, |
6190 | .read_u64 = mem_cgroup_read_u64, | 6192 | .read_u64 = mem_cgroup_read_u64, |
6191 | }, | 6193 | }, |
6192 | { | 6194 | { |
6193 | .name = "kmem.max_usage_in_bytes", | 6195 | .name = "kmem.max_usage_in_bytes", |
6194 | .private = MEMFILE_PRIVATE(_KMEM, RES_MAX_USAGE), | 6196 | .private = MEMFILE_PRIVATE(_KMEM, RES_MAX_USAGE), |
6195 | .trigger = mem_cgroup_reset, | 6197 | .write = mem_cgroup_reset, |
6196 | .read_u64 = mem_cgroup_read_u64, | 6198 | .read_u64 = mem_cgroup_read_u64, |
6197 | }, | 6199 | }, |
6198 | #ifdef CONFIG_SLABINFO | 6200 | #ifdef CONFIG_SLABINFO |
@@ -6215,7 +6217,7 @@ static struct cftype memsw_cgroup_files[] = { | |||
6215 | { | 6217 | { |
6216 | .name = "memsw.max_usage_in_bytes", | 6218 | .name = "memsw.max_usage_in_bytes", |
6217 | .private = MEMFILE_PRIVATE(_MEMSWAP, RES_MAX_USAGE), | 6219 | .private = MEMFILE_PRIVATE(_MEMSWAP, RES_MAX_USAGE), |
6218 | .trigger = mem_cgroup_reset, | 6220 | .write = mem_cgroup_reset, |
6219 | .read_u64 = mem_cgroup_read_u64, | 6221 | .read_u64 = mem_cgroup_read_u64, |
6220 | }, | 6222 | }, |
6221 | { | 6223 | { |
@@ -6227,7 +6229,7 @@ static struct cftype memsw_cgroup_files[] = { | |||
6227 | { | 6229 | { |
6228 | .name = "memsw.failcnt", | 6230 | .name = "memsw.failcnt", |
6229 | .private = MEMFILE_PRIVATE(_MEMSWAP, RES_FAILCNT), | 6231 | .private = MEMFILE_PRIVATE(_MEMSWAP, RES_FAILCNT), |
6230 | .trigger = mem_cgroup_reset, | 6232 | .write = mem_cgroup_reset, |
6231 | .read_u64 = mem_cgroup_read_u64, | 6233 | .read_u64 = mem_cgroup_read_u64, |
6232 | }, | 6234 | }, |
6233 | { }, /* terminate */ | 6235 | { }, /* terminate */ |