I am currently using the do_gettimeofday()
function to measure time in the kernel, which gives me microsecond precision. Is there anything available that is more precise than this (maybe on the order of nanoseconds)?
ktime_get()
函数返回ktime_t
,其具有纳秒分辨率。
As I know, the most precise timer should be the processor specific counter register (such as TSC in x86). Linux kernel provide rdtsc, rdtscl, rdtscll macros from the "./arch/x86/include/asm/msr.h" file to read this register value. For ARM, cycle counter register .
These registers are all different from CPU to CPU. Common interface to access it is "get_cycles" function which is declared in file.
Maybe, this document can be helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.