[Devel] [PATCH rh8 6/8] ve/proc/stat: Wire virtualized /proc/stat handler
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Oct 28 18:57:35 MSK 2020
Signed-off-by: Konstantin Khorenko <khorenko at 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 dfcd5280a7c6..937790fd02cf 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -13,6 +13,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
@@ -113,6 +114,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 20a28b043810..205dfa82ec07 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -185,8 +185,10 @@ static inline void monotonic_ve_to_abs(clockid_t which_clock,
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 193fdb95daab..b01f95d29748 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1149,6 +1149,23 @@ int vz_security_protocol_check(struct net *net, int protocol)
EXPORT_SYMBOL_GPL(vz_security_protocol_check);
#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.28.0
More information about the Devel
mailing list