aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
commit182446d087906de40e514573a92a97b203695f71 (patch)
tree6aee96219c82d0a64b9d389c50666c1ce0ec27ee /kernel
parent67f4c36f83455b253445b2cb28ac9a2c4f85d99a (diff)
cgroup: pass around cgroup_subsys_state instead of cgroup in file methods
cgroup is currently in the process of transitioning to using struct cgroup_subsys_state * as the primary handle instead of struct cgroup. Please see the previous commit which converts the subsystem methods for rationale. This patch converts all cftype file operations to take @css instead of @cgroup. cftypes for the cgroup core files don't have their subsytem pointer set. These will automatically use the dummy_css added by the previous patch and can be converted the same way. Most subsystem conversions are straight forwards but there are some interesting ones. * freezer: update_if_frozen() is also converted to take @css instead of @cgroup for consistency. This will make the code look simpler too once iterators are converted to use css. * memory/vmpressure: mem_cgroup_from_css() needs to be exported to vmpressure while mem_cgroup_from_cont() can be made static. Updated accordingly. * cpu: cgroup_tg() doesn't have any user left. Removed. * cpuacct: cgroup_ca() doesn't have any user left. Removed. * hugetlb: hugetlb_cgroup_form_cgroup() doesn't have any user left. Removed. * net_cls: cgrp_cls_state() doesn't have any user left. Removed. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Aristeu Rozanski <aris@redhat.com> Acked-by: Daniel Wagner <daniel.wagner@bmw-carit.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Matt Helsley <matthltc@us.ibm.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c162
-rw-r--r--kernel/cgroup_freezer.c40
-rw-r--r--kernel/cpuset.c35
-rw-r--r--kernel/sched/core.c65
-rw-r--r--kernel/sched/cpuacct.c28
5 files changed, 165 insertions, 165 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c049992f1ffa..6ee469837fda 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2235,34 +2235,38 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
2235} 2235}
2236EXPORT_SYMBOL_GPL(cgroup_attach_task_all); 2236EXPORT_SYMBOL_GPL(cgroup_attach_task_all);
2237 2237
2238static int cgroup_tasks_write(struct cgroup *cgrp, struct cftype *cft, u64 pid) 2238static int cgroup_tasks_write(struct cgroup_subsys_state *css,
2239 struct cftype *cft, u64 pid)
2239{ 2240{
2240 return attach_task_by_pid(cgrp, pid, false); 2241 return attach_task_by_pid(css->cgroup, pid, false);
2241} 2242}
2242 2243
2243static int cgroup_procs_write(struct cgroup *cgrp, struct cftype *cft, u64 tgid) 2244static int cgroup_procs_write(struct cgroup_subsys_state *css,
2245 struct cftype *cft, u64 tgid)
2244{ 2246{
2245 return attach_task_by_pid(cgrp, tgid, true); 2247 return attach_task_by_pid(css->cgroup, tgid, true);
2246} 2248}
2247 2249
2248static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, 2250static int cgroup_release_agent_write(struct cgroup_subsys_state *css,
2249 const char *buffer) 2251 struct cftype *cft, const char *buffer)
2250{ 2252{
2251 BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); 2253 BUILD_BUG_ON(sizeof(css->cgroup->root->release_agent_path) < PATH_MAX);
2252 if (strlen(buffer) >= PATH_MAX) 2254 if (strlen(buffer) >= PATH_MAX)
2253 return -EINVAL; 2255 return -EINVAL;
2254 if (!cgroup_lock_live_group(cgrp)) 2256 if (!cgroup_lock_live_group(css->cgroup))
2255 return -ENODEV; 2257 return -ENODEV;
2256 mutex_lock(&cgroup_root_mutex); 2258 mutex_lock(&cgroup_root_mutex);
2257 strcpy(cgrp->root->release_agent_path, buffer); 2259 strcpy(css->cgroup->root->release_agent_path, buffer);
2258 mutex_unlock(&cgroup_root_mutex); 2260 mutex_unlock(&cgroup_root_mutex);
2259 mutex_unlock(&cgroup_mutex); 2261 mutex_unlock(&cgroup_mutex);
2260 return 0; 2262 return 0;
2261} 2263}
2262 2264
2263static int cgroup_release_agent_show(struct cgroup *cgrp, struct cftype *cft, 2265static int cgroup_release_agent_show(struct cgroup_subsys_state *css,
2264 struct seq_file *seq) 2266 struct cftype *cft, struct seq_file *seq)
2265{ 2267{
2268 struct cgroup *cgrp = css->cgroup;
2269
2266 if (!cgroup_lock_live_group(cgrp)) 2270 if (!cgroup_lock_live_group(cgrp))
2267 return -ENODEV; 2271 return -ENODEV;
2268 seq_puts(seq, cgrp->root->release_agent_path); 2272 seq_puts(seq, cgrp->root->release_agent_path);
@@ -2271,10 +2275,10 @@ static int cgroup_release_agent_show(struct cgroup *cgrp, struct cftype *cft,
2271 return 0; 2275 return 0;
2272} 2276}
2273 2277
2274static int cgroup_sane_behavior_show(struct cgroup *cgrp, struct cftype *cft, 2278static int cgroup_sane_behavior_show(struct cgroup_subsys_state *css,
2275 struct seq_file *seq) 2279 struct cftype *cft, struct seq_file *seq)
2276{ 2280{
2277 seq_printf(seq, "%d\n", cgroup_sane_behavior(cgrp)); 2281 seq_printf(seq, "%d\n", cgroup_sane_behavior(css->cgroup));
2278 return 0; 2282 return 0;
2279} 2283}
2280 2284
@@ -2292,10 +2296,10 @@ static struct cgroup_subsys_state *cgroup_file_css(struct cfent *cfe)
2292/* A buffer size big enough for numbers or short strings */ 2296/* A buffer size big enough for numbers or short strings */
2293#define CGROUP_LOCAL_BUFFER_SIZE 64 2297#define CGROUP_LOCAL_BUFFER_SIZE 64
2294 2298
2295static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft, 2299static ssize_t cgroup_write_X64(struct cgroup_subsys_state *css,
2296 struct file *file, 2300 struct cftype *cft, struct file *file,
2297 const char __user *userbuf, 2301 const char __user *userbuf, size_t nbytes,
2298 size_t nbytes, loff_t *unused_ppos) 2302 loff_t *unused_ppos)
2299{ 2303{
2300 char buffer[CGROUP_LOCAL_BUFFER_SIZE]; 2304 char buffer[CGROUP_LOCAL_BUFFER_SIZE];
2301 int retval = 0; 2305 int retval = 0;
@@ -2313,22 +2317,22 @@ static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft,
2313 u64 val = simple_strtoull(strstrip(buffer), &end, 0); 2317 u64 val = simple_strtoull(strstrip(buffer), &end, 0);
2314 if (*end) 2318 if (*end)
2315 return -EINVAL; 2319 return -EINVAL;
2316 retval = cft->write_u64(cgrp, cft, val); 2320 retval = cft->write_u64(css, cft, val);
2317 } else { 2321 } else {
2318 s64 val = simple_strtoll(strstrip(buffer), &end, 0); 2322 s64 val = simple_strtoll(strstrip(buffer), &end, 0);
2319 if (*end) 2323 if (*end)
2320 return -EINVAL; 2324 return -EINVAL;
2321 retval = cft->write_s64(cgrp, cft, val); 2325 retval = cft->write_s64(css, cft, val);
2322 } 2326 }
2323 if (!retval) 2327 if (!retval)
2324 retval = nbytes; 2328 retval = nbytes;
2325 return retval; 2329 return retval;
2326} 2330}
2327 2331
2328static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft, 2332static ssize_t cgroup_write_string(struct cgroup_subsys_state *css,
2329 struct file *file, 2333 struct cftype *cft, struct file *file,
2330 const char __user *userbuf, 2334 const char __user *userbuf, size_t nbytes,
2331 size_t nbytes, loff_t *unused_ppos) 2335 loff_t *unused_ppos)
2332{ 2336{
2333 char local_buffer[CGROUP_LOCAL_BUFFER_SIZE]; 2337 char local_buffer[CGROUP_LOCAL_BUFFER_SIZE];
2334 int retval = 0; 2338 int retval = 0;
@@ -2351,7 +2355,7 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
2351 } 2355 }
2352 2356
2353 buffer[nbytes] = 0; /* nul-terminate */ 2357 buffer[nbytes] = 0; /* nul-terminate */
2354 retval = cft->write_string(cgrp, cft, strstrip(buffer)); 2358 retval = cft->write_string(css, cft, strstrip(buffer));
2355 if (!retval) 2359 if (!retval)
2356 retval = nbytes; 2360 retval = nbytes;
2357out: 2361out:
@@ -2361,60 +2365,60 @@ out:
2361} 2365}
2362 2366
2363static ssize_t cgroup_file_write(struct file *file, const char __user *buf, 2367static ssize_t cgroup_file_write(struct file *file, const char __user *buf,
2364 size_t nbytes, loff_t *ppos) 2368 size_t nbytes, loff_t *ppos)
2365{ 2369{
2370 struct cfent *cfe = __d_cfe(file->f_dentry);
2366 struct cftype *cft = __d_cft(file->f_dentry); 2371 struct cftype *cft = __d_cft(file->f_dentry);
2367 struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent); 2372 struct cgroup_subsys_state *css = cgroup_file_css(cfe);
2368 2373
2369 if (cft->write) 2374 if (cft->write)
2370 return cft->write(cgrp, cft, file, buf, nbytes, ppos); 2375 return cft->write(css, cft, file, buf, nbytes, ppos);
2371 if (cft->write_u64 || cft->write_s64) 2376 if (cft->write_u64 || cft->write_s64)
2372 return cgroup_write_X64(cgrp, cft, file, buf, nbytes, ppos); 2377 return cgroup_write_X64(css, cft, file, buf, nbytes, ppos);
2373 if (cft->write_string) 2378 if (cft->write_string)
2374 return cgroup_write_string(cgrp, cft, file, buf, nbytes, ppos); 2379 return cgroup_write_string(css, cft, file, buf, nbytes, ppos);
2375 if (cft->trigger) { 2380 if (cft->trigger) {
2376 int ret = cft->trigger(cgrp, (unsigned int)cft->private); 2381 int ret = cft->trigger(css, (unsigned int)cft->private);
2377 return ret ? ret : nbytes; 2382 return ret ? ret : nbytes;
2378 } 2383 }
2379 return -EINVAL; 2384 return -EINVAL;
2380} 2385}
2381 2386
2382static ssize_t cgroup_read_u64(struct cgroup *cgrp, struct cftype *cft, 2387static ssize_t cgroup_read_u64(struct cgroup_subsys_state *css,
2383 struct file *file, 2388 struct cftype *cft, struct file *file,
2384 char __user *buf, size_t nbytes, 2389 char __user *buf, size_t nbytes, loff_t *ppos)
2385 loff_t *ppos)
2386{ 2390{
2387 char tmp[CGROUP_LOCAL_BUFFER_SIZE]; 2391 char tmp[CGROUP_LOCAL_BUFFER_SIZE];
2388 u64 val = cft->read_u64(cgrp, cft); 2392 u64 val = cft->read_u64(css, cft);
2389 int len = sprintf(tmp, "%llu\n", (unsigned long long) val); 2393 int len = sprintf(tmp, "%llu\n", (unsigned long long) val);
2390 2394
2391 return simple_read_from_buffer(buf, nbytes, ppos, tmp, len); 2395 return simple_read_from_buffer(buf, nbytes, ppos, tmp, len);
2392} 2396}
2393 2397
2394static ssize_t cgroup_read_s64(struct cgroup *cgrp, struct cftype *cft, 2398static ssize_t cgroup_read_s64(struct cgroup_subsys_state *css,
2395 struct file *file, 2399 struct cftype *cft, struct file *file,
2396 char __user *buf, size_t nbytes, 2400 char __user *buf, size_t nbytes, loff_t *ppos)
2397 loff_t *ppos)
2398{ 2401{
2399 char tmp[CGROUP_LOCAL_BUFFER_SIZE]; 2402 char tmp[CGROUP_LOCAL_BUFFER_SIZE];
2400 s64 val = cft->read_s64(cgrp, cft); 2403 s64 val = cft->read_s64(css, cft);
2401 int len = sprintf(tmp, "%lld\n", (long long) val); 2404 int len = sprintf(tmp, "%lld\n", (long long) val);
2402 2405
2403 return simple_read_from_buffer(buf, nbytes, ppos, tmp, len); 2406 return simple_read_from_buffer(buf, nbytes, ppos, tmp, len);
2404} 2407}
2405 2408
2406static ssize_t cgroup_file_read(struct file *file, char __user *buf, 2409static ssize_t cgroup_file_read(struct file *file, char __user *buf,
2407 size_t nbytes, loff_t *ppos) 2410 size_t nbytes, loff_t *ppos)
2408{ 2411{
2412 struct cfent *cfe = __d_cfe(file->f_dentry);
2409 struct cftype *cft = __d_cft(file->f_dentry); 2413 struct cftype *cft = __d_cft(file->f_dentry);
2410 struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent); 2414 struct cgroup_subsys_state *css = cgroup_file_css(cfe);
2411 2415
2412 if (cft->read) 2416 if (cft->read)
2413 return cft->read(cgrp, cft, file, buf, nbytes, ppos); 2417 return cft->read(css, cft, file, buf, nbytes, ppos);
2414 if (cft->read_u64) 2418 if (cft->read_u64)
2415 return cgroup_read_u64(cgrp, cft, file, buf, nbytes, ppos); 2419 return cgroup_read_u64(css, cft, file, buf, nbytes, ppos);
2416 if (cft->read_s64) 2420 if (cft->read_s64)
2417 return cgroup_read_s64(cgrp, cft, file, buf, nbytes, ppos); 2421 return cgroup_read_s64(css, cft, file, buf, nbytes, ppos);
2418 return -EINVAL; 2422 return -EINVAL;
2419} 2423}
2420 2424
@@ -2433,16 +2437,16 @@ static int cgroup_seqfile_show(struct seq_file *m, void *arg)
2433{ 2437{
2434 struct cfent *cfe = m->private; 2438 struct cfent *cfe = m->private;
2435 struct cftype *cft = cfe->type; 2439 struct cftype *cft = cfe->type;
2436 struct cgroup *cgrp = __d_cgrp(cfe->dentry->d_parent); 2440 struct cgroup_subsys_state *css = cgroup_file_css(cfe);
2437 2441
2438 if (cft->read_map) { 2442 if (cft->read_map) {
2439 struct cgroup_map_cb cb = { 2443 struct cgroup_map_cb cb = {
2440 .fill = cgroup_map_add, 2444 .fill = cgroup_map_add,
2441 .state = m, 2445 .state = m,
2442 }; 2446 };
2443 return cft->read_map(cgrp, cft, &cb); 2447 return cft->read_map(css, cft, &cb);
2444 } 2448 }
2445 return cft->read_seq_string(cgrp, cft, m); 2449 return cft->read_seq_string(css, cft, m);
2446} 2450}
2447 2451
2448static const struct file_operations cgroup_seqfile_operations = { 2452static const struct file_operations cgroup_seqfile_operations = {
@@ -3860,21 +3864,20 @@ static int cgroup_procs_open(struct inode *unused, struct file *file)
3860 return cgroup_pidlist_open(file, CGROUP_FILE_PROCS); 3864 return cgroup_pidlist_open(file, CGROUP_FILE_PROCS);
3861} 3865}
3862 3866
3863static u64 cgroup_read_notify_on_release(struct cgroup *cgrp, 3867static u64 cgroup_read_notify_on_release(struct cgroup_subsys_state *css,
3864 struct cftype *cft) 3868 struct cftype *cft)
3865{ 3869{
3866 return notify_on_release(cgrp); 3870 return notify_on_release(css->cgroup);
3867} 3871}
3868 3872
3869static int cgroup_write_notify_on_release(struct cgroup *cgrp, 3873static int cgroup_write_notify_on_release(struct cgroup_subsys_state *css,
3870 struct cftype *cft, 3874 struct cftype *cft, u64 val)
3871 u64 val)
3872{ 3875{
3873 clear_bit(CGRP_RELEASABLE, &cgrp->flags); 3876 clear_bit(CGRP_RELEASABLE, &css->cgroup->flags);
3874 if (val) 3877 if (val)
3875 set_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); 3878 set_bit(CGRP_NOTIFY_ON_RELEASE, &css->cgroup->flags);
3876 else 3879 else
3877 clear_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); 3880 clear_bit(CGRP_NOTIFY_ON_RELEASE, &css->cgroup->flags);
3878 return 0; 3881 return 0;
3879} 3882}
3880 3883
@@ -3972,9 +3975,10 @@ static void cgroup_event_ptable_queue_proc(struct file *file,
3972 * Input must be in format '<event_fd> <control_fd> <args>'. 3975 * Input must be in format '<event_fd> <control_fd> <args>'.
3973 * Interpretation of args is defined by control file implementation. 3976 * Interpretation of args is defined by control file implementation.
3974 */ 3977 */
3975static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft, 3978static int cgroup_write_event_control(struct cgroup_subsys_state *css,
3976 const char *buffer) 3979 struct cftype *cft, const char *buffer)
3977{ 3980{
3981 struct cgroup *cgrp = css->cgroup;
3978 struct cgroup_event *event; 3982 struct cgroup_event *event;
3979 struct cgroup *cgrp_cfile; 3983 struct cgroup *cgrp_cfile;
3980 unsigned int efd, cfd; 3984 unsigned int efd, cfd;
@@ -4082,20 +4086,19 @@ out_kfree:
4082 return ret; 4086 return ret;
4083} 4087}
4084 4088
4085static u64 cgroup_clone_children_read(struct cgroup *cgrp, 4089static u64 cgroup_clone_children_read(struct cgroup_subsys_state *css,
4086 struct cftype *cft) 4090 struct cftype *cft)
4087{ 4091{
4088 return test_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags); 4092 return test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags);
4089} 4093}
4090 4094
4091static int cgroup_clone_children_write(struct cgroup *cgrp, 4095static int cgroup_clone_children_write(struct cgroup_subsys_state *css,
4092 struct cftype *cft, 4096 struct cftype *cft, u64 val)
4093 u64 val)
4094{ 4097{
4095 if (val) 4098 if (val)
4096 set_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags); 4099 set_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags);
4097 else 4100 else
4098 clear_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags); 4101 clear_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags);
4099 return 0; 4102 return 0;
4100} 4103}
4101 4104
@@ -5585,17 +5588,19 @@ static void debug_css_free(struct cgroup_subsys_state *css)
5585 kfree(css); 5588 kfree(css);
5586} 5589}
5587 5590
5588static u64 debug_taskcount_read(struct cgroup *cgrp, struct cftype *cft) 5591static u64 debug_taskcount_read(struct cgroup_subsys_state *css,
5592 struct cftype *cft)
5589{ 5593{
5590 return cgroup_task_count(cgrp); 5594 return cgroup_task_count(css->cgroup);
5591} 5595}
5592 5596
5593static u64 current_css_set_read(struct cgroup *cgrp, struct cftype *cft) 5597static u64 current_css_set_read(struct cgroup_subsys_state *css,
5598 struct cftype *cft)
5594{ 5599{
5595 return (u64)(unsigned long)current->cgroups; 5600 return (u64)(unsigned long)current->cgroups;
5596} 5601}
5597 5602
5598static u64 current_css_set_refcount_read(struct cgroup *cgrp, 5603static u64 current_css_set_refcount_read(struct cgroup_subsys_state *css,
5599 struct cftype *cft) 5604 struct cftype *cft)
5600{ 5605{
5601 u64 count; 5606 u64 count;
@@ -5606,7 +5611,7 @@ static u64 current_css_set_refcount_read(struct cgroup *cgrp,
5606 return count; 5611 return count;
5607} 5612}
5608 5613
5609static int current_css_set_cg_links_read(struct cgroup *cgrp, 5614static int current_css_set_cg_links_read(struct cgroup_subsys_state *css,
5610 struct cftype *cft, 5615 struct cftype *cft,
5611 struct seq_file *seq) 5616 struct seq_file *seq)
5612{ 5617{
@@ -5633,14 +5638,13 @@ static int current_css_set_cg_links_read(struct cgroup *cgrp,
5633} 5638}
5634 5639
5635#define MAX_TASKS_SHOWN_PER_CSS 25 5640#define MAX_TASKS_SHOWN_PER_CSS 25
5636static int cgroup_css_links_read(struct cgroup *cgrp, 5641static int cgroup_css_links_read(struct cgroup_subsys_state *css,
5637 struct cftype *cft, 5642 struct cftype *cft, struct seq_file *seq)
5638 struct seq_file *seq)
5639{ 5643{
5640 struct cgrp_cset_link *link; 5644 struct cgrp_cset_link *link;
5641 5645
5642 read_lock(&css_set_lock); 5646 read_lock(&css_set_lock);
5643 list_for_each_entry(link, &cgrp->cset_links, cset_link) { 5647 list_for_each_entry(link, &css->cgroup->cset_links, cset_link) {
5644 struct css_set *cset = link->cset; 5648 struct css_set *cset = link->cset;
5645 struct task_struct *task; 5649 struct task_struct *task;
5646 int count = 0; 5650 int count = 0;
@@ -5659,9 +5663,9 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
5659 return 0; 5663 return 0;
5660} 5664}
5661 5665
5662static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft) 5666static u64 releasable_read(struct cgroup_subsys_state *css, struct cftype *cft)
5663{ 5667{
5664 return test_bit(CGRP_RELEASABLE, &cgrp->flags); 5668 return test_bit(CGRP_RELEASABLE, &css->cgroup->flags);
5665} 5669}
5666 5670
5667static struct cftype debug_files[] = { 5671static struct cftype debug_files[] = {
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index f03a85719c3c..19613ba51444 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -245,7 +245,7 @@ out:
245 245
246/** 246/**
247 * update_if_frozen - update whether a cgroup finished freezing 247 * update_if_frozen - update whether a cgroup finished freezing
248 * @cgroup: cgroup of interest 248 * @css: css of interest
249 * 249 *
250 * Once FREEZING is initiated, transition to FROZEN is lazily updated by 250 * Once FREEZING is initiated, transition to FROZEN is lazily updated by
251 * calling this function. If the current state is FREEZING but not FROZEN, 251 * calling this function. If the current state is FREEZING but not FROZEN,
@@ -256,12 +256,12 @@ out:
256 * update_if_frozen() on all descendants prior to invoking this function. 256 * update_if_frozen() on all descendants prior to invoking this function.
257 * 257 *
258 * Task states and freezer state might disagree while tasks are being 258 * Task states and freezer state might disagree while tasks are being
259 * migrated into or out of @cgroup, so we can't verify task states against 259 * migrated into or out of @css, so we can't verify task states against
260 * @freezer state here. See freezer_attach() for details. 260 * @freezer state here. See freezer_attach() for details.
261 */ 261 */
262static void update_if_frozen(struct cgroup *cgroup) 262static void update_if_frozen(struct cgroup_subsys_state *css)
263{ 263{
264 struct freezer *freezer = cgroup_freezer(cgroup); 264 struct freezer *freezer = css_freezer(css);
265 struct cgroup *pos; 265 struct cgroup *pos;
266 struct cgroup_iter it; 266 struct cgroup_iter it;
267 struct task_struct *task; 267 struct task_struct *task;
@@ -275,7 +275,7 @@ static void update_if_frozen(struct cgroup *cgroup)
275 goto out_unlock; 275 goto out_unlock;
276 276
277 /* are all (live) children frozen? */ 277 /* are all (live) children frozen? */
278 cgroup_for_each_child(pos, cgroup) { 278 cgroup_for_each_child(pos, css->cgroup) {
279 struct freezer *child = cgroup_freezer(pos); 279 struct freezer *child = cgroup_freezer(pos);
280 280
281 if ((child->state & CGROUP_FREEZER_ONLINE) && 281 if ((child->state & CGROUP_FREEZER_ONLINE) &&
@@ -284,9 +284,9 @@ static void update_if_frozen(struct cgroup *cgroup)
284 } 284 }
285 285
286 /* are all tasks frozen? */ 286 /* are all tasks frozen? */
287 cgroup_iter_start(cgroup, &it); 287 cgroup_iter_start(css->cgroup, &it);
288 288
289 while ((task = cgroup_iter_next(cgroup, &it))) { 289 while ((task = cgroup_iter_next(css->cgroup, &it))) {
290 if (freezing(task)) { 290 if (freezing(task)) {
291 /* 291 /*
292 * freezer_should_skip() indicates that the task 292 * freezer_should_skip() indicates that the task
@@ -301,12 +301,12 @@ static void update_if_frozen(struct cgroup *cgroup)
301 301
302 freezer->state |= CGROUP_FROZEN; 302 freezer->state |= CGROUP_FROZEN;
303out_iter_end: 303out_iter_end:
304 cgroup_iter_end(cgroup, &it); 304 cgroup_iter_end(css->cgroup, &it);
305out_unlock: 305out_unlock:
306 spin_unlock_irq(&freezer->lock); 306 spin_unlock_irq(&freezer->lock);
307} 307}
308 308
309static int freezer_read(struct cgroup *cgroup, struct cftype *cft, 309static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft,
310 struct seq_file *m) 310 struct seq_file *m)
311{ 311{
312 struct cgroup *pos; 312 struct cgroup *pos;
@@ -314,13 +314,13 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft,
314 rcu_read_lock(); 314 rcu_read_lock();
315 315
316 /* update states bottom-up */ 316 /* update states bottom-up */
317 cgroup_for_each_descendant_post(pos, cgroup) 317 cgroup_for_each_descendant_post(pos, css->cgroup)
318 update_if_frozen(pos); 318 update_if_frozen(cgroup_css(pos, freezer_subsys_id));
319 update_if_frozen(cgroup); 319 update_if_frozen(css);
320 320
321 rcu_read_unlock(); 321 rcu_read_unlock();
322 322
323 seq_puts(m, freezer_state_strs(cgroup_freezer(cgroup)->state)); 323 seq_puts(m, freezer_state_strs(css_freezer(css)->state));
324 seq_putc(m, '\n'); 324 seq_putc(m, '\n');
325 return 0; 325 return 0;
326} 326}
@@ -426,7 +426,7 @@ static void freezer_change_state(struct freezer *freezer, bool freeze)
426 rcu_read_unlock(); 426 rcu_read_unlock();
427} 427}
428 428
429static int freezer_write(struct cgroup *cgroup, struct cftype *cft, 429static int freezer_write(struct cgroup_subsys_state *css, struct cftype *cft,
430 const char *buffer) 430 const char *buffer)
431{ 431{
432 bool freeze; 432 bool freeze;
@@ -438,20 +438,22 @@ static int freezer_write(struct cgroup *cgroup, struct cftype *cft,
438 else 438 else
439 return -EINVAL; 439 return -EINVAL;
440 440
441 freezer_change_state(cgroup_freezer(cgroup), freeze); 441 freezer_change_state(css_freezer(css), freeze);
442 return 0; 442 return 0;
443} 443}
444 444
445static u64 freezer_self_freezing_read(struct cgroup *cgroup, struct cftype *cft) 445static u64 freezer_self_freezing_read(struct cgroup_subsys_state *css,
446 struct cftype *cft)
446{ 447{
447 struct freezer *freezer = cgroup_freezer(cgroup); 448 struct freezer *freezer = css_freezer(css);
448 449
449 return (bool)(freezer->state & CGROUP_FREEZING_SELF); 450 return (bool)(freezer->state & CGROUP_FREEZING_SELF);
450} 451}
451 452
452static u64 freezer_parent_freezing_read(struct cgroup *cgroup, struct cftype *cft) 453static u64 freezer_parent_freezing_read(struct cgroup_subsys_state *css,
454 struct cftype *cft)
453{ 455{
454 struct freezer *freezer = cgroup_freezer(cgroup); 456 struct freezer *freezer = css_freezer(css);
455 457
456 return (bool)(freezer->state & CGROUP_FREEZING_PARENT); 458 return (bool)(freezer->state & CGROUP_FREEZING_PARENT);
457} 459}
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 8ce3fdc3dfcc..89b76e1d3aa1 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1603,9 +1603,10 @@ typedef enum {
1603 FILE_SPREAD_SLAB, 1603 FILE_SPREAD_SLAB,
1604} cpuset_filetype_t; 1604} cpuset_filetype_t;
1605 1605
1606static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val) 1606static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
1607 u64 val)
1607{ 1608{
1608 struct cpuset *cs = cgroup_cs(cgrp); 1609 struct cpuset *cs = css_cs(css);
1609 cpuset_filetype_t type = cft->private; 1610 cpuset_filetype_t type = cft->private;
1610 int retval = -ENODEV; 1611 int retval = -ENODEV;
1611 1612
@@ -1650,9 +1651,10 @@ out_unlock:
1650 return retval; 1651 return retval;
1651} 1652}
1652 1653
1653static int cpuset_write_s64(struct cgroup *cgrp, struct cftype *cft, s64 val) 1654static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
1655 s64 val)
1654{ 1656{
1655 struct cpuset *cs = cgroup_cs(cgrp); 1657 struct cpuset *cs = css_cs(css);
1656 cpuset_filetype_t type = cft->private; 1658 cpuset_filetype_t type = cft->private;
1657 int retval = -ENODEV; 1659 int retval = -ENODEV;
1658 1660
@@ -1676,10 +1678,10 @@ out_unlock:
1676/* 1678/*
1677 * Common handling for a write to a "cpus" or "mems" file. 1679 * Common handling for a write to a "cpus" or "mems" file.
1678 */ 1680 */
1679static int cpuset_write_resmask(struct cgroup *cgrp, struct cftype *cft, 1681static int cpuset_write_resmask(struct cgroup_subsys_state *css,
1680 const char *buf) 1682 struct cftype *cft, const char *buf)
1681{ 1683{
1682 struct cpuset *cs = cgroup_cs(cgrp); 1684 struct cpuset *cs = css_cs(css);
1683 struct cpuset *trialcs; 1685 struct cpuset *trialcs;
1684 int retval = -ENODEV; 1686 int retval = -ENODEV;
1685 1687
@@ -1758,13 +1760,12 @@ static size_t cpuset_sprintf_memlist(char *page, struct cpuset *cs)
1758 return count; 1760 return count;
1759} 1761}
1760 1762
1761static ssize_t cpuset_common_file_read(struct cgroup *cgrp, 1763static ssize_t cpuset_common_file_read(struct cgroup_subsys_state *css,
1762 struct cftype *cft, 1764 struct cftype *cft, struct file *file,
1763 struct file *file, 1765 char __user *buf, size_t nbytes,
1764 char __user *buf, 1766 loff_t *ppos)
1765 size_t nbytes, loff_t *ppos)
1766{ 1767{
1767 struct cpuset *cs = cgroup_cs(cgrp); 1768 struct cpuset *cs = css_cs(css);
1768 cpuset_filetype_t type = cft->private; 1769 cpuset_filetype_t type = cft->private;
1769 char *page; 1770 char *page;
1770 ssize_t retval = 0; 1771 ssize_t retval = 0;
@@ -1794,9 +1795,9 @@ out:
1794 return retval; 1795 return retval;
1795} 1796}
1796 1797
1797static u64 cpuset_read_u64(struct cgroup *cgrp, struct cftype *cft) 1798static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft)
1798{ 1799{
1799 struct cpuset *cs = cgroup_cs(cgrp); 1800 struct cpuset *cs = css_cs(css);
1800 cpuset_filetype_t type = cft->private; 1801 cpuset_filetype_t type = cft->private;
1801 switch (type) { 1802 switch (type) {
1802 case FILE_CPU_EXCLUSIVE: 1803 case FILE_CPU_EXCLUSIVE:
@@ -1825,9 +1826,9 @@ static u64 cpuset_read_u64(struct cgroup *cgrp, struct cftype *cft)
1825 return 0; 1826 return 0;
1826} 1827}
1827 1828
1828static s64 cpuset_read_s64(struct cgroup *cgrp, struct cftype *cft) 1829static s64 cpuset_read_s64(struct cgroup_subsys_state *css, struct cftype *cft)
1829{ 1830{
1830 struct cpuset *cs = cgroup_cs(cgrp); 1831 struct cpuset *cs = css_cs(css);
1831 cpuset_filetype_t type = cft->private; 1832 cpuset_filetype_t type = cft->private;
1832 switch (type) { 1833 switch (type) {
1833 case FILE_SCHED_RELAX_DOMAIN_LEVEL: 1834 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 622b7efc5ade..cc9a49266382 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7088,12 +7088,6 @@ static inline struct task_group *css_tg(struct cgroup_subsys_state *css)
7088 return css ? container_of(css, struct task_group, css) : NULL; 7088 return css ? container_of(css, struct task_group, css) : NULL;
7089} 7089}
7090 7090
7091/* return corresponding task_group object of a cgroup */
7092static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
7093{
7094 return css_tg(cgroup_css(cgrp, cpu_cgroup_subsys_id));
7095}
7096
7097static struct cgroup_subsys_state * 7091static struct cgroup_subsys_state *
7098cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) 7092cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
7099{ 7093{
@@ -7179,15 +7173,16 @@ static void cpu_cgroup_exit(struct cgroup_subsys_state *css,
7179} 7173}
7180 7174
7181#ifdef CONFIG_FAIR_GROUP_SCHED 7175#ifdef CONFIG_FAIR_GROUP_SCHED
7182static int cpu_shares_write_u64(struct cgroup *cgrp, struct cftype *cftype, 7176static int cpu_shares_write_u64(struct cgroup_subsys_state *css,
7183 u64 shareval) 7177 struct cftype *cftype, u64 shareval)
7184{ 7178{
7185 return sched_group_set_shares(cgroup_tg(cgrp), scale_load(shareval)); 7179 return sched_group_set_shares(css_tg(css), scale_load(shareval));
7186} 7180}
7187 7181
7188static u64 cpu_shares_read_u64(struct cgroup *cgrp, struct cftype *cft) 7182static u64 cpu_shares_read_u64(struct cgroup_subsys_state *css,
7183 struct cftype *cft)
7189{ 7184{
7190 struct task_group *tg = cgroup_tg(cgrp); 7185 struct task_group *tg = css_tg(css);
7191 7186
7192 return (u64) scale_load_down(tg->shares); 7187 return (u64) scale_load_down(tg->shares);
7193} 7188}
@@ -7309,26 +7304,28 @@ long tg_get_cfs_period(struct task_group *tg)
7309 return cfs_period_us; 7304 return cfs_period_us;
7310} 7305}
7311 7306
7312static s64 cpu_cfs_quota_read_s64(struct cgroup *cgrp, struct cftype *cft) 7307static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css,
7308 struct cftype *cft)
7313{ 7309{
7314 return tg_get_cfs_quota(cgroup_tg(cgrp)); 7310 return tg_get_cfs_quota(css_tg(css));
7315} 7311}
7316 7312
7317static int cpu_cfs_quota_write_s64(struct cgroup *cgrp, struct cftype *cftype, 7313static int cpu_cfs_quota_write_s64(struct cgroup_subsys_state *css,
7318 s64 cfs_quota_us) 7314 struct cftype *cftype, s64 cfs_quota_us)
7319{ 7315{
7320 return tg_set_cfs_quota(cgroup_tg(cgrp), cfs_quota_us); 7316 return tg_set_cfs_quota(css_tg(css), cfs_quota_us);
7321} 7317}
7322 7318
7323static u64 cpu_cfs_period_read_u64(struct cgroup *cgrp, struct cftype *cft) 7319static u64 cpu_cfs_period_read_u64(struct cgroup_subsys_state *css,
7320 struct cftype *cft)
7324{ 7321{
7325 return tg_get_cfs_period(cgroup_tg(cgrp)); 7322 return tg_get_cfs_period(css_tg(css));
7326} 7323}
7327 7324
7328static int cpu_cfs_period_write_u64(struct cgroup *cgrp, struct cftype *cftype, 7325static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css,
7329 u64 cfs_period_us) 7326 struct cftype *cftype, u64 cfs_period_us)
7330{ 7327{
7331 return tg_set_cfs_period(cgroup_tg(cgrp), cfs_period_us); 7328 return tg_set_cfs_period(css_tg(css), cfs_period_us);
7332} 7329}
7333 7330
7334struct cfs_schedulable_data { 7331struct cfs_schedulable_data {
@@ -7409,10 +7406,10 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota)
7409 return ret; 7406 return ret;
7410} 7407}
7411 7408
7412static int cpu_stats_show(struct cgroup *cgrp, struct cftype *cft, 7409static int cpu_stats_show(struct cgroup_subsys_state *css, struct cftype *cft,
7413 struct cgroup_map_cb *cb) 7410 struct cgroup_map_cb *cb)
7414{ 7411{
7415 struct task_group *tg = cgroup_tg(cgrp); 7412 struct task_group *tg = css_tg(css);
7416 struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; 7413 struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
7417 7414
7418 cb->fill(cb, "nr_periods", cfs_b->nr_periods); 7415 cb->fill(cb, "nr_periods", cfs_b->nr_periods);
@@ -7425,26 +7422,28 @@ static int cpu_stats_show(struct cgroup *cgrp, struct cftype *cft,
7425#endif /* CONFIG_FAIR_GROUP_SCHED */ 7422#endif /* CONFIG_FAIR_GROUP_SCHED */
7426 7423
7427#ifdef CONFIG_RT_GROUP_SCHED 7424#ifdef CONFIG_RT_GROUP_SCHED
7428static int cpu_rt_runtime_write(struct cgroup *cgrp, struct cftype *cft, 7425static int cpu_rt_runtime_write(struct cgroup_subsys_state *css,
7429 s64 val) 7426 struct cftype *cft, s64 val)
7430{ 7427{
7431 return sched_group_set_rt_runtime(cgroup_tg(cgrp), val); 7428 return sched_group_set_rt_runtime(css_tg(css), val);
7432} 7429}
7433 7430
7434static s64 cpu_rt_runtime_read(struct cgroup *cgrp, struct cftype *cft) 7431static s64 cpu_rt_runtime_read(struct cgroup_subsys_state *css,
7432 struct cftype *cft)
7435{ 7433{
7436 return sched_group_rt_runtime(cgroup_tg(cgrp)); 7434 return sched_group_rt_runtime(css_tg(css));
7437} 7435}
7438 7436
7439static int cpu_rt_period_write_uint(struct cgroup *cgrp, struct cftype *cftype, 7437static int cpu_rt_period_write_uint(struct cgroup_subsys_state *css,
7440 u64 rt_period_us) 7438 struct cftype *cftype, u64 rt_period_us)
7441{ 7439{
7442 return sched_group_set_rt_period(cgroup_tg(cgrp), rt_period_us); 7440 return sched_group_set_rt_period(css_tg(css), rt_period_us);
7443} 7441}
7444 7442
7445static u64 cpu_rt_period_read_uint(struct cgroup *cgrp, struct cftype *cft) 7443static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css,
7444 struct cftype *cft)
7446{ 7445{
7447 return sched_group_rt_period(cgroup_tg(cgrp)); 7446 return sched_group_rt_period(css_tg(css));
7448} 7447}
7449#endif /* CONFIG_RT_GROUP_SCHED */ 7448#endif /* CONFIG_RT_GROUP_SCHED */
7450 7449
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 1b784d9b3630..f64722ff0299 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -38,12 +38,6 @@ static inline struct cpuacct *css_ca(struct cgroup_subsys_state *css)
38 return css ? container_of(css, struct cpuacct, css) : NULL; 38 return css ? container_of(css, struct cpuacct, css) : NULL;
39} 39}
40 40
41/* return cpu accounting group corresponding to this container */
42static inline struct cpuacct *cgroup_ca(struct cgroup *cgrp)
43{
44 return css_ca(cgroup_css(cgrp, cpuacct_subsys_id));
45}
46
47/* return cpu accounting group to which this task belongs */ 41/* return cpu accounting group to which this task belongs */
48static inline struct cpuacct *task_ca(struct task_struct *tsk) 42static inline struct cpuacct *task_ca(struct task_struct *tsk)
49{ 43{
@@ -138,9 +132,9 @@ static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val)
138} 132}
139 133
140/* return total cpu usage (in nanoseconds) of a group */ 134/* return total cpu usage (in nanoseconds) of a group */
141static u64 cpuusage_read(struct cgroup *cgrp, struct cftype *cft) 135static u64 cpuusage_read(struct cgroup_subsys_state *css, struct cftype *cft)
142{ 136{
143 struct cpuacct *ca = cgroup_ca(cgrp); 137 struct cpuacct *ca = css_ca(css);
144 u64 totalcpuusage = 0; 138 u64 totalcpuusage = 0;
145 int i; 139 int i;
146 140
@@ -150,10 +144,10 @@ static u64 cpuusage_read(struct cgroup *cgrp, struct cftype *cft)
150 return totalcpuusage; 144 return totalcpuusage;
151} 145}
152 146
153static int cpuusage_write(struct cgroup *cgrp, struct cftype *cftype, 147static int cpuusage_write(struct cgroup_subsys_state *css, struct cftype *cft,
154 u64 reset) 148 u64 reset)
155{ 149{
156 struct cpuacct *ca = cgroup_ca(cgrp); 150 struct cpuacct *ca = css_ca(css);
157 int err = 0; 151 int err = 0;
158 int i; 152 int i;
159 153
@@ -169,10 +163,10 @@ out:
169 return err; 163 return err;
170} 164}
171 165
172static int cpuacct_percpu_seq_read(struct cgroup *cgroup, struct cftype *cft, 166static int cpuacct_percpu_seq_read(struct cgroup_subsys_state *css,
173 struct seq_file *m) 167 struct cftype *cft, struct seq_file *m)
174{ 168{
175 struct cpuacct *ca = cgroup_ca(cgroup); 169 struct cpuacct *ca = css_ca(css);
176 u64 percpu; 170 u64 percpu;
177 int i; 171 int i;
178 172
@@ -189,10 +183,10 @@ static const char * const cpuacct_stat_desc[] = {
189 [CPUACCT_STAT_SYSTEM] = "system", 183 [CPUACCT_STAT_SYSTEM] = "system",
190}; 184};
191 185
192static int cpuacct_stats_show(struct cgroup *cgrp, struct cftype *cft, 186static int cpuacct_stats_show(struct cgroup_subsys_state *css,
193 struct cgroup_map_cb *cb) 187 struct cftype *cft, struct cgroup_map_cb *cb)
194{ 188{
195 struct cpuacct *ca = cgroup_ca(cgrp); 189 struct cpuacct *ca = css_ca(css);
196 int cpu; 190 int cpu;
197 s64 val = 0; 191 s64 val = 0;
198 192