<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello All,</div><div><br></div>I’m using nonpreemptive sections pretty heavily in my code, and I’m experiencing a situation where jobs are descheduled, never to return. I suspect jobs are being unlinked, but never relinked onto a ready queue.<div><br></div><div>In GSN-EDF, we have the following code:</div><div><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; margin-top: 0px; margin-bottom: 0px; color: rgb(51, 51, 51); line-height: 18px;"><div class="line" id="LC472" style="box-sizing: border-box; padding-left: 10px; background-color: rgb(255, 255, 204);"> <span class="k" style="box-sizing: border-box; font-weight: bold;">if</span> <span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">np</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">&&</span> <span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">out_of_time</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">||</span> <span class="n" style="box-sizing: border-box;">preempt</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">||</span> <span class="n" style="box-sizing: border-box;">sleep</span><span class="p" style="box-sizing: border-box;">))</span> <span class="p" style="box-sizing: border-box;">{</span></div><div class="line" id="LC473" style="box-sizing: border-box; padding-left: 10px;"> <span class="n" style="box-sizing: border-box;">unlink</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">entry</span><span class="o" style="box-sizing: border-box; font-weight: bold;">-></span><span class="n" style="box-sizing: border-box;">scheduled</span><span class="p" style="box-sizing: border-box;">);</span></div><div class="line" id="LC474" style="box-sizing: border-box; padding-left: 10px;"> <span class="n" style="box-sizing: border-box;">request_exit_np</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">entry</span><span class="o" style="box-sizing: border-box; font-weight: bold;">-></span><span class="n" style="box-sizing: border-box;">scheduled</span><span class="p" style="box-sizing: border-box;">);</span></div><div class="line" id="LC475" style="box-sizing: border-box; padding-left: 10px;"> <span class="p" style="box-sizing: border-box;">}</span></div></pre><div>(link: <a href="https://github.com/LITMUS-RT/litmus-rt/blob/master/litmus/sched_gsn_edf.c#L472">https://github.com/LITMUS-RT/litmus-rt/blob/master/litmus/sched_gsn_edf.c#L472</a>)</div></div><div><br></div><div>Suppose: np == 1 and preempt == 1, out_of_time == 0, sleep == 0.</div><div><br></div><div>Why do we unlink() even if the scheduled task (entry->scheduled) will remain running? I have tasks that, upon exiting a non-preemptive section, are descheduled and are never rescheduled. I think they fell off a queue some where.</div><div><br></div><div>A log. Pay special attention to pgmrt/4650.</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285694 </span>285694 P21 [__add_ready@litmus/rt_domain.c:307]: rt: adding <span style="background-color: #e6e600">pgmrt/4650</span> (12441000, 191976000, 191976000) rel=1519606919297 to ready queue at 1519597109578</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><font color="#ce7924">...</font></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285697 </span>285696 P10 [is_np@include/litmus/litmus.h:241]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) is non-preemptive: kernel=0 user=1</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><font color="#ce7924">...</font></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><b>/* vvvv An attempt to preempt is made, but it is rejected. However, pgmrt/4650 will still be unlinked. vvvv */</b></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><b><span style="color: #ce7924">285699 </span>285699 P10 [cflsplit_schedule@litmus/sched_cfl_split.c:595]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) blocks:0 out_of_time:0 needs_move: 0 np:1 sleep:0 preempt:1 state:0 sig:0 boosted:0</b></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><font color="#ce7924">...</font></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285701 </span>285701 P10 [cflsplit_schedule@litmus/sched_cfl_split.c:599]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) will be preempted by pgmrt/4723</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><font color="#ce7924">...</font></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285703 </span>285703 P10 [request_exit_np@include/litmus/litmus.h:154]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) setting delayed_preemption flag</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><font color="#ce7924">...</font></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285705 </span>285705 P10 [is_np@include/litmus/litmus.h:241]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) is non-preemptive: kernel=0 user=1</div><div style="margin: 0px;"><span style="color: rgb(206, 121, 36); font-family: 'Source Code Pro'; font-size: 11px;">...</span></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><b>/* vvvv sched_yield() is called in the user space and pgmrt/4650 finally gives up the CPU to pgmrt/4723 vvvv */</b></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><b><span style="color: #ce7924">285715 </span>285715 P10 [cflsplit_schedule@litmus/sched_cfl_split.c:595]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) blocks:0 out_of_time:0 needs_move: 0 np:0 sleep:0 preempt:1 state:0 sig:0 boosted:0</b></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285716 </span>285716 P10 [cflsplit_schedule@litmus/sched_cfl_split.c:599]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) will be preempted by pgmrt/4723</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #ce7924">285717 </span>285717 P10 [cflsplit_schedule@litmus/sched_cfl_split.c:708]: (<span style="background-color: #e6e600">pgmrt/4650</span>:50) scheduled_on = NO_CPU</div></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><b>/* ^^^^ pgmrt/4650 is never heard from again ^^^^ */</b></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><b><br></b></div><div style="margin: 0px;">Do we need to call job_arrival() on the job exiting the non-preemption section?</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">Thanks,</div><div style="margin: 0px;">Glenn</div></body></html>