metrics-rs / quanta

high-speed timing library in Rust
MIT License
302 stars 31 forks source link

Check for RDTSCP support doesn't work #56

Closed humb1t closed 3 years ago

humb1t commented 3 years ago

Hi, I faced a problem. My VM had no support for RDTSCP which resulted in app crash without a stacktrace:

Main process exited, code=dumped, status=4/ILL

After looking into core dumps I found that the reason is rdtscp dependency:

Program terminated with signal SIGILL, Illegal instruction.
#0  core::core_arch::x86::rdtsc::__rdtscp (aux=<optimized out>) at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/../../stdarch/crates/core_arch/src/x86/rdtsc.rs:49
49  /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/../../stdarch/crates/core_arch/src/x86/rdtsc.rs: No such file or directory.

It started to be a problem with introduction of metrics with quanta as a dependency. RDTSCP enabled on VM solved the problem, but I think it should be handled in a more user friendly way inside quanta.

Thank you in advance.

tobz commented 3 years ago

@humb1t Can you provide a little more information about the VM environment, such as the emulated CPUs? Something like the output of /proc/cpuinfo on a Linux host would work best.

We do check for rdtscp support in some cases, but this might be a case where it's not checking.

humb1t commented 3 years ago
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   40 bits physical, 48 bits virtual
CPU(s):                          10
On-line CPU(s) list:             0-9
Thread(s) per core:              1
Core(s) per socket:              10
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      15
Model:                           6
Model name:                      Common KVM processor
Stepping:                        1
CPU MHz:                         3393.624
BogoMIPS:                        6787.24
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       640 KiB
L1i cache:                       640 KiB
L2 cache:                        5 MiB
L3 cache:                        16 MiB
NUMA node0 CPU(s):               0-9
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Not affected
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full AMD retpoline, STIBP disabled, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
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 rep_good nopl cpuid extd_apicid tsc_known_freq pni cx16 x2apic hypervisor cmp_legacy 3dnowprefetch vmmcall

Sure - here it is.