Re: [vserver] sysinfo leaks of host uptime

From: Ghislain Adnet <gadnet_at_aqueos.com>
Date: Wed 12 Dec 2018 - 10:56:53 GMT
Message-ID: <fdc47bc6-cc59-c3c4-f38f-3134d961357d@aqueos.com>

since i fail to update the core ktime_get_boottime();

i have made a temporary patch to fix only the sysinfo call, please look and give your advice on it !

seems to work on my tests for sysinfo and uptime

---------------- host ----------------
Uptime: 0days, 0hours, 5minutes, 14seconds
Load Avgs: 1min(38208) 5min(21888) 15min(7712)
Total Ram: 16149004k Free: 14062280k
Shared Ram: 33780k
Buffered Ram: 28320k
Total Swap: 3904508k Free: 3904508k
Number of processes: 272
---------------- guest ------------------
Uptime: 0days, 0hours, 1minutes, 19seconds
Load Avgs: 1min(5408) 5min(2496) 15min(672)
Total Ram: 6723536k Free: 4800120k
Shared Ram: 33780k
Buffered Ram: 0k
Total Swap: 1953124k Free: 1953124k
Number of processes: 99

---------------- host ----------------
  11:55:31 up 5 min, 1 user, load average: 0.35, 0.30, 0.11
---------------- guest ------------------
  11:55:31 up 1 min, 0 users, load average: 0.05, 0.03, 0.01

Ghislain.

--- linux-4.9.140/kernel/sys.c 2018-11-26 07:43:11.835810746 +0100
+++ linux-4.9.144/kernel/sys.c 2018-12-12 10:54:59.905687398 +0100
@@ -64,6 +64,8 @@
  #include <asm/io.h>
  #include <asm/unistd.h>

+#include <linux/vserver/cvirt.h>
+
  #ifndef SET_UNALIGN_CTL
  # define SET_UNALIGN_CTL(a, b) (-EINVAL)
  #endif
@@ -2331,16 +2333,28 @@ static int do_sysinfo(struct sysinfo *in
         unsigned long mem_total, sav_total;
         unsigned int mem_unit, bitcount;
         struct timespec tp;
+ struct timespec idle;

         memset(info, 0, sizeof(struct sysinfo));

         get_monotonic_boottime(&tp);
+
+ // if in vserver guest virtualize the result
+ if (!vx_check(0, VS_ADMIN|VS_WATCH)) {
+ struct vx_info *vxi = current_vx_info();
+ info->procs = atomic_read(&vxi->cvirt.nr_threads);
+
+ if vx_flags(VXF_VIRT_UPTIME, 0) {
+ vx_vsi_uptime(&tp, &idle);
+ }
+ } else {
+ info->procs = nr_threads;
+ }
+
         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);
Received on Wed Dec 12 10:46:09 2018

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Wed 12 Dec 2018 - 10:46:09 GMT by hypermail 2.1.8