New domain migration process with ipipe-core and forge
Hi Philippe,
I'm trying to understand how the new Linux-to-RT migration process works under forge and specifically I-pipe core. It currently looks to me like we are delaying this needlessly:
- __ipipe_migrate_head() suspends the calling Linux thread and triggers a context switch
- after the switch, __ipipe_switch_tail and then complete_domain_migration is invoked
- complete_domain_migration stalls head and calls ipipe_migration_hook. We are still running over the root domain.
- ipipe_migration_hook in forge wakes up the RT thread and calls xnpod_schedule
- as we are in root, xnarch_escalate triggers and calls ipipe_raise_irq
- as the head domain is stalled, dispatch_irq_head just marks the escalation VIRQ pending, not handler is called, no actual RT rescheduling can be performed on its return
- we eventually return to complete_domain_migration and simply clear the stall flag. No pending IRQs are process, again no VIRQ is delivered
- only when we receive the next IRQ or have some other reason for checking the head domain's IRQ log, the pending VIRQ will finally be processed
Did I miss something or should we actually perform some __ipipe_sync_stage in complete_domain_migration to accelerate the switch?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
Quoted 25 lines · Jan Kiszka
Hi Philippe,
I'm trying to understand how the new Linux-to-RT migration process works under forge and specifically I-pipe core. It currently looks to me like we are delaying this needlessly:
-
__ipipe_migrate_head()suspends the calling Linux thread and triggers a context switch
- after the switch,__ipipe_switch_tailand thencomplete_domain_migrationis invoked
-complete_domain_migrationstalls head and callsipipe_migration_hook. We are still running over the root domain.
-ipipe_migration_hookin forge wakes up the RT thread and callsxnpod_schedule
- as we are in root,xnarch_escalatetriggers and callsipipe_raise_irq
- as the head domain is stalled,dispatch_irq_headjust marks the escalation VIRQ pending, not handler is called, no actual RT rescheduling can be performed on its return
- we eventually return tocomplete_domain_migrationand simply clear the stall flag. No pending IRQs are process, again no VIRQ is delivered
- only when we receive the next IRQ or have some other reason for checking the head domain's IRQ log, the pending VIRQ will finally be processed
Quoted 2 lines
Did I miss something or should we actually perform some
__ipipe_sync_stageincomplete_domain_migrationto accelerate the switch?
Or rather this:
kernel/ipipe/core.c +1 -0
@@ -1102,6 +1102,7 @@ static void complete_domain_migration(void) /* hw IRQs off */__set_bit (IPIPE_STALL_FLAG , &p->status);ipipe_migration_hook (t);__clear_bit (IPIPE_STALL_FLAG , &p->status); + __ipipe_do_sync_pipeline(p->domain); }#endif /* !CONFIG_IPIPE_LEGACY */
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
Quoted 25 lines · Jan Kiszka
Hi Philippe,
I'm trying to understand how the new Linux-to-RT migration process works under forge and specifically I-pipe core. It currently looks to me like we are delaying this needlessly:
-
__ipipe_migrate_head()suspends the calling Linux thread and triggers a context switch
- after the switch,__ipipe_switch_tailand thencomplete_domain_migrationis invoked
-complete_domain_migrationstalls head and callsipipe_migration_hook. We are still running over the root domain.
-ipipe_migration_hookin forge wakes up the RT thread and callsxnpod_schedule
- as we are in root,xnarch_escalatetriggers and callsipipe_raise_irq
- as the head domain is stalled,dispatch_irq_headjust marks the escalation VIRQ pending, not handler is called, no actual RT rescheduling can be performed on its return
- we eventually return tocomplete_domain_migrationand simply clear the stall flag. No pending IRQs are process, again no VIRQ is delivered
- only when we receive the next IRQ or have some other reason for checking the head domain's IRQ log, the pending VIRQ will finally be processed
Quoted 3 lines
Did I miss something or should we actually perform some
__ipipe_sync_stageincomplete_domain_migrationto accelerate the switch?
Yep. The current code wrongly assumes that we are covered by a root unstall from finish_task_switch -> finish_lock_switch, but we are not since the pipeline won't consider the head domain log when deciding whether irqs should be synced.
Signature · 1 line
Philippe.
Quoted 37 lines · Jan Kiszka
Quoted 25 lines · Jan Kiszka
Hi Philippe,
I'm trying to understand how the new Linux-to-RT migration process works under forge and specifically I-pipe core. It currently looks to me like we are delaying this needlessly:
-
__ipipe_migrate_head()suspends the calling Linux thread and triggers a context switch
- after the switch,__ipipe_switch_tailand thencomplete_domain_migrationis invoked
-complete_domain_migrationstalls head and callsipipe_migration_hook. We are still running over the root domain.
-ipipe_migration_hookin forge wakes up the RT thread and callsxnpod_schedule
- as we are in root,xnarch_escalatetriggers and callsipipe_raise_irq
- as the head domain is stalled,dispatch_irq_headjust marks the escalation VIRQ pending, not handler is called, no actual RT rescheduling can be performed on its return
- we eventually return tocomplete_domain_migrationand simply clear the stall flag. No pending IRQs are process, again no VIRQ is delivered
- only when we receive the next IRQ or have some other reason for checking the head domain's IRQ log, the pending VIRQ will finally be processedQuoted 2 lines
Did I miss something or should we actually perform some
__ipipe_sync_stageincomplete_domain_migrationto accelerate the switch?Or rather this:
kernel/ipipe/core.c +0
-0
kernel/ipipe/core.c static void complete_domain_migration(void) /* hw IRQs off */ · line 1108
Quoted 7 lines
kernel/ipipe/core.c +1
-0@@ -1102,6 +1102,7 @@ static void complete_domain_migration(void) /* hw IRQs off */__set_bit (IPIPE_STALL_FLAG , &p->status);ipipe_migration_hook (t);__clear_bit (IPIPE_STALL_FLAG , &p->status); + __ipipe_do_sync_pipeline(p->domain); }#endif /* !CONFIG_IPIPE_LEGACY */
Nitpicking: in theory, the code should expect the migration hook to have actually done the work, and not delayed it like Xenomai currently does in practice. A safer check would be as follows, allowing further arch-dependent handling in case the migration did succeed (typically for Blackfin):
kernel/ipipe/core.c +2 -0
@@ -1102,6 +1102,8 @@ static void complete_domain_migration(void) /* hw IRQs off */__set_bit (IPIPE_STALL_FLAG , &p->status);ipipe_migration_hook (t);__clear_bit (IPIPE_STALL_FLAG , &p->status); +if (__ipipe_ipending_p (p)) + __ipipe_sync_pipeline(p->domain); }#endif /* !CONFIG_IPIPE_LEGACY */
Signature · 1 line
Philippe.
Quoted 43 lines · Philippe Gerum
Quoted 42 lines · Jan Kiszka
Quoted 25 lines · Jan Kiszka
Hi Philippe,
I'm trying to understand how the new Linux-to-RT migration process works under forge and specifically I-pipe core. It currently looks to me like we are delaying this needlessly:
-
__ipipe_migrate_head()suspends the calling Linux thread and triggers a context switch
- after the switch,__ipipe_switch_tailand thencomplete_domain_migrationis invoked
-complete_domain_migrationstalls head and callsipipe_migration_hook. We are still running over the root domain.
-ipipe_migration_hookin forge wakes up the RT thread and callsxnpod_schedule
- as we are in root,xnarch_escalatetriggers and callsipipe_raise_irq
- as the head domain is stalled,dispatch_irq_headjust marks the escalation VIRQ pending, not handler is called, no actual RT rescheduling can be performed on its return
- we eventually return tocomplete_domain_migrationand simply clear the stall flag. No pending IRQs are process, again no VIRQ is delivered
- only when we receive the next IRQ or have some other reason for checking the head domain's IRQ log, the pending VIRQ will finally be processedQuoted 2 lines
Did I miss something or should we actually perform some
__ipipe_sync_stageincomplete_domain_migrationto accelerate the switch?Or rather this:
kernel/ipipe/core.c +1
-0@@ -1102,6 +1102,7 @@ static void complete_domain_migration(void) /* hw IRQs off */__set_bit (IPIPE_STALL_FLAG , &p->status);ipipe_migration_hook (t);__clear_bit (IPIPE_STALL_FLAG , &p->status); +__ipipe_do_sync_pipeline (p->domain); }
Quoted 6 lines
kernel/ipipe/core.c static void complete_domain_migration(void) /* hw IRQs off */ · line 1109
Quoted 2 lines
kernel/ipipe/core.c +0
-0#endif /* !CONFIG_IPIPE_LEGACY */ Nitpicking: in theory, the code should expect the migration hook to have actually done the work, and not delayed it like Xenomai currently does in practice.
Where does Xenomai do that? I was looking for it but didn't find a log flush.
Quoted 14 lines
A safer check would be as follows, allowing further arch-dependent handling in case the migration did succeed (typically for Blackfin):
kernel/ipipe/core.c +0
-0@@ -1102,6 +1102,8 @@ static void complete_domain_migration(void) /* hwIRQs off */
__set_bit(IPIPE_STALL_FLAG, &p->status);ipipe_migration_hook(t);__clear_bit(IPIPE_STALL_FLAG, &p->status);
kernel/ipipe/core.c static void complete_domain_migration(void) /* hw IRQs off */ · line 1109
Quoted 5 lines
kernel/ipipe/core.c +2
-0+if (__ipipe_ipending_p (p)) + __ipipe_sync_pipeline(p->domain); }#endif /* !CONFIG_IPIPE_LEGACY */
OK, will queue this up here for the next pull request.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
Quoted 7 lines · Jan Kiszka
Quoted 3 lines
Nitpicking: in theory, the code should expect the migration hook to have actually done the work, and not delayed it like Xenomai currently does in practice.
Where does Xenomai do that? I was looking for it but didn't find a log flush.
You mean delaying? Check per-arch xnarch_escalate(). Flushing occurs as soon as the xnpod_schedule() caller unstalls the head domain, which has to happen quickly after the delay was enforced.
Quoted 9 lines
Quoted 7 lines
kernel/ipipe/core.c +0
-0@@ -1102,6 +1102,8 @@ static void complete_domain_migration(void) /* hwIRQs off */
OK, will queue this up here for the next pull request.
Ok.
Signature · 1 line
Philippe.
Quoted 6 lines · Philippe Gerum
Quoted 4 lines · Jan Kiszka
Quoted 3 lines
Nitpicking: in theory, the code should expect the migration hook to have actually done the work, and not delayed it like Xenomai currently does in practice.
Quoted 7 lines
Quoted 3 lines
Where does Xenomai do that? I was looking for it but didn't find a log flush.
You mean delaying? Check per-arch
xnarch_escalate(). Flushing occurs as soon as thexnpod_schedule()caller unstalls the head domain, which has to happen quickly after the delay was enforced.
Hmm, I still do not see where we should flush in Xenomai forge before the return to complete_domain_migration and its clearance of the stall flag.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka
Quoted 3 lines
Nitpicking: in theory, the code should expect the migration hook to have actually done the work, and not delayed it like Xenomai currently does in practice.
Where does Xenomai do that? I was looking for it but didn't find a log flush.
Quoted 7 lines
Quoted 3 lines
You mean delaying? Check per-arch
xnarch_escalate(). Flushing occurs as soon as thexnpod_schedule()caller unstalls the head domain, which has to happen quickly after the delay was enforced.Hmm, I still do not see where we should flush in Xenomai forge before the return to
complete_domain_migrationand its clearance of the stall flag.
With the new migration interface, we don't have to do that from Xenomai, since the migration hook assumes it is called with the head domain stalled, so the caller has to unstall shortly after anyway. But for that to work, we need your latest fix.
2.x was immune because everything happened on behalf of the gatekeeper, which triggered a rescheduling with head unstalled. This is how the bug slipped into the -forge logic.
Signature · 1 line
Philippe.