[Devel] [PATCH RH9 5/5] ve: Virtualize sysinfo

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Oct 4 18:00:03 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>

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>
---
 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)
-- 
2.31.1



More information about the Devel mailing list