diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup/cgroup-internal.h | 1 | ||||
-rw-r--r-- | kernel/cgroup/cgroup.c | 60 | ||||
-rw-r--r-- | kernel/cgroup/stat.c | 10 | ||||
-rw-r--r-- | kernel/sched/core.c | 13 |
4 files changed, 68 insertions, 16 deletions
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h index fa642c99586a..4dc317090920 100644 --- a/kernel/cgroup/cgroup-internal.h +++ b/kernel/cgroup/cgroup-internal.h | |||
@@ -205,6 +205,7 @@ int cgroup_task_count(const struct cgroup *cgrp); | |||
205 | void cgroup_stat_flush(struct cgroup *cgrp); | 205 | void cgroup_stat_flush(struct cgroup *cgrp); |
206 | int cgroup_stat_init(struct cgroup *cgrp); | 206 | int cgroup_stat_init(struct cgroup *cgrp); |
207 | void cgroup_stat_exit(struct cgroup *cgrp); | 207 | void cgroup_stat_exit(struct cgroup *cgrp); |
208 | void cgroup_stat_show_cputime(struct seq_file *seq); | ||
208 | void cgroup_stat_boot(void); | 209 | void cgroup_stat_boot(void); |
209 | 210 | ||
210 | /* | 211 | /* |
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 7975b20f1fd1..d9773e49a1b4 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
@@ -464,6 +464,28 @@ static struct cgroup_subsys_state *cgroup_css(struct cgroup *cgrp, | |||
464 | } | 464 | } |
465 | 465 | ||
466 | /** | 466 | /** |
467 | * cgroup_tryget_css - try to get a cgroup's css for the specified subsystem | ||
468 | * @cgrp: the cgroup of interest | ||
469 | * @ss: the subsystem of interest | ||
470 | * | ||
471 | * Find and get @cgrp's css assocaited with @ss. If the css doesn't exist | ||
472 | * or is offline, %NULL is returned. | ||
473 | */ | ||
474 | static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp, | ||
475 | struct cgroup_subsys *ss) | ||
476 | { | ||
477 | struct cgroup_subsys_state *css; | ||
478 | |||
479 | rcu_read_lock(); | ||
480 | css = cgroup_css(cgrp, ss); | ||
481 | if (!css || !css_tryget_online(css)) | ||
482 | css = NULL; | ||
483 | rcu_read_unlock(); | ||
484 | |||
485 | return css; | ||
486 | } | ||
487 | |||
488 | /** | ||
467 | * cgroup_e_css - obtain a cgroup's effective css for the specified subsystem | 489 | * cgroup_e_css - obtain a cgroup's effective css for the specified subsystem |
468 | * @cgrp: the cgroup of interest | 490 | * @cgrp: the cgroup of interest |
469 | * @ss: the subsystem of interest (%NULL returns @cgrp->self) | 491 | * @ss: the subsystem of interest (%NULL returns @cgrp->self) |
@@ -3311,11 +3333,40 @@ static int cgroup_stat_show(struct seq_file *seq, void *v) | |||
3311 | seq_printf(seq, "nr_dying_descendants %d\n", | 3333 | seq_printf(seq, "nr_dying_descendants %d\n", |
3312 | cgroup->nr_dying_descendants); | 3334 | cgroup->nr_dying_descendants); |
3313 | 3335 | ||
3314 | cgroup_stat_show_cputime(seq, "cpu."); | ||
3315 | |||
3316 | return 0; | 3336 | return 0; |
3317 | } | 3337 | } |
3318 | 3338 | ||
3339 | static int __maybe_unused cgroup_extra_stat_show(struct seq_file *seq, | ||
3340 | struct cgroup *cgrp, int ssid) | ||
3341 | { | ||
3342 | struct cgroup_subsys *ss = cgroup_subsys[ssid]; | ||
3343 | struct cgroup_subsys_state *css; | ||
3344 | int ret; | ||
3345 | |||
3346 | if (!ss->css_extra_stat_show) | ||
3347 | return 0; | ||
3348 | |||
3349 | css = cgroup_tryget_css(cgrp, ss); | ||
3350 | if (!css) | ||
3351 | return 0; | ||
3352 | |||
3353 | ret = ss->css_extra_stat_show(seq, css); | ||
3354 | css_put(css); | ||
3355 | return ret; | ||
3356 | } | ||
3357 | |||
3358 | static int cpu_stat_show(struct seq_file *seq, void *v) | ||
3359 | { | ||
3360 | struct cgroup *cgrp = seq_css(seq)->cgroup; | ||
3361 | int ret = 0; | ||
3362 | |||
3363 | cgroup_stat_show_cputime(seq); | ||
3364 | #ifdef CONFIG_CGROUP_SCHED | ||
3365 | ret = cgroup_extra_stat_show(seq, cgrp, cpu_cgrp_id); | ||
3366 | #endif | ||
3367 | return ret; | ||
3368 | } | ||
3369 | |||
3319 | static int cgroup_file_open(struct kernfs_open_file *of) | 3370 | static int cgroup_file_open(struct kernfs_open_file *of) |
3320 | { | 3371 | { |
3321 | struct cftype *cft = of->kn->priv; | 3372 | struct cftype *cft = of->kn->priv; |
@@ -4423,6 +4474,11 @@ static struct cftype cgroup_base_files[] = { | |||
4423 | .name = "cgroup.stat", | 4474 | .name = "cgroup.stat", |
4424 | .seq_show = cgroup_stat_show, | 4475 | .seq_show = cgroup_stat_show, |
4425 | }, | 4476 | }, |
4477 | { | ||
4478 | .name = "cpu.stat", | ||
4479 | .flags = CFTYPE_NOT_ON_ROOT, | ||
4480 | .seq_show = cpu_stat_show, | ||
4481 | }, | ||
4426 | { } /* terminate */ | 4482 | { } /* terminate */ |
4427 | }; | 4483 | }; |
4428 | 4484 | ||
diff --git a/kernel/cgroup/stat.c b/kernel/cgroup/stat.c index 9cce79e89320..133b465691d6 100644 --- a/kernel/cgroup/stat.c +++ b/kernel/cgroup/stat.c | |||
@@ -256,7 +256,7 @@ void __cgroup_account_cputime_field(struct cgroup *cgrp, | |||
256 | cgroup_cpu_stat_account_end(cgrp, cstat); | 256 | cgroup_cpu_stat_account_end(cgrp, cstat); |
257 | } | 257 | } |
258 | 258 | ||
259 | void cgroup_stat_show_cputime(struct seq_file *seq, const char *prefix) | 259 | void cgroup_stat_show_cputime(struct seq_file *seq) |
260 | { | 260 | { |
261 | struct cgroup *cgrp = seq_css(seq)->cgroup; | 261 | struct cgroup *cgrp = seq_css(seq)->cgroup; |
262 | u64 usage, utime, stime; | 262 | u64 usage, utime, stime; |
@@ -278,10 +278,10 @@ void cgroup_stat_show_cputime(struct seq_file *seq, const char *prefix) | |||
278 | do_div(utime, NSEC_PER_USEC); | 278 | do_div(utime, NSEC_PER_USEC); |
279 | do_div(stime, NSEC_PER_USEC); | 279 | do_div(stime, NSEC_PER_USEC); |
280 | 280 | ||
281 | seq_printf(seq, "%susage_usec %llu\n" | 281 | seq_printf(seq, "usage_usec %llu\n" |
282 | "%suser_usec %llu\n" | 282 | "user_usec %llu\n" |
283 | "%ssystem_usec %llu\n", | 283 | "system_usec %llu\n", |
284 | prefix, usage, prefix, utime, prefix, stime); | 284 | usage, utime, stime); |
285 | } | 285 | } |
286 | 286 | ||
287 | int cgroup_stat_init(struct cgroup *cgrp) | 287 | int cgroup_stat_init(struct cgroup *cgrp) |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ad255162a830..0b3eec389552 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -6678,13 +6678,12 @@ static struct cftype cpu_legacy_files[] = { | |||
6678 | { } /* Terminate */ | 6678 | { } /* Terminate */ |
6679 | }; | 6679 | }; |
6680 | 6680 | ||
6681 | static int cpu_stat_show(struct seq_file *sf, void *v) | 6681 | static int cpu_extra_stat_show(struct seq_file *sf, |
6682 | struct cgroup_subsys_state *css) | ||
6682 | { | 6683 | { |
6683 | cgroup_stat_show_cputime(sf, ""); | ||
6684 | |||
6685 | #ifdef CONFIG_CFS_BANDWIDTH | 6684 | #ifdef CONFIG_CFS_BANDWIDTH |
6686 | { | 6685 | { |
6687 | struct task_group *tg = css_tg(seq_css(sf)); | 6686 | struct task_group *tg = css_tg(css); |
6688 | struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; | 6687 | struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; |
6689 | u64 throttled_usec; | 6688 | u64 throttled_usec; |
6690 | 6689 | ||
@@ -6817,11 +6816,6 @@ static ssize_t cpu_max_write(struct kernfs_open_file *of, | |||
6817 | #endif | 6816 | #endif |
6818 | 6817 | ||
6819 | static struct cftype cpu_files[] = { | 6818 | static struct cftype cpu_files[] = { |
6820 | { | ||
6821 | .name = "stat", | ||
6822 | .flags = CFTYPE_NOT_ON_ROOT, | ||
6823 | .seq_show = cpu_stat_show, | ||
6824 | }, | ||
6825 | #ifdef CONFIG_FAIR_GROUP_SCHED | 6819 | #ifdef CONFIG_FAIR_GROUP_SCHED |
6826 | { | 6820 | { |
6827 | .name = "weight", | 6821 | .name = "weight", |
@@ -6852,6 +6846,7 @@ struct cgroup_subsys cpu_cgrp_subsys = { | |||
6852 | .css_online = cpu_cgroup_css_online, | 6846 | .css_online = cpu_cgroup_css_online, |
6853 | .css_released = cpu_cgroup_css_released, | 6847 | .css_released = cpu_cgroup_css_released, |
6854 | .css_free = cpu_cgroup_css_free, | 6848 | .css_free = cpu_cgroup_css_free, |
6849 | .css_extra_stat_show = cpu_extra_stat_show, | ||
6855 | .fork = cpu_cgroup_fork, | 6850 | .fork = cpu_cgroup_fork, |
6856 | .can_attach = cpu_cgroup_can_attach, | 6851 | .can_attach = cpu_cgroup_can_attach, |
6857 | .attach = cpu_cgroup_attach, | 6852 | .attach = cpu_cgroup_attach, |