I used OProfile to profiling my Linux box. During the profiling processes, I’ve found that besides “native_safe_halt” function, the “delay_tsc” is the second most significant function consuming cpu cycles (around 10%). It seems delay_tsc() is a busy loop. But who calls it and what is its function?
I used OProfile to profiling my Linux box. During the profiling processes, I’ve found
Share
Nobody calls it directly since it’s a local function inside that piece of source you link to. The way to call it is by the published
__delay()function.When you call
__delay(), this will use thedelay_fnfunction pointer (also local to that file) to select one of several delay functions. By default, the one selected isdelay_loop(), which uses x86 instructions to try and mark time.However, if
use_tsc_delay()has been called (at boot time), it switches the function pointer todelay_tsc(), which uses the time stamp counter (a CPU counter) to mark time.It’s called by any kernel code that wants a reasonably reliable, high-resolution delay function. You can see all the code in the kernel that references
__delayhere (quite a few places).I think it’s probably pretty safe, in terms of profiling, to ignore the time spent in that function since its intent is to delay. In other words, it’s not useful work that’s taking a long time to perform – if callers didn’t want to delay, they wouldn’t call it.
Some examples from that list: