diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-22 18:20:42 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-11-22 18:20:42 -0500 |
commit | b5557c4c3b1a38074d7001b87c2482eda3a0834a (patch) | |
tree | 4bd6b1a6d05ee74485a88ae814828d0befc04fc6 /mm/memcontrol.c | |
parent | 79bd9814e5ec9a288d6599f53aeac0b548fdfe52 (diff) |
memcg: cgroup_write_event_control() now knows @css is for memcg
@css for cgroup_write_event_control() is now always for memcg and the
target file should be a memcg file too. Drop code which assumes @css
is dummy_css and the target file may belong to different subsystems.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 02dae3292668..d00368110b08 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -6056,10 +6056,10 @@ static void cgroup_event_ptable_queue_proc(struct file *file, | |||
6056 | * Input must be in format '<event_fd> <control_fd> <args>'. | 6056 | * Input must be in format '<event_fd> <control_fd> <args>'. |
6057 | * Interpretation of args is defined by control file implementation. | 6057 | * Interpretation of args is defined by control file implementation. |
6058 | */ | 6058 | */ |
6059 | static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, | 6059 | static int cgroup_write_event_control(struct cgroup_subsys_state *css, |
6060 | struct cftype *cft, const char *buffer) | 6060 | struct cftype *cft, const char *buffer) |
6061 | { | 6061 | { |
6062 | struct cgroup *cgrp = dummy_css->cgroup; | 6062 | struct cgroup *cgrp = css->cgroup; |
6063 | struct cgroup_event *event; | 6063 | struct cgroup_event *event; |
6064 | struct cgroup_subsys_state *cfile_css; | 6064 | struct cgroup_subsys_state *cfile_css; |
6065 | unsigned int efd, cfd; | 6065 | unsigned int efd, cfd; |
@@ -6082,6 +6082,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, | |||
6082 | if (!event) | 6082 | if (!event) |
6083 | return -ENOMEM; | 6083 | return -ENOMEM; |
6084 | 6084 | ||
6085 | event->css = css; | ||
6085 | INIT_LIST_HEAD(&event->list); | 6086 | INIT_LIST_HEAD(&event->list); |
6086 | init_poll_funcptr(&event->pt, cgroup_event_ptable_queue_proc); | 6087 | init_poll_funcptr(&event->pt, cgroup_event_ptable_queue_proc); |
6087 | init_waitqueue_func_entry(&event->wait, cgroup_event_wake); | 6088 | init_waitqueue_func_entry(&event->wait, cgroup_event_wake); |
@@ -6117,23 +6118,17 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, | |||
6117 | goto out_put_cfile; | 6118 | goto out_put_cfile; |
6118 | } | 6119 | } |
6119 | 6120 | ||
6120 | if (!event->cft->ss) { | ||
6121 | ret = -EBADF; | ||
6122 | goto out_put_cfile; | ||
6123 | } | ||
6124 | |||
6125 | /* | 6121 | /* |
6126 | * Determine the css of @cfile, verify it belongs to the same | 6122 | * Verify @cfile should belong to @css. Also, remaining events are |
6127 | * cgroup as cgroup.event_control, and associate @event with it. | 6123 | * automatically removed on cgroup destruction but the removal is |
6128 | * Remaining events are automatically removed on cgroup destruction | 6124 | * asynchronous, so take an extra ref on @css. |
6129 | * but the removal is asynchronous, so take an extra ref. | ||
6130 | */ | 6125 | */ |
6131 | rcu_read_lock(); | 6126 | rcu_read_lock(); |
6132 | 6127 | ||
6133 | ret = -EINVAL; | 6128 | ret = -EINVAL; |
6134 | event->css = cgroup_css(cgrp, event->cft->ss); | 6129 | cfile_css = css_from_dir(cfile.file->f_dentry->d_parent, |
6135 | cfile_css = css_from_dir(cfile.file->f_dentry->d_parent, event->cft->ss); | 6130 | &mem_cgroup_subsys); |
6136 | if (event->css && event->css == cfile_css && css_tryget(event->css)) | 6131 | if (cfile_css == css && css_tryget(css)) |
6137 | ret = 0; | 6132 | ret = 0; |
6138 | 6133 | ||
6139 | rcu_read_unlock(); | 6134 | rcu_read_unlock(); |
@@ -6145,7 +6140,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, | |||
6145 | goto out_put_css; | 6140 | goto out_put_css; |
6146 | } | 6141 | } |
6147 | 6142 | ||
6148 | ret = event->cft->register_event(event->css, event->cft, | 6143 | ret = event->cft->register_event(css, event->cft, |
6149 | event->eventfd, buffer); | 6144 | event->eventfd, buffer); |
6150 | if (ret) | 6145 | if (ret) |
6151 | goto out_put_css; | 6146 | goto out_put_css; |
@@ -6162,7 +6157,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, | |||
6162 | return 0; | 6157 | return 0; |
6163 | 6158 | ||
6164 | out_put_css: | 6159 | out_put_css: |
6165 | css_put(event->css); | 6160 | css_put(css); |
6166 | out_put_cfile: | 6161 | out_put_cfile: |
6167 | fdput(cfile); | 6162 | fdput(cfile); |
6168 | out_put_eventfd: | 6163 | out_put_eventfd: |