Who calls delay_tsc () on Linux

I used OProfile to profile my Linux box. During the profiling processes, I found that in addition to the " native_safe_halt " function, " delay_tsc " is the second most important function consuming cpu (about 10%). It seems that delay_tsc() is a busy cycle. But who calls him and what is his function?

+4
source share
1 answer

No one calls it directly, since it is a local function inside the part of the source that you are referring to. The call method is the published __delay() function.

When you call __delay() , it will use the delay_fn function delay_fn (also local to this file) to select one of several delay functions. The default value is delay_loop() , which uses x86 instructions to check the time.

However, if use_tsc_delay() was called (at boot time), it switches the pointer to delay_tsc() , which uses the timestamp (CPU counter) to timestamp.

It is called by any kernel code that wants to have a fairly robust, high-resolution delay function. You can see all the code in the kernel that references __delay here (quite a few places).

I think it is probably pretty safe, from the point of view of profiling, to ignore the time spent on this function, since its intention is to delay. In other words, this is not a very useful job, requiring a lot of time to complete - if the callers do not want to delay, they will not call it.

Some examples from this list:

  • The control timer uses it to step along the cores so that their output does not mix with each other, delaying several multiple of the current kernel identifier.
  • The ATI framebuffer driver appears to be using it for delays between low-level hardware accesses. In fact, it has been used for this purpose in many device drivers.
  • It was used during startup to find out the relationship between jiffies and actual hardware speeds.
+6
source

Source: https://habr.com/ru/post/1380327/


All Articles