pub unsafe fn rdtscp() -> (u64, u32)
Expand description
Read the time stamp counter.
The RDTSCP instruction waits until all previous instructions have been executed before reading the counter. However, subsequent instructions may begin execution before the read operation is performed.
Volatile is used here because the function may be used to act as an instruction barrier.
§Returns
- The current time stamp counter value of the CPU as a
u64
. - The contents of
IA32_TSC_AUX
on that particular core. This is an OS defined value. For example, Linux writesnuma_id << 12 | core_id
into it. See alsocrate::rdpid
.
§Note
One can use core::arch::x86_64::__rdtscp
from the Rust core library as
well. We don’t rely on it because it only returns the time-stamp counter of
rdtscp and not the contents of IA32_TSC_AUX
.
§Safety
- Causes a GP fault if the TSD flag in register CR4 is set and the CPL is greater than 0.