[Devel] [PATCH vz9 06/23] ve: Virtualize sysinfo
Nikita Yushchenko
nikita.yushchenko at virtuozzo.com
Fri Oct 1 18:53:14 MSK 2021
From: Kirill Tkhai <ktkhai at virtuozzo.com>
Extracted from "Initial patch".
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
(cherry picked from vz7 commit e55cd51304b3271a2adaf43de9b9a5a7be34541e)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Port to vz8 notes:
* virtinfo_notifier_call (bc_fill_sysinfo()) is substituted by
direct call to si_meminfo_ve() and only for not VE0.
* "avenrun" is not virtualized yet - need to port first commit
715f311fdb4a ("sched: Account task_group::cpustat,taskstats,avenrun")
* ve_struct.real_start_time is u64 now instead of timespec
Cherry-picked from vz8 commit a93d11cae4cc ("ve: Virtualize sysinfo").
Followed ve->real_start_time -> ve->start_boottime rename.
Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
kernel/sys.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/kernel/sys.c b/kernel/sys.c
index da8e44e1525d..1943af548f59 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2588,6 +2588,8 @@ SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,
return err ? -EFAULT : 0;
}
+extern void si_meminfo_ve(struct sysinfo *si, struct ve_struct *ve);
+
/**
* do_sysinfo - fill in sysinfo struct
* @info: pointer to buffer to fill
@@ -2597,19 +2599,29 @@ static int do_sysinfo(struct sysinfo *info)
unsigned long mem_total, sav_total;
unsigned int mem_unit, bitcount;
struct timespec64 tp;
+ struct ve_struct *ve;
memset(info, 0, sizeof(struct sysinfo));
+ si_meminfo(info);
+ si_swapinfo(info);
+
ktime_get_boottime_ts64(&tp);
timens_add_boottime(&tp);
- info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
- get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
+ ve = get_exec_env();
+ if (ve_is_super(ve)) {
+ info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
+ get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
- info->procs = nr_threads;
+ info->procs = nr_threads;
+ } else {
+ si_meminfo_ve(info, ve);
+ info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0) -
+ ve->start_boottime / NSEC_PER_SEC;
- si_meminfo(info);
- si_swapinfo(info);
+ info->procs = nr_threads_ve(ve);
+ }
/*
* If the sum of all the available memory (i.e. ram + swap)
--
2.30.2
More information about the Devel
mailing list