user3191169
user3191169

Reputation: 11

Where is the linux scheduler triggered?

Currently, I want to dive into the Linux scheduling. I have a test setup with lubuntu and a 4.10.0-37-generic Kernel. I want to know how long the minimum time of execution with a CFS task could be without self yielding. Here a good overview is given how to tweak the scheduler. I think the sysctl parameter kernel.sched_min_granularity_ns (setup = 1.500.000) is the right place to look at. But I do not find any reference on the scheduler frequency. In the CFS documentation (CFS doc) the independence of scheduling and the jiffies (counted from system timer interrupt with the 1/HZ period). But in some documentation I can't find anymore it was noted that all frequencies in the Kernel rely on this HZ value. My current HZ value is 250 (default), so if the scheduler is called within the jiffy timer interrupt only ever 4 ms a reschedule can happen. This is in contrast to the 1.5 ms sched_min_granularity_ns. How the scheduler could be faster than the system interrupt?

Upvotes: 1

Views: 729

Answers (1)

sourcejedi
sourcejedi

Reputation: 3271

My current HZ value is 250 (default), so if the scheduler is called within the jiffy timer interrupt only ever 4 ms a reschedule can happen. This is in contrast to the 1.5 ms sched_min_granularity_ns. How the scheduler could be faster than the system interrupt?

See commit 8f4d37ec073c, "sched: high-res preemption tick", found via this comment in a thread about the change: https://lwn.net/Articles/549754/ .

When hrtimers are available (and only when), the CPU scheduler will use them to interrupt more frequently. Note, this also allows it to interrupt less frequently if it wants, which can be more efficient.

hrtimers should be available on most systems.

(If you look Kconfig.hz in the commit, don't worry that SCHED_HRTICK depends on X86. That requirement seems to have been dropped in some more recent commit).

Upvotes: 1

Related Questions