<div dir="ltr">Hi everyone,<div><br></div><div>I'm developing a scheduler that supports a specific resource sharing protocol. In particular it allows a task, which is waiting for a busy resource, to dequeue the lock owner from its the ready queue and requeue it to the waiting task's cpu.</div>

<div><br></div><div>So, under particular conditions, the schedule function performs the dequeue and the migration:<br></div><div><br></div><div><div>static void dequeue_and_migrate(int from_cpu, int target_cpu, struct task_struct* owner)</div>

<div>{</div><div><span class="" style="white-space:pre">    </span>pfp_domain_t *from = remote_pfp(from_cpu);</div><div><span class="" style="white-space:pre"> </span>pfp_domain_t *to = remote_pfp(target_cpu);</div><div><br>

</div><div><span class="" style="white-space:pre">        </span>if (get_partition(owner) == target_cpu)</div><div><span class="" style="white-space:pre">            </span>return;</div><div><br></div><div><span class="" style="white-space:pre">   </span>preempt_disable();</div>

<div><span class="" style="white-space:pre">            </span>local_irq_disable();<br></div><div><br></div><div><span class="" style="white-space:pre">                    </span>raw_spin_lock(&from->slock);</div><div><br></div><div><span class="" style="white-space:pre">                               </span>tsk_rt(owner)->task_params.cpu = target_cpu;</div>

<div><span class="" style="white-space:pre">                            </span>fp_dequeue(from, owner);</div><div><br></div><div><span class="" style="white-space:pre">                  </span>raw_spin_unlock(&from->slock);</div><div><br></div><div><span class="" style="white-space:pre">                     </span>raw_spin_lock(&to->slock);</div>

<div><br></div><div><span class="" style="white-space:pre">                           </span>requeue(owner, to);<br></div><div><span class="" style="white-space:pre">                              </span>preempt(to);</div><div><br></div><div><span class="" style="white-space:pre">                      </span>raw_spin_unlock(&to->slock);</div>

<div><br></div><div><span class="" style="white-space:pre">           </span>local_irq_enable();</div><div><span class="" style="white-space:pre">        </span>preempt_enable();<br></div><div>}<br></div></div><div><br></div><div>When the lock owner releases the resource, it migrates back to the former cpu. This is performed using the migration function used by DPCP.<br>

</div><div><br></div><div>At run-time I have this warning:</div><div><br></div><div><div>WARNING: at kernel/sched/core.c:2885 sub_preempt_count+0x9e/0xf0()</div><div>DEBUG_LOCKS_WARN_ON(val > preempt_count())</div><div>

CPU: 2 PID: 1702 Comm: rtspin Not tainted 3.10.5-litmus2013.1 #354</div><div>Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011</div><div> 0000000000000009 ffff88001cd27de0 ffffffff8155ae8e ffff88001cd27e18</div><div> ffffffff8102f356 0000000000000001 ffff88001eada160 ffff88001cea0830</div>

<div> ffff88001eada160 ffff88001fd0fb20 ffff88001cd27e78 ffffffff8102f3f7</div><div>Call Trace:</div><div> [<ffffffff8155ae8e>] dump_stack+0x19/0x1b</div><div> [<ffffffff8102f356>] warn_slowpath_common+0x66/0x90</div>

<div> [<ffffffff8102f3f7>] warn_slowpath_fmt+0x47/0x50</div><div> [<ffffffff8105e5be>] sub_preempt_count+0x9e/0xf0</div><div> [<ffffffff8129ba0d>] pfp_lock+0x49d/0x6b0</div><div> [<ffffffff81293bca>] sys_litmus_lock+0x16a/0x1e0</div>

<div> [<ffffffff815625d2>] system_call_fastpath+0x16/0x1b</div><div>---[ end trace 3c8b462b5826d6f4 ]---</div></div><div><br></div><div>From the point of view of the tasks, only the first occurrence of the condition is affected by some problems, otherwise the rest of the execution is correct. In particular the lock owner, after the unlock event and the migration back, executes till the deadline instead of till the expiration of the execution time.</div>

<div><br></div><div>Anyone has any suggestion?</div><div><br></div><div>Thanks in advance,</div><div><br></div><div>Sebastiano</div></div>