diff options
author | Tejun Heo <tj@kernel.org> | 2017-09-25 08:12:04 -0700 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2017-09-25 08:12:04 -0700 |
commit | d2cc5ed6949085cfba30ec5228816cf6eb1d02b9 (patch) | |
tree | 52cd7323c6a2068f4ec1b4a08ad8a3ad674f5c81 /include/linux/cgroup.h | |
parent | cfb766da54d98ceb145e1bb0bd11c559569dcbfc (diff) | |
download | talos-obmc-linux-d2cc5ed6949085cfba30ec5228816cf6eb1d02b9.tar.gz talos-obmc-linux-d2cc5ed6949085cfba30ec5228816cf6eb1d02b9.zip |
cpuacct: Introduce cgroup_account_cputime[_field]()
Introduce cgroup_account_cputime[_field]() which wrap cpuacct_charge()
and cgroup_account_field(). This doesn't introduce any functional
changes and will be used to add cgroup basic resource accounting.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index d023ac5e377f..6cd579329310 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -22,6 +22,7 @@ #include <linux/nsproxy.h> #include <linux/user_namespace.h> #include <linux/refcount.h> +#include <linux/kernel_stat.h> #include <linux/cgroup-defs.h> @@ -689,6 +690,43 @@ static inline void cgroup_path_from_kernfs_id(const union kernfs_node_id *id, #endif /* !CONFIG_CGROUPS */ /* + * Basic resource stats. + */ +#ifdef CONFIG_CGROUPS + +#ifdef CONFIG_CGROUP_CPUACCT +void cpuacct_charge(struct task_struct *tsk, u64 cputime); +void cpuacct_account_field(struct task_struct *tsk, int index, u64 val); +#else +static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {} +static inline void cpuacct_account_field(struct task_struct *tsk, int index, + u64 val) {} +#endif + +static inline void cgroup_account_cputime(struct task_struct *task, + u64 delta_exec) +{ + cpuacct_charge(task, delta_exec); +} + +static inline void cgroup_account_cputime_field(struct task_struct *task, + enum cpu_usage_stat index, + u64 delta_exec) +{ + cpuacct_account_field(task, index, delta_exec); +} + +#else /* CONFIG_CGROUPS */ + +static inline void cgroup_account_cputime(struct task_struct *task, + u64 delta_exec) {} +static inline void cgroup_account_cputime_field(struct task_struct *task, + enum cpu_usage_stat index, + u64 delta_exec) {} + +#endif /* CONFIG_CGROUPS */ + +/* * sock->sk_cgrp_data handling. For more info, see sock_cgroup_data * definition in cgroup-defs.h. */ |