What is hrtick_clear (rq); in linux scheduler?
Classic OS design includes a system timer - an object that ticks at fixed intervals. During each tick the scheduler is called and if the process / thread needs to be switched. But the frequency of the system timer is quite low (i.e. 1000 Hz, which means once every 1 ms), and if a process only leaves 100us of its timelis, it will get extra time (under certain circumstances) while other processes will starve ...
However, modern processors provide more accurate hardware timers like Intel's HPET which are provided by hrtimers . They can be enabled for use in the scheduler using the option CONFIG_SCHED_HRTICK
.
But if you have already called __schedule()
(that is, on the way to the system call), you don't need to call it a second time from hrtimer, because you are already planning, so hrtick_clear
disables that hrtimer before doing that.
source to share