Feature Suggestion: AVX/AVX2 CPU flags

jic5760

Member
Nov 10, 2020
40
8
13
26
We can change the CPU to host to use AVX, but live migration is difficult in this case.

AVX is supported by most server CPUs.

Like aes, it would be nice to be able to use AVX while using kvm64.

Example) AVX is required from MongoDB version 5 or later.
 
you can already create custom CPU models (based on existing ones) and add flags there - maybe that is an option? see man cpu-models.conf
 
Worked.

EXAMPLE FILE
cpu-model: avx
flags +avx;+avx2
phys-bits host
hidden 0
hv-vendor-id proxmox
reported-model kvm64
 
  • Like
Reactions: fabian
you can already create custom CPU models (based on existing ones) and add flags there - maybe that is an option? see man cpu-models.conf
I also need AVX to run MongoDB 5.x, but don't want to use `host`. When I create the custom CPU type, as per the instructions, am I extending the `kvm64` flags, or am I only getting the AVX flags and nothing else? What are the default flags on `kvm64`, and do I need to add them, as well as avx, to the flags section?

Code:
cpu-model: avx
    flags +avx;+avx2
    phys-bits host
    hidden 0
    hv-vendor-id proxmox
    reported-model kvm64
 
Last edited:
I also need AVX to run MongoDB 5.x, but don't want to use `host`. When I create the custom CPU type, as per the instructions, am I extending the `kvm64` flags, or am I only getting the AVX flags and nothing else? What are the default flags on `kvm64`, and do I need to add them, as well as avx, to the flags section?

Code:
cpu-model: avx
    flags +avx;+avx2
    phys-bits 64
    hidden 0
    hv-vendor-id proxmox
    reported-model kvm64

the flags of the custom models are in addition to the one from the base model (unless you use -FLAG to subtract flags ;)). see man cpu-models.conf
 
@fabian, thanks for the info.

I setup my cpu-models.conf file as follows:

Code:
cpu-model: avx
    flags +avx;+avx2
    phys-bits host
    hidden 0
    hv-vendor-id proxmox
    reported-model kvm64

In my Docker VM, I can see the AVX flags (I have 4 cores).
Code:
root@docker05:~# grep avx /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2

However, MongoDB 5.0 (a Docker container inside the VM) still doesn't start. A quick Google shows this is an error about the CPU type.
Code:
Nov 16 15:41:18 docker05 kernel: [77258.409533] traps: mongod[408967] trap invalid opcode ip:5621fe59615a sp:7fffc77adef0 error:0 in mongod[5621fa519000+51e1000]

Note that containers are able to see the AVX flags (same flags on the VM).
Code:
root@docker05:~# docker run -it --rm alpine grep avx /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic avx hypervisor lahf_lm cpuid_fault pti avx2

I could change the CPU type to host, but I'd prefer to use a generic kvm64 if possible. What am I missing here? Is this a problem with Proxmox, or Mongo? The MongoDB Docker container has a check for AVX, so it won't start if AVX isn't there, and I'm not seeing that error, which means the container is seeing AVX present...
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!