How to understand sched_period in the cfs schedule class?

Song Zhi hizhisong at
Tue Mar 15 07:30:17 EDT 2022

As far as I understand, __sched_period is the time incurred in making the task runnable again(the period  making sure each process have a chance to run). When the processes are less than sched_nr_latency, the CFS scheduler splits time into periods in which each process is anticipated to run once.

u64 __sched_period(unsigned long nr_running)
    if (unlikely(nr_running > sched_nr_latency))
        return nr_running * sysctl_sched_min_granularity;
        return sysctl_sched_latency;

  1.  Does each process have a maximum of 'sysctl_sched_latency/2' time to run or do we have to perform 'sysctl_sched_latency/2' for each process if we have two processes with the same weight?
  2.  What about context switching time, scheduler cost calculation, and other factors? What does the sched_period consist of? What is the meaning of sched_period?

More details here:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Kernelnewbies mailing list