The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.12
------>
commit 688c65f8eaf161a15fc2a644b511d7c245d45890
Author: Kirill Tkhai <ktk...@virtuozzo.com>
Date:   Tue Nov 28 15:15:16 2017 +0300

    ve: Virtualize sysinfo
    
    Extracted from "Initial patch".
    
    Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com>
    
    (cherry picked from vz7 commit e55cd51304b3271a2adaf43de9b9a5a7be34541e)
    Signed-off-by: Konstantin Khorenko <khore...@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
---
 kernel/sys.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index cfde07d0ba9f..2644090f8d4b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2545,6 +2545,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
@@ -2554,18 +2556,34 @@ static int do_sysinfo(struct sysinfo *info)
        unsigned long mem_total, sav_total;
        unsigned int mem_unit, bitcount;
        struct timespec tp;
+       struct ve_struct *ve;
 
        memset(info, 0, sizeof(struct sysinfo));
 
+       si_meminfo(info);
+       si_swapinfo(info);
+
        get_monotonic_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;
+       } else {
+               si_meminfo_ve(info, ve);
+               info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0) -
+                              ve->real_start_time / NSEC_PER_SEC;
 
-       info->procs = nr_threads;
+               info->procs = nr_threads_ve(ve);
 
-       si_meminfo(info);
-       si_swapinfo(info);
+#if 0
+FIXME after
+715f311fdb4a ("sched: Account task_group::cpustat,taskstats,avenrun") is ported
+               get_avenrun_ve(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
+#endif
+       }
 
        /*
         * If the sum of all the available memory (i.e. ram + swap)
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to