<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p style="margin-top:0px;margin-bottom:var(--s-prose-spacing);font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", "Liberation Sans", sans-serif;font-size:15px;clear:both;color:rgb(35, 38, 41);text-align:left;background-color:rgb(255, 255, 255)">
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.</p>
<pre class="lang-c s-code-block" style="margin-top:0px;margin-bottom:calc(var(--s-prose-spacing) + 0.4em);padding:12px;line-height:1.30769;font-family:var(--ff-mono);font-size:13px;width:auto;max-height:600px;overflow:auto;background-color:var(--highlight-bg);border-radius:5px;color:var(--highlight-color);text-align:left"><code class="hljs language-c" style="margin:0px">u64 __sched_period(<span class="hljs-type" style="margin:0px;color:var(--highlight-namespace)">unsigned</span> <span class="hljs-type" style="margin:0px;color:var(--highlight-namespace)">long</span> nr_running)
{
<span class="hljs-keyword" style="margin:0px;color:var(--highlight-keyword)">if</span> (unlikely(nr_running > sched_nr_latency))
<span class="hljs-keyword" style="margin:0px;color:var(--highlight-keyword)">return</span> nr_running * sysctl_sched_min_granularity;
<span class="hljs-keyword" style="margin:0px;color:var(--highlight-keyword)">else</span>
<span class="hljs-keyword" style="margin:0px;color:var(--highlight-keyword)">return</span> sysctl_sched_latency;
}
</code></pre>
<p style="margin:0px;clear:both"></p>
<ol>
<li><span>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?<br>
</span></li><li style="margin:0px;overflow-wrap:break-word">
<p style="margin:0px;clear:both">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?</p>
</li></ol>
<p></p>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
More details here:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://stackoverflow.com/questions/71480711/how-to-understand-sched-period-in-the-cfs-schedule-class" id="LPNoLPOWALinkPreview">https://stackoverflow.com/questions/71480711/how-to-understand-sched-period-in-the-cfs-schedule-class</a></div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<br>
</body>
</html>