Add a helper that charges some kernel CPU time to a cgroup's cpu.stat. The next patch uses it for the time a kernel thread spends working for another cgroup.
Signed-off-by: Shakeel Butt <[email protected]> --- include/linux/cgroup.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 2afb4cb2bb4f..7b19ded2578d 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -868,6 +868,17 @@ void __cgroup_account_cputime(struct cgroup *cgrp, u64 delta_exec); void __cgroup_account_cputime_field(struct cgroup *cgrp, enum cpu_usage_stat index, u64 delta_exec); +/* Charge @delta_exec of kernel CPU time to @cgrp. */ +static inline void cgroup_account_system_time(struct cgroup *cgrp, + u64 delta_exec) +{ + if (cgroup_parent(cgrp)) { + __cgroup_account_cputime(cgrp, delta_exec); + __cgroup_account_cputime_field(cgrp, CPUTIME_SYSTEM, + delta_exec); + } +} + static inline void cgroup_account_cputime(struct task_struct *task, u64 delta_exec) { @@ -900,6 +911,8 @@ static inline void cgroup_account_cputime(struct task_struct *task, static inline void cgroup_account_cputime_field(struct task_struct *task, enum cpu_usage_stat index, u64 delta_exec) {} +static inline void cgroup_account_system_time(struct cgroup *cgrp, + u64 delta_exec) {} #endif /* CONFIG_CGROUPS */ -- 2.53.0-Meta

