QEMU-KVM performance optimization - linux

I am trying to test the performance difference between QEMU-KVM and host machine and could not understand how optimize my QEMU-KVM to achieve near native performance.
I installed QEMU-KVM with lubuntu 14.04 and running a stress microbenchmark that does not produce any cache misses.
I am recording the performance counter, instructions retired, using perf monitoring tool.
Since QEMU does not provide with this performance counter. I am recording the performance of the entire QEMU process using perf from the host system.
The results obtained do not reflect that. I am not sure entirely how I should setup the QEMU-KVM subsystem.
I describe details of QEMU and the host machine (bare metal) below.
QEMU emulator version 2.0.0 in conjunction with KVM as the virtual environment and libvirt 1.2.2
The guest machine is running kernel version 3.19.0-15-generic and the host machine is running version 3.14.5-031405-generic on a x86_64 machine
guest machine with Intel SandyBridge processor (model name:Intel Xeon E312xx) with the following flags: sockets=1,cores=1,threads=1 and 4mb cache.
More details:
cpu family : 6
model : 42
max freq : 2394.560 MHz
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx hypervisor lahf_lm vnmi ept xsaveopt
The host machine is an Intel Sandy Bridge processor (Intel(R) Core(TM) i7-2760QM CPU # 2.40GHz) with 4 cores and 6mb cache.
cpu family : 6
model : 42
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
Let me know if I can provide any more details.
Thanks!

Try using event modifiers, as explained in "perf help list":
EVENT MODIFIERS
Events can optionally have a modifer by appending a colon and one or more
modifiers. Modifiers allow the user to restrict the events to be counted. The
following modifiers exist:
u - user-space counting
k - kernel counting
h - hypervisor counting
G - guest counting (in KVM guests)
H - host counting (not in KVM guests)
p - precise level
S - read sample value (PERF_SAMPLE_READ)
D - pin the event to the PMU
The documentation above is not satisfactory IMHO, and I don't fully understand the meaning of each event modifier. Sometimes I get inconsistent results, e.g. more retired instructions in user-space counting ("u" modifier) than in full counting (no modifiers at all).
I'm using the following perf version:
>> perf --version
perf version 3.13.11-ckt20

Related

How to enable Intel TSX in i7-7700 cpu?

I have this Intel i7-7700 CPU. lscpu shows it has Intel TSX feature.
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi
mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs
bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx
est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer
aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb invpcid_single intel_pt ssbd ibrs ibpb stibp
kaiser tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms
invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp
hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
However, I'm unable to use it. I was trying to run the test program from this repository https://github.com/blue9057/intel-tsx-sample. I check IA32_ARCH_CAPABILITIES with sudo rdmsr 0x10AH, and it returns 0xc04 which indicates bit 7 (TSX_CTRL) is 0. So there is no TSX support. I'm not an expert, I tried to change the MSR with sudo wrmsr 0x10ah 0xC84 and I get the following error,
wrmsr: CPU 0 cannot set MSR 0x0000010a to 0x0000000000000c84
I also try to read IA32_TSX_CTRL with sudo rdmsr 0x122H and get the following error,
rdmsr: CPU 0 cannot read MSR 0x00000122
I disable secure boot from BIOS
lscpu shows the microcode: 0xf0. I believe Intel disable this TSX feature with microde update. I'm not sure if this update is automatic or not. But as far I can remember I did not update any.
Not if this is relevent or not /usr/src/linux-headers-4.4.0-210/arch/x86/include/asm/msr-index.h files shows
#define MSR_IA32_TSX_CTRL 0x00000122
#define TSX_CTRL_RTM_DISABLE BIT(0) /* Disable RTM feature */
#define TSX_CTRL_CPUID_CLEAR BIT(1) /* Disable TSX enumeration */
I also comment out #define TSX_CTRL_RTM_DISABLE and #define TSX_CTRL_CPUID_CLEAR but no luck.
I was wondering if there is any way I can enable this feature. I'm not sure If I provide enough information on this. Please let me know what other information will be helpful. I will add them. Or if you can point me in some directions that will be helpful.
OS version: Linux xxxx 4.4.0-210-generic x86_64
UPDATE
complete lscpu
xxx#xxx:~$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Model name: Intel(R) Core(TM) i7-7700 CPU # 3.60GHz
Stepping: 9
CPU MHz: 900.000
CPU max MHz: 4200.0000
CPU min MHz: 800.0000
BogoMIPS: 7199.80
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic
sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse
sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art
arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc
aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2
ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe
popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm
3dnowprefetch epb invpcid_single intel_pt ssbd ibrs ibpb stibp
kaiser tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust
bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap
clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp
hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
arch_capabilities
Kernel log shows,
$dmesg | grep "tsx=on"
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-210-generic root=UUID=b528525a-2daa-4537-964e-106314e6a7bd ro quiet splash nokaslr tsx_async_abort=off tsx=on vt.handoff=7
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-210-generic root=UUID=b528525a-2daa-4537-964e-106314e6a7bd ro quiet splash nokaslr tsx_async_abort=off tsx=on vt.handoff=7
$dmesg | grep "TAA"
[ 0.063012] TAA: Mitigation: Clear CPU buffers
[ 0.209727] TAA CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html for more details.
Instead of using the example from the mentioned git repo, I was trying to run the following program,
#include <stdio.h>
#include <stdlib.h>
#include <immintrin.h>
int main(int argc, char *argv[]){
volatile int result=-1;
unsigned status;
while(result != 1){
if ((status = _xbegin()) == _XBEGIN_STARTED) {
result=1;
_xend();
}else{
printf("rtmCheck: Transaction failed\n");
printf("Trying again ...\n");
sleep(5);
}
}
printf("rtmCheck : Result is %d\n", result);
return 0;
}
Makefile
CC=gcc
CFLAGS= -mrtm
rtmCheck: rtmCheck.o
$(CC) $(CFLAGS) -o rtmCheck rtmCheck.o
clean:
rm -f *.o rtmCheck
output:
rtmCheck: Transaction failed
Trying again ...
rtmCheck: Transaction failed
Trying again ...

Tensorflow 2.4 doesn't work despite my cpu having AVX support

I am running Ubuntu 20.04.1 LTS/tf version 2.4.0, and I am not able to run the tensorflow library, because it always results in an error
This is the only line that I put in
import tensorflow as tf
This is the error it gives out
Illegal instruction (core dumped)
These are the processor specs
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3437U CPU # 1.90GHz
stepping : 9
microcode : 0x21
cpu MHz : 842.451
cache size : 3072 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds
bogomips : 4789.04
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
If more information will be needed I will provide it.
I have the same problem running the tf version 2.4.0 in Ubuntu 18.04.4 LTS. I have been looking for a solution but I didn't find it yet so, for now, I am using the previous version which works for me.
pip uninstall tensorflow
pip install tensorflow==2.3.1
It should be fixed now in 2.4.1

How to find the L3 Cache parameters on Intel CPUs?

I would like to know the following L3 cache parameters. But not sure how to get them, I also pasted the /proc/cpuinfo output (4 processors, only pasted the first one, the others are repetitive.)
CACHE_SIZE
LINE_SIZE
Associativity
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i7-3520M CPU # 2.90GHz
stepping : 9
microcode : 0x15
cpu MHz : 1200.000
cache size : 4096 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips : 5786.68
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
UPDATE 1: It seems that someone posted the cache size and associativity here:
http://www.cpu-world.com/CPUs/Core_i7/Intel-Core%20i7-3520M%20%28PGA%29%20Mobile%20processor.html
But still I dont know the line size.
Hwloc / lstopo
Hwloc (Portable hardware locality) is a small utility that reports the structure of the processor in a neat visual diagram. The diagram shows the number of cores, hyperthreads and cache size. A single diagram tells it all.
$ sudo apt-get install hwloc
$ hwloc

Can't install eucalyptus

I have a VM with storage size as 20 GB. I begin setup eucalyptus by Eucalyptus FastStart, i use to command:
bash <(curl -Ls eucalyptus.com/install)
But It appear mistake,and this is log file of eucalyptus:
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
CentOS release 6.6 (Final)
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni vmx ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm ida arat epb dts tpr_shadow vnmi ept vpid
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni vmx ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm ida arat epb dts tpr_shadow vnmi ept vpid
Loaded plugins: fastestmirror, security, versionlock
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.vinahost.vn
* elrepo: mirrors.thzhost.com
* epel: mirrors.vinahost.vn
* extras: mirrors.vinahost.vn
* updates: mirrors.vinahost.vn
Package git-1.7.1-3.el6_4.1.x86_64 already installed and latest version
Nothing to do
.....
[2014-12-05T14:02:10+07:00] INFO: yum_package[eucalyptus-sc] sending create action to template[eucalyptus.conf] (delayed)
[2014-12-05T14:02:10+07:00] INFO: Processing template[eucalyptus.conf] action create (eucalyptus::storage-controller line 46)
[2014-12-05T14:02:10+07:00] ERROR: Running exception handlers
[2014-12-05T14:02:10+07:00] ERROR: Exception handlers complete
[2014-12-05T14:02:10+07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-12-05T14:02:10+07:00] ERROR: execute[Wait for resource availability] (eucalyptus::create-first-resources line 48) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of source /root/eucarc && euca-describe-availability-zones verbose | grep m1.small | grep -v 0000 ----
STDOUT:
STDERR:
---- End output of source /root/eucarc && euca-describe-availability-zones verbose | grep m1.small | grep -v 0000 ----
Ran source /root/eucarc && euca-describe-availability-zones verbose | grep m1.small | grep -v 0000 returned 1
[2014-12-05T14:02:13+07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
I don't understand what it's to talk to me. Any help?
Cheers,
Nghiep.
I solved it , It mistake because i provice not enough storage size for eucalyptus. Eucalyptus recommend manimum 100Gb

what's mean 'the use of this feature is restricted'?

I used the Xenserver 6.1 in my two servers.
I want to use live-migration.
But, they can't to join same resource pool .
So, I use cpu-masking feature.
However, it isn't working, too.
My first server info is..
[server-1]
cpu_count : 32
vendor: GenuineIntel
speed: 2000.066
modelname: Intel(R) Xeon(R) CPU E5-2640 v2 # 2.00GHz
family: 6
model: 62
stepping: 4
flags: fpu de tsc msr pae mce cx8 apic sep mtrr mca cmov pat
clflush acpi mmx fxsr sse sse2 ss ht nx constant_tsc
nonstop_tsc aperfmperf pni pclmulqdq vmx est ssse3 sse4_1 sse4_2
x2apic popcnt aes hypervisor ida arat tpr_shadow vnmi
flexpriority ept vpid
features: 77bee3ff-bfebfbff-00000001-2c100800
features_after_reboot: 77bee3ff-bfebfbff-00000001-2c100800
physical_features: 77bee3ff-bfebfbff-00000001-2c100800
maskable: no
My second server info is..
[server-2]
cpu_count : 24
vendor: GenuineIntel
speed: 2000.040
modelname: Intel(R) Xeon(R) CPU E5-2620 0 # 2.00GHz
family: 6
model: 45
stepping: 7
flags: fpu de tsc msr pae mce cx8 apic sep mtrr mca cmov pat clflush
acpi mmx fxsr sse sse2 ss ht nx constant_tsc nonstop_tsc
aperfmperf pni pclmulqdq vmx est ssse3 sse4_1 sse4_2 x2apic
popcnt aes hypervisor ida arat tpr_shadow vnmi flexpriority
ept vpid
features: 17bee3ff-bfebfbff-00000001-2c100800
features_after_reboot: 17bee3ff-bfebfbff-00000001-2c100800
physical_features: 17bee3ff-bfebfbff-00000001-2c100800
maskable: full
I use this command in my server1.
xe host-set-cpu-features features=17bee3ff-bfebfbff-00000001-2c100800 uuid=6c91e5c8-06b9-4b5c-a41d-ec4d6b2c44aa
Result is 'The use of this feature is restricted'.
And, I use this command in my server2.
xe host-set-cpu-features features=77bee3ff-bfebfbff-00000001-2c100800 uuid=53566e64-a24f-42a4-8a6d-a26e9f740fa8
Result is same.
What's mean this message?
'The use of this feature is restricted'.
How to use cpu-masking in my environment?
I encountered the same error message when trying to join a host with a cpu model E5503 to a pool with two hosts with E5645's. I was not able to get past this error with XenServer 6.1, but after upgrading the pool and the lone host to 6.2 I was able to apply a mask and join the third host to the pool without further issue.

Resources