[Devel] [PATCH RHEL COMMIT] ve: Virtualize sysinfo
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Oct 4 21:53:19 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 83135b2ee15d9f4913b0850b36c8a787d2c24955
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Mon Oct 4 21:53:19 2021 +0300
ve: Virtualize sysinfo
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>
VZ9 changes:
- sysinfo is time namespace aware so skip our ve-time virtualization
- reorder branches to follow same order (1 si_meminfo, 2 avenrun, 3
procs, 4 uptime).
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
====================
Patchset description:
ve/time: switch from our ve-time to native timenamespace
https://jira.sw.ru/browse/PSBM-134393
As time-namespaces are a new and mainstreamed version of ve-time, it's
time to switch to it.
Notes:
1) ve-time does not need configuration on start, though time namespace
needs configuration (offset == -now).
2) ve-time saved container start time but time namespaces save offset
between host start time and container start time
(offset == ve_start_time - now).
3) criu already knows how to handle time namespaces, though we need to
do a compatibility layer to convert our ve.clock_* to offsets in time
namespace for pre-vz9 to vz9 migration.
4) vdso time is already handled by time namespaces, though time
namespace only virtualizes vvar page, so it should not intersect with
our vdso virtualization for ve.os_release.
https://jira.sw.ru/browse/PSBM-134393
Cyrill Gorcunov (1):
ve: Add interface for ve::clock_[monotonic|bootbased] adjustment
Kirill Tkhai (2):
ve/time: Use ve_relative_clock in times() syscall and /proc/[pid]/stat
ve: Virtualize sysinfo
Pavel Tikhomirov (1):
ve/time: remove our per-ve times in favor of mainstream
time-namespaces
Valeriy Vdovin (1):
ve/proc: Added separate start time field to task_struct to show in
container
---
kernel/sys.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/kernel/sys.c b/kernel/sys.c
index 3d4b35e0e636..b0caeed760bd 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2629,6 +2629,7 @@ 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);
extern int get_avenrun_tg(struct task_group *tg, unsigned long *loads,
unsigned long offset, int shift);
@@ -2641,25 +2642,28 @@ 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));
- 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);
-
- info->procs = nr_threads;
-
si_meminfo(info);
si_swapinfo(info);
- if (!ve_is_super(get_exec_env())) {
+ ktime_get_boottime_ts64(&tp);
+ timens_add_boottime(&tp);
+
+ ve = get_exec_env();
+ if (ve_is_super(ve)) {
+ get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
+ info->procs = nr_threads;
+ } else {
+ si_meminfo_ve(info, ve);
/* does not fail on non-VE0 task group */
(void)get_avenrun_tg(NULL, info->loads,
0, SI_LOAD_SHIFT - FSHIFT);
+ info->procs = nr_threads_ve(ve);
}
+ info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
/*
* If the sum of all the available memory (i.e. ram + swap)
More information about the Devel
mailing list