Skip to content
  • Philippe Gerum's avatar
    cobalt/thread: dovetail: keep hard irqs off on transition to in-band · 98288382
    Philippe Gerum authored and Jan Kiszka's avatar Jan Kiszka committed
    
    
    Dovetail provides a fast service to escalate the caller to out-of-band
    mode for executing a routine (run_oob_call()), which we use to enforce
    primary mode in ___xnsched_run() to schedule out the relaxing thread.
    
    Due to the way run_oob_call() works, enabling hardirqs during this
    transition can trigger a subtle bug caused by the relaxing thread to
    be switched out, as a result of taking an interrupt during the irqs on
    section, before __xnsched_run() actually runs on behalf of
    xnthread_relax() -> xnthread_suspend().
    
    This may lead to a breakage of the inband interrupt state, revealed by
    lockdep complaining about a HARDIRQ-IN-W -> HARDIRQ-ON-W situation,
    when finalize_task_switch() runs for reconciling both the in-band and
    Xenomai scheduler states.
    
    Re-enabling hard irqs before switching out the relaxing thread was
    throught as a mean to reduce the scope of the interrupt-free section
    while relaxing a thread with the I-pipe, which unlike Dovetail
    requires us to open code an escalation service based on triggering a
    synthetic interrupt.
    
    We differentiate the behavior between the I-pipe and Dovetail by
    abstracting the related bits as pipeline_leave_oob_unlock(), keeping
    the current implementation unchanged for the I-pipe.
    
    Signed-off-by: default avatarPhilippe Gerum <rpm@xenomai.org>
    Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
    98288382