
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ica1gk -------------------------------- Add a helper to get the cpuacct cgroup of a task. Signed-off-by: GONG Ruiqi <gongruiqi1@huawei.com> --- include/linux/cgroup.h | 9 +++++++++ kernel/sched/cpuacct.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 48f0e9dcd3a1..453beda8bc9a 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -704,10 +704,19 @@ void cgroup_rstat_flush_release(void); #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); +#ifdef CONFIG_BPF_RVI +struct cpuacct *task_cpuacct(struct task_struct *tsk); +#endif #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) {} +#ifdef CONFIG_BPF_RVI +static inline struct cpuacct *task_cpuacct(struct task_struct *tsk) +{ + return NULL; +} +#endif #endif void __cgroup_account_cputime(struct cgroup *cgrp, u64 delta_exec); diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index edb37dfda54d..3d3d12b60572 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -409,6 +409,11 @@ late_initcall_sync(cgroup_v1_ifs_init); #endif #ifdef CONFIG_BPF_RVI +struct cpuacct *task_cpuacct(struct task_struct *tsk) +{ + return tsk ? task_ca(tsk) : NULL; +} + __bpf_kfunc void bpf_cpuacct_kcpustat_cpu_fetch(struct kernel_cpustat *dst, struct cpuacct *ca, int cpu) { -- 2.25.1