Skip to content
  • Philippe Gerum's avatar
    cobalt/sched: guard against missed rescheduling upon CPU migration · d540b504
    Philippe Gerum authored and Jan Kiszka's avatar Jan Kiszka committed
    
    
    Kicking the rescheduling procedure (xnsched_run()) from call sites
    running over the root thread with hard irqs enabled may lead to
    missing a rescheduling opportunity as a consequence of a CPU
    migration, e.g.:
    
        CPU0					CPU1
        ----                         		----
        t0: ...
                <context switch>
        t1: xnthread_resume(t0)
                 xnsched_run()
                 <CPU MIGRATION -->
                      |                             |
                      |                             |
                      x                             |
              (missed rescheduling)                 v
                                        ___xnsched_run(CPU1.sched)
    
    To address this issue, make sure every call to xnsched_run() either
    runs from the head domain which is not affected by CPU migration, or
    moves into the latest atomic section which might have changed the
    scheduler state.
    
    Turning on CONFIG_XENO_OPT_DEBUG_COBALT also enables a (oneshot)
    assertion which detects invalid calls from the root domain with hard
    irqs enabled.
    
    Signed-off-by: default avatarPhilippe Gerum <rpm@xenomai.org>
    Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
    d540b504