diff options
| author | Tejun Heo <tj@kernel.org> | 2013-12-05 12:28:04 -0500 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2013-12-05 12:28:04 -0500 |
| commit | 2da8ca822d49c8b8781800ad155aaa00e7bb5f1a (patch) | |
| tree | 9ec6b0a7a009d76d0c607640eae64d3e9ed666a9 /kernel | |
| parent | 7da112792753d71aed44b918395892a1fc53048a (diff) | |
cgroup: replace cftype->read_seq_string() with cftype->seq_show()
In preparation of conversion to kernfs, cgroup file handling is
updated so that it can be easily mapped to kernfs. This patch
replaces cftype->read_seq_string() with cftype->seq_show() which is
not limited to single_open() operation and will map directcly to
kernfs seq_file interface.
The conversions are mechanical. As ->seq_show() doesn't have @css and
@cft, the functions which make use of them are converted to use
seq_css() and seq_cft() respectively. In several occassions, e.f. if
it has seq_string in its name, the function name is updated to fit the
new method better.
This patch does not introduce any behavior changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Aristeu Rozanski <arozansk@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cgroup.c | 34 | ||||
| -rw-r--r-- | kernel/cgroup_freezer.c | 7 | ||||
| -rw-r--r-- | kernel/cpuset.c | 12 | ||||
| -rw-r--r-- | kernel/sched/core.c | 7 | ||||
| -rw-r--r-- | kernel/sched/cpuacct.c | 14 |
5 files changed, 33 insertions, 41 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 036c05d8e572..c45e63328a0a 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -2212,10 +2212,9 @@ static int cgroup_release_agent_write(struct cgroup_subsys_state *css, | |||
| 2212 | return 0; | 2212 | return 0; |
| 2213 | } | 2213 | } |
| 2214 | 2214 | ||
| 2215 | static int cgroup_release_agent_show(struct cgroup_subsys_state *css, | 2215 | static int cgroup_release_agent_show(struct seq_file *seq, void *v) |
| 2216 | struct cftype *cft, struct seq_file *seq) | ||
| 2217 | { | 2216 | { |
| 2218 | struct cgroup *cgrp = css->cgroup; | 2217 | struct cgroup *cgrp = seq_css(seq)->cgroup; |
| 2219 | 2218 | ||
| 2220 | if (!cgroup_lock_live_group(cgrp)) | 2219 | if (!cgroup_lock_live_group(cgrp)) |
| 2221 | return -ENODEV; | 2220 | return -ENODEV; |
| @@ -2225,10 +2224,11 @@ static int cgroup_release_agent_show(struct cgroup_subsys_state *css, | |||
| 2225 | return 0; | 2224 | return 0; |
| 2226 | } | 2225 | } |
| 2227 | 2226 | ||
| 2228 | static int cgroup_sane_behavior_show(struct cgroup_subsys_state *css, | 2227 | static int cgroup_sane_behavior_show(struct seq_file *seq, void *v) |
| 2229 | struct cftype *cft, struct seq_file *seq) | ||
| 2230 | { | 2228 | { |
| 2231 | seq_printf(seq, "%d\n", cgroup_sane_behavior(css->cgroup)); | 2229 | struct cgroup *cgrp = seq_css(seq)->cgroup; |
| 2230 | |||
| 2231 | seq_printf(seq, "%d\n", cgroup_sane_behavior(cgrp)); | ||
| 2232 | return 0; | 2232 | return 0; |
| 2233 | } | 2233 | } |
| 2234 | 2234 | ||
| @@ -2291,8 +2291,8 @@ static int cgroup_seqfile_show(struct seq_file *m, void *arg) | |||
| 2291 | struct cftype *cft = seq_cft(m); | 2291 | struct cftype *cft = seq_cft(m); |
| 2292 | struct cgroup_subsys_state *css = seq_css(m); | 2292 | struct cgroup_subsys_state *css = seq_css(m); |
| 2293 | 2293 | ||
| 2294 | if (cft->read_seq_string) | 2294 | if (cft->seq_show) |
| 2295 | return cft->read_seq_string(css, cft, m); | 2295 | return cft->seq_show(m, arg); |
| 2296 | 2296 | ||
| 2297 | if (cft->read_u64) | 2297 | if (cft->read_u64) |
| 2298 | seq_printf(m, "%llu\n", cft->read_u64(css, cft)); | 2298 | seq_printf(m, "%llu\n", cft->read_u64(css, cft)); |
| @@ -2559,7 +2559,7 @@ static umode_t cgroup_file_mode(const struct cftype *cft) | |||
| 2559 | if (cft->mode) | 2559 | if (cft->mode) |
| 2560 | return cft->mode; | 2560 | return cft->mode; |
| 2561 | 2561 | ||
| 2562 | if (cft->read_u64 || cft->read_s64 || cft->read_seq_string) | 2562 | if (cft->read_u64 || cft->read_s64 || cft->seq_show) |
| 2563 | mode |= S_IRUGO; | 2563 | mode |= S_IRUGO; |
| 2564 | 2564 | ||
| 2565 | if (cft->write_u64 || cft->write_s64 || cft->write_string || | 2565 | if (cft->write_u64 || cft->write_s64 || cft->write_string || |
| @@ -3874,7 +3874,7 @@ static struct cftype cgroup_base_files[] = { | |||
| 3874 | { | 3874 | { |
| 3875 | .name = "cgroup.sane_behavior", | 3875 | .name = "cgroup.sane_behavior", |
| 3876 | .flags = CFTYPE_ONLY_ON_ROOT, | 3876 | .flags = CFTYPE_ONLY_ON_ROOT, |
| 3877 | .read_seq_string = cgroup_sane_behavior_show, | 3877 | .seq_show = cgroup_sane_behavior_show, |
| 3878 | }, | 3878 | }, |
| 3879 | 3879 | ||
| 3880 | /* | 3880 | /* |
| @@ -3899,7 +3899,7 @@ static struct cftype cgroup_base_files[] = { | |||
| 3899 | { | 3899 | { |
| 3900 | .name = "release_agent", | 3900 | .name = "release_agent", |
| 3901 | .flags = CFTYPE_INSANE | CFTYPE_ONLY_ON_ROOT, | 3901 | .flags = CFTYPE_INSANE | CFTYPE_ONLY_ON_ROOT, |
| 3902 | .read_seq_string = cgroup_release_agent_show, | 3902 | .seq_show = cgroup_release_agent_show, |
| 3903 | .write_string = cgroup_release_agent_write, | 3903 | .write_string = cgroup_release_agent_write, |
| 3904 | .max_write_len = PATH_MAX, | 3904 | .max_write_len = PATH_MAX, |
| 3905 | }, | 3905 | }, |
| @@ -5274,9 +5274,7 @@ static u64 current_css_set_refcount_read(struct cgroup_subsys_state *css, | |||
| 5274 | return count; | 5274 | return count; |
| 5275 | } | 5275 | } |
| 5276 | 5276 | ||
| 5277 | static int current_css_set_cg_links_read(struct cgroup_subsys_state *css, | 5277 | static int current_css_set_cg_links_read(struct seq_file *seq, void *v) |
| 5278 | struct cftype *cft, | ||
| 5279 | struct seq_file *seq) | ||
| 5280 | { | 5278 | { |
| 5281 | struct cgrp_cset_link *link; | 5279 | struct cgrp_cset_link *link; |
| 5282 | struct css_set *cset; | 5280 | struct css_set *cset; |
| @@ -5301,9 +5299,9 @@ static int current_css_set_cg_links_read(struct cgroup_subsys_state *css, | |||
| 5301 | } | 5299 | } |
| 5302 | 5300 | ||
| 5303 | #define MAX_TASKS_SHOWN_PER_CSS 25 | 5301 | #define MAX_TASKS_SHOWN_PER_CSS 25 |
| 5304 | static int cgroup_css_links_read(struct cgroup_subsys_state *css, | 5302 | static int cgroup_css_links_read(struct seq_file *seq, void *v) |
| 5305 | struct cftype *cft, struct seq_file *seq) | ||
| 5306 | { | 5303 | { |
| 5304 | struct cgroup_subsys_state *css = seq_css(seq); | ||
| 5307 | struct cgrp_cset_link *link; | 5305 | struct cgrp_cset_link *link; |
| 5308 | 5306 | ||
| 5309 | read_lock(&css_set_lock); | 5307 | read_lock(&css_set_lock); |
| @@ -5349,12 +5347,12 @@ static struct cftype debug_files[] = { | |||
| 5349 | 5347 | ||
| 5350 | { | 5348 | { |
| 5351 | .name = "current_css_set_cg_links", | 5349 | .name = "current_css_set_cg_links", |
| 5352 | .read_seq_string = current_css_set_cg_links_read, | 5350 | .seq_show = current_css_set_cg_links_read, |
| 5353 | }, | 5351 | }, |
| 5354 | 5352 | ||
| 5355 | { | 5353 | { |
| 5356 | .name = "cgroup_css_links", | 5354 | .name = "cgroup_css_links", |
| 5357 | .read_seq_string = cgroup_css_links_read, | 5355 | .seq_show = cgroup_css_links_read, |
| 5358 | }, | 5356 | }, |
| 5359 | 5357 | ||
| 5360 | { | 5358 | { |
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index f0ff64d0ebaa..6c3154e477f6 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
| @@ -301,10 +301,9 @@ out_unlock: | |||
| 301 | spin_unlock_irq(&freezer->lock); | 301 | spin_unlock_irq(&freezer->lock); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft, | 304 | static int freezer_read(struct seq_file *m, void *v) |
| 305 | struct seq_file *m) | ||
| 306 | { | 305 | { |
| 307 | struct cgroup_subsys_state *pos; | 306 | struct cgroup_subsys_state *css = seq_css(m), *pos; |
| 308 | 307 | ||
| 309 | rcu_read_lock(); | 308 | rcu_read_lock(); |
| 310 | 309 | ||
| @@ -458,7 +457,7 @@ static struct cftype files[] = { | |||
| 458 | { | 457 | { |
| 459 | .name = "state", | 458 | .name = "state", |
| 460 | .flags = CFTYPE_NOT_ON_ROOT, | 459 | .flags = CFTYPE_NOT_ON_ROOT, |
| 461 | .read_seq_string = freezer_read, | 460 | .seq_show = freezer_read, |
| 462 | .write_string = freezer_write, | 461 | .write_string = freezer_write, |
| 463 | }, | 462 | }, |
| 464 | { | 463 | { |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 032929f91648..4410ac6a55f1 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
| @@ -1732,12 +1732,10 @@ out_unlock: | |||
| 1732 | * and since these maps can change value dynamically, one could read | 1732 | * and since these maps can change value dynamically, one could read |
| 1733 | * gibberish by doing partial reads while a list was changing. | 1733 | * gibberish by doing partial reads while a list was changing. |
| 1734 | */ | 1734 | */ |
| 1735 | static int cpuset_common_read_seq_string(struct cgroup_subsys_state *css, | 1735 | static int cpuset_common_seq_show(struct seq_file *sf, void *v) |
| 1736 | struct cftype *cft, | ||
| 1737 | struct seq_file *sf) | ||
| 1738 | { | 1736 | { |
| 1739 | struct cpuset *cs = css_cs(css); | 1737 | struct cpuset *cs = css_cs(seq_css(sf)); |
| 1740 | cpuset_filetype_t type = cft->private; | 1738 | cpuset_filetype_t type = seq_cft(sf)->private; |
| 1741 | ssize_t count; | 1739 | ssize_t count; |
| 1742 | char *buf, *s; | 1740 | char *buf, *s; |
| 1743 | int ret = 0; | 1741 | int ret = 0; |
| @@ -1824,7 +1822,7 @@ static s64 cpuset_read_s64(struct cgroup_subsys_state *css, struct cftype *cft) | |||
| 1824 | static struct cftype files[] = { | 1822 | static struct cftype files[] = { |
| 1825 | { | 1823 | { |
| 1826 | .name = "cpus", | 1824 | .name = "cpus", |
| 1827 | .read_seq_string = cpuset_common_read_seq_string, | 1825 | .seq_show = cpuset_common_seq_show, |
| 1828 | .write_string = cpuset_write_resmask, | 1826 | .write_string = cpuset_write_resmask, |
| 1829 | .max_write_len = (100U + 6 * NR_CPUS), | 1827 | .max_write_len = (100U + 6 * NR_CPUS), |
| 1830 | .private = FILE_CPULIST, | 1828 | .private = FILE_CPULIST, |
| @@ -1832,7 +1830,7 @@ static struct cftype files[] = { | |||
| 1832 | 1830 | ||
| 1833 | { | 1831 | { |
| 1834 | .name = "mems", | 1832 | .name = "mems", |
| 1835 | .read_seq_string = cpuset_common_read_seq_string, | 1833 | .seq_show = cpuset_common_seq_show, |
| 1836 | .write_string = cpuset_write_resmask, | 1834 | .write_string = cpuset_write_resmask, |
| 1837 | .max_write_len = (100U + 6 * MAX_NUMNODES), | 1835 | .max_write_len = (100U + 6 * MAX_NUMNODES), |
| 1838 | .private = FILE_MEMLIST, | 1836 | .private = FILE_MEMLIST, |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f28ec6722f0b..7e8cbb9ee4d6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -7256,10 +7256,9 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota) | |||
| 7256 | return ret; | 7256 | return ret; |
| 7257 | } | 7257 | } |
| 7258 | 7258 | ||
| 7259 | static int cpu_stats_show(struct cgroup_subsys_state *css, struct cftype *cft, | 7259 | static int cpu_stats_show(struct seq_file *sf, void *v) |
| 7260 | struct seq_file *sf) | ||
| 7261 | { | 7260 | { |
| 7262 | struct task_group *tg = css_tg(css); | 7261 | struct task_group *tg = css_tg(seq_css(sf)); |
| 7263 | struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; | 7262 | struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; |
| 7264 | 7263 | ||
| 7265 | seq_printf(sf, "nr_periods %d\n", cfs_b->nr_periods); | 7264 | seq_printf(sf, "nr_periods %d\n", cfs_b->nr_periods); |
| @@ -7318,7 +7317,7 @@ static struct cftype cpu_files[] = { | |||
| 7318 | }, | 7317 | }, |
| 7319 | { | 7318 | { |
| 7320 | .name = "stat", | 7319 | .name = "stat", |
| 7321 | .read_seq_string = cpu_stats_show, | 7320 | .seq_show = cpu_stats_show, |
| 7322 | }, | 7321 | }, |
| 7323 | #endif | 7322 | #endif |
| 7324 | #ifdef CONFIG_RT_GROUP_SCHED | 7323 | #ifdef CONFIG_RT_GROUP_SCHED |
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index dd88738cd4a9..622e0818f905 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c | |||
| @@ -163,10 +163,9 @@ out: | |||
| 163 | return err; | 163 | return err; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | static int cpuacct_percpu_seq_read(struct cgroup_subsys_state *css, | 166 | static int cpuacct_percpu_seq_show(struct seq_file *m, void *V) |
| 167 | struct cftype *cft, struct seq_file *m) | ||
| 168 | { | 167 | { |
| 169 | struct cpuacct *ca = css_ca(css); | 168 | struct cpuacct *ca = css_ca(seq_css(m)); |
| 170 | u64 percpu; | 169 | u64 percpu; |
| 171 | int i; | 170 | int i; |
| 172 | 171 | ||
| @@ -183,10 +182,9 @@ static const char * const cpuacct_stat_desc[] = { | |||
| 183 | [CPUACCT_STAT_SYSTEM] = "system", | 182 | [CPUACCT_STAT_SYSTEM] = "system", |
| 184 | }; | 183 | }; |
| 185 | 184 | ||
| 186 | static int cpuacct_stats_show(struct cgroup_subsys_state *css, | 185 | static int cpuacct_stats_show(struct seq_file *sf, void *v) |
| 187 | struct cftype *cft, struct seq_file *sf) | ||
| 188 | { | 186 | { |
| 189 | struct cpuacct *ca = css_ca(css); | 187 | struct cpuacct *ca = css_ca(seq_css(sf)); |
| 190 | int cpu; | 188 | int cpu; |
| 191 | s64 val = 0; | 189 | s64 val = 0; |
| 192 | 190 | ||
| @@ -220,11 +218,11 @@ static struct cftype files[] = { | |||
| 220 | }, | 218 | }, |
| 221 | { | 219 | { |
| 222 | .name = "usage_percpu", | 220 | .name = "usage_percpu", |
| 223 | .read_seq_string = cpuacct_percpu_seq_read, | 221 | .seq_show = cpuacct_percpu_seq_show, |
| 224 | }, | 222 | }, |
| 225 | { | 223 | { |
| 226 | .name = "stat", | 224 | .name = "stat", |
| 227 | .read_seq_string = cpuacct_stats_show, | 225 | .seq_show = cpuacct_stats_show, |
| 228 | }, | 226 | }, |
| 229 | { } /* terminate */ | 227 | { } /* terminate */ |
| 230 | }; | 228 | }; |
