Commit | Line | Data |
---|---|---|
60fed789 LZ |
1 | /* Time spent by the tasks of the cpu accounting group executing in ... */ |
2 | enum cpuacct_stat_index { | |
3 | CPUACCT_STAT_USER, /* ... user mode */ | |
4 | CPUACCT_STAT_SYSTEM, /* ... kernel mode */ | |
5 | ||
6 | CPUACCT_STAT_NSTATS, | |
7 | }; | |
8 | ||
9 | #ifdef CONFIG_CGROUP_CPUACCT | |
10 | ||
11 | #include <linux/cgroup.h> | |
12 | /* track cpu usage of a group of tasks and its child groups */ | |
13 | struct cpuacct { | |
14 | struct cgroup_subsys_state css; | |
15 | /* cpuusage holds pointer to a u64-type object on every cpu */ | |
16 | u64 __percpu *cpuusage; | |
17 | struct kernel_cpustat __percpu *cpustat; | |
18 | }; | |
19 | ||
20 | extern struct cgroup_subsys cpuacct_subsys; | |
21 | extern struct cpuacct root_cpuacct; | |
22 | ||
23 | /* return cpu accounting group corresponding to this container */ | |
24 | static inline struct cpuacct *cgroup_ca(struct cgroup *cgrp) | |
25 | { | |
26 | return container_of(cgroup_subsys_state(cgrp, cpuacct_subsys_id), | |
27 | struct cpuacct, css); | |
28 | } | |
29 | ||
30 | /* return cpu accounting group to which this task belongs */ | |
31 | static inline struct cpuacct *task_ca(struct task_struct *tsk) | |
32 | { | |
33 | return container_of(task_subsys_state(tsk, cpuacct_subsys_id), | |
34 | struct cpuacct, css); | |
35 | } | |
36 | ||
37 | static inline struct cpuacct *parent_ca(struct cpuacct *ca) | |
38 | { | |
39 | if (!ca || !ca->css.cgroup->parent) | |
40 | return NULL; | |
41 | return cgroup_ca(ca->css.cgroup->parent); | |
42 | } | |
43 | ||
dbe4b41f | 44 | extern void cpuacct_init(void); |
60fed789 LZ |
45 | extern void cpuacct_charge(struct task_struct *tsk, u64 cputime); |
46 | ||
47 | #else | |
48 | ||
dbe4b41f LZ |
49 | static inline void cpuacct_init(void) |
50 | { | |
51 | } | |
52 | ||
60fed789 LZ |
53 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) |
54 | { | |
55 | } | |
56 | ||
57 | #endif |