From: Konstantin Khorenko <khore...@virtuozzo.com> Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com> Reviewed-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
(cherry-picked from vz8 commit abac75aaeba1 ("ve/proc/stat: Wire virtualized /proc/stat handler")) Signed-off-by: Nikita Yushchenko <nikita.yushche...@virtuozzo.com> --- fs/proc/stat.c | 10 ++++++++++ include/linux/ve.h | 2 ++ kernel/ve/ve.c | 17 +++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 3f102d658b33..d40f26728c9b 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -14,6 +14,7 @@ #include <linux/irqnr.h> #include <linux/sched/cputime.h> #include <linux/tick.h> +#include <linux/ve.h> #ifndef arch_irq_stat_cpu #define arch_irq_stat_cpu(cpu) 0 @@ -114,6 +115,15 @@ static int show_stat(struct seq_file *p, void *v) u64 sum_softirq = 0; unsigned int per_softirq_sums[NR_SOFTIRQS] = {0}; struct timespec64 boottime; + struct ve_struct *ve; + + ve = get_exec_env(); + if (!ve_is_super(ve)) { + int ret; + ret = ve_show_cpu_stat(ve, p); + if (ret != -ENOSYS) + return ret; + } user = nice = system = idle = iowait = irq = softirq = steal = 0; diff --git a/include/linux/ve.h b/include/linux/ve.h index 4dde4cb46d52..47f690c1b8b9 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -199,8 +199,10 @@ static inline int vz_security_protocol_check(struct net *net, int protocol) { re struct seq_file; #if defined(CONFIG_VE) && defined(CONFIG_CGROUP_SCHED) +int ve_show_cpu_stat(struct ve_struct *ve, struct seq_file *p); int ve_show_loadavg(struct ve_struct *ve, struct seq_file *p); #else +static inline int ve_show_cpu_stat(struct ve_struct *ve, struct seq_file *p) { return -ENOSYS; } static inline int ve_show_loadavg(struct ve_struct *ve, struct seq_file *p) { return -ENOSYS; } #endif diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c index bd114bd620eb..2e418e72ce62 100644 --- a/kernel/ve/ve.c +++ b/kernel/ve/ve.c @@ -1455,6 +1455,23 @@ bool ve_check_trusted_exec(struct file *file, struct filename *name) } #ifdef CONFIG_CGROUP_SCHED +int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css, + struct cgroup_subsys_state *cpuacct_css, + struct seq_file *p); + +int ve_show_cpu_stat(struct ve_struct *ve, struct seq_file *p) +{ + struct cgroup_subsys_state *cpu_css, *cpuacct_css; + int err; + + cpu_css = ve_get_init_css(ve, cpu_cgrp_id); + cpuacct_css = ve_get_init_css(ve, cpuacct_cgrp_id); + err = cpu_cgroup_proc_stat(cpu_css, cpuacct_css, p); + css_put(cpuacct_css); + css_put(cpu_css); + return err; +} + int cpu_cgroup_proc_loadavg(struct cgroup_subsys_state *css, struct seq_file *p); -- 2.30.2 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel