Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

cpu time reporting for SVM is not proper (kvm/SVM) #1

Open
rampai opened this issue Nov 21, 2020 · 0 comments
Open

cpu time reporting for SVM is not proper (kvm/SVM) #1

rampai opened this issue Nov 21, 2020 · 0 comments

Comments

@rampai
Copy link
Collaborator

rampai commented Nov 21, 2020


#!/bin/bash
sleep_sec=300
normalvm="normal"
securevm="vm"
function stats(){
echo ""
echo $2
echo "total time from virsh cpu-stats: "
virsh cpu-stats $1|grep -A3 Total:|grep -v Total:
echo "cpu time from virsh vcpuinfo: "
virsh vcpuinfo $1|grep "CPU time:"
}

if [ "virsh domstate $normalvm" == "shut off" ]; then
virsh start $normalvm
else
echo "make sure vms are in shutoff state"
exit 1
fi
if [ "virsh domstate $securevm" == "shut off" ]; then
virsh start $securevm
else
echo "make sure vms are in shutoff state"
exit 1
fi
sleep 10
echo "----initial stats----"
stats $normalvm "normal vm"
stats $securevm "secure vm"
echo ""
echo "Sleeping $sleep_sec seconds..."
sleep $sleep_sec
echo "----stats after $sleep_sec seconds----"
stats $normalvm "normal vm"
stats $securevm "secure vm"
normalvmpid=ps -ef|grep guest=$normalvm|grep -v grep|tr -s " "|cut -d" " -f2
securevmpid=ps -ef|grep guest=$securevm|grep -v grep|tr -s " "|cut -d" " -f2
echo ""
echo "PID of normal vm: $normalvmpid"
echo "PID of secure vm: $securevmpid"
echo "top stats"
top -p $normalvmpid -p $securevmpid -d 5 -n 2 -b
echo ""
echo "pid stats"
echo -n "$normalvmpid: "
cat /proc/$normalvmpid/stat
echo ""
echo -n "$securevmpid: "
cat /proc/$securevmpid/stat
echo ""
echo -n "$normalvmpid: "
cat /proc/$normalvmpid/status
echo ""
echo -n "$securevmpid: "
cat /proc/$securevmpid/status
echo ""

Make sure svm guest with name "vm" and normal guest with name "normal" is defined in the PEF host and run the attached script(cputime.sh)

Note: both normal and secure guest running no workload(idle).

./cputime.sh

Domain normal started

Domain vm started

----initial stats----

normal vm
total time from virsh cpu-stats:
cpu_time 10.906516180 seconds
user_time 0.130000000 seconds
system_time 0.260000000 seconds
cpu time from virsh vcpuinfo:
CPU time: 10.5s

secure vm
total time from virsh cpu-stats:
cpu_time 10.361590632 seconds
user_time 0.130000000 seconds
system_time 0.170000000 seconds
cpu time from virsh vcpuinfo:
CPU time: 10.1s

Sleeping 300 seconds...
----stats after 300 seconds----

normal vm
total time from virsh cpu-stats:
cpu_time 83.495148868 seconds
user_time 0.280000000 seconds
system_time 0.970000000 seconds
cpu time from virsh vcpuinfo:
CPU time: 33.3s
CPU time: 14.8s
CPU time: 17.5s
CPU time: 16.7s

secure vm
total time from virsh cpu-stats:
cpu_time 1178.105399264 seconds -------NOK
user_time 0.360000000 seconds
system_time 1.300000000 seconds
cpu time from virsh vcpuinfo:
CPU time: 308.9s --------------------NOK
CPU time: 289.3s --------------------NOK
CPU time: 289.5s --------------------NOK
CPU time: 289.5s --------------------NOK

PID of normal vm: 359698
PID of secure vm: 359754
top stats
top - 07:58:00 up 5 days, 5:53, 5 users, load average: 257.02, 256.84, 256.53
Tasks: 2 total, 0 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.5 us, 0.0 sy, 0.0 ni, 97.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 519438.0 total, 472028.8 free, 12083.4 used, 35325.8 buff/cache
MiB Swap: 4095.9 total, 4095.9 free, 0.0 used. 503875.7 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND

359754 qemu 20 0 9853.5m 8.1g 21376 S 400.0 1.6 19:39.30 qemu-kvm
359698 qemu 20 0 10.7g 1.1g 21504 S 0.0 0.2 1:23.48 qemu-kvm

top - 07:58:05 up 5 days, 5:53, 5 users, load average: 257.02, 256.85, 256.53
Tasks: 2 total, 0 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.5 us, 0.0 sy, 0.0 ni, 97.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 519438.0 total, 472024.7 free, 12087.1 used, 35326.2 buff/cache
MiB Swap: 4095.9 total, 4095.9 free, 0.0 used. 503872.1 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND

359754 qemu 20 0 9853.5m 8.1g 21376 S 400.0 1.6 19:59.34 qemu-kvm
359698 qemu 20 0 10.7g 1.1g 21504 S 0.0 0.2 1:23.48 qemu-kvm

pid stats
359698: 359698 (qemu-kvm) S 1 359697 359697 0 -1 138412416 3553 0 0 0 8251 97 0 0 20 0 7 0 45291836 11475615744 17856 18446744073709551615 4661903360 4672923916 140736605059008 0 0 0 268444224 4096 16963 0 0 0 17 147 0 0 0 8184 0 4673012544 4674161426 4787011584 140736605123946 140736605126312 140736605126312 140736605126626 0

359754: 359754 (qemu-kvm) S 1 359753 359753 0 -1 138412416 5039 0 0 0 119804 130 0 0 20 0 7 0 45291900 10332143616 131997 18446744073709551615 5224792064 5235812620 140736770981040 0 0 0 268444224 4096 16963 0 0 0 17 112 0 0 0 119701 0 5235901248 5237050130 5773393920 140736770995583 140736770997944 140736770997944 140736770998242 0

359698: Name: qemu-kvm
Umask: 0002
State: S (sleeping)
Tgid: 359698
Ngid: 359698
Pid: 359698
PPid: 1
TracerPid: 0
Uid: 107 107 107 107
Gid: 107 107 107 107
FDSize: 128
Groups: 36 107
NStgid: 359698
NSpid: 359698
NSpgid: 359697
NSsid: 359697
VmPeak: 11313984 kB
VmSize: 11206656 kB
VmLck: 2240 kB
VmPin: 0 kB
VmHWM: 1143104 kB
VmRSS: 1142784 kB
RssAnon: 1121280 kB
RssFile: 21504 kB
RssShmem: 0 kB
VmData: 8598656 kB
VmStk: 192 kB
VmExe: 10816 kB
VmLib: 30336 kB
VmPTE: 218 kB
VmSwap: 0 kB
HugetlbPages: 0 kB
CoreDumping: 0
THP_enabled: 1
Threads: 7
SigQ: 0/1972697
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000010002240
SigIgn: 0000000000001000
SigCgt: 0000000180004243
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000003fffffffff
CapAmb: 0000000000000000
NoNewPrivs: 1
Seccomp: 2
Speculation_Store_Bypass: unknown
Cpus_allowed: ffffffff,ffffffff,ffffffff,ffffffff,ffffffff
Cpus_allowed_list: 0-159
Mems_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000101
Mems_allowed_list: 0,8
voluntary_ctxt_switches: 22574
nonvoluntary_ctxt_switches: 4

359754: Name: qemu-kvm
Umask: 0002
State: S (sleeping)
Tgid: 359754
Ngid: 359754
Pid: 359754
PPid: 1
TracerPid: 0
Uid: 107 107 107 107
Gid: 107 107 107 107
FDSize: 128
Groups: 36 107
NStgid: 359754
NSpid: 359754
NSpgid: 359753
NSsid: 359753
VmPeak: 10189056 kB
VmSize: 10089984 kB
VmLck: 2240 kB
VmPin: 0 kB
VmHWM: 8448192 kB
VmRSS: 8447808 kB
RssAnon: 8426432 kB
RssFile: 21376 kB
RssShmem: 0 kB
VmData: 8595072 kB
VmStk: 192 kB
VmExe: 10816 kB
VmLib: 30336 kB
VmPTE: 1119 kB
VmSwap: 0 kB
HugetlbPages: 0 kB
CoreDumping: 0
THP_enabled: 1
Threads: 7
SigQ: 0/1972697
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000010002240
SigIgn: 0000000000001000
SigCgt: 0000000180004243
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000003fffffffff
CapAmb: 0000000000000000
NoNewPrivs: 1
Seccomp: 2
Speculation_Store_Bypass: unknown
Cpus_allowed: ffffffff,ffffffff,ffffffff,ffffffff,ffffffff
Cpus_allowed_list: 0-159
Mems_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000101
Mems_allowed_list: 0,8
voluntary_ctxt_switches: 24190
nonvoluntary_ctxt_switches: 4

Domain normal destroyed

Domain vm destroyed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant