rtdm_task_init vs. supported_cpus
Hi Philippe,
while playing with maxcpus on x86, I ran into one issue again that I think I saw already but forgot to dig into back then: When an RTDM driver happens to create a kernel task (rtdm_task_init) on a support outside of xenomai.supported_cpus, we will crash. That may happen because that command is run over module_init, or any other context that is not a Xenomai-blessed Linux task with therefore constraint affinity mask.
Any suggestions how to resolve that best? Restrict the affinity of the rtdm_task_init caller? Permanently or maybe just temporarily? Or is there some way to resolve that deeper inside xnthread_* APIs?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Quoted 10 lines · Jan Kiszka
Hi Philippe,
while playing with maxcpus on x86, I ran into one issue again that I think I saw already but forgot to dig into back then: When an RTDM driver happens to create a kernel task (
rtdm_task_init) on a support outside of xenomai.supported_cpus, we will crash. That may happen because that command is run overmodule_init, or any other context that is not a Xenomai-blessed Linux task with therefore constraint affinity mask.
Quoted 4 lines
Any suggestions how to resolve that best? Restrict the affinity of the
rtdm_task_initcaller? Permanently or maybe just temporarily? Or is there some way to resolve that deeper inside xnthread_* APIs?
xnthread_pin_initial() may help.
Signature · 1 line
Philippe.
Quoted 10 lines · Philippe Gerum
Quoted 9 lines · Jan Kiszka
Hi Philippe,
while playing with maxcpus on x86, I ran into one issue again that I think I saw already but forgot to dig into back then: When an RTDM driver happens to create a kernel task (
rtdm_task_init) on a support outside of xenomai.supported_cpus, we will crash. That may happen because that command is run overmodule_init, or any other context that is not a Xenomai-blessed Linux task with therefore constraint affinity mask.
More precisely: You had to boot with maxcpus < existing CPUs as well. I that case, the core would not initialize its internal per-cpu data structures (specifically nksched) for the initially offlined CPUs, and running xnthread_start over them later on will cause that crash.
Quoted 8 lines
Quoted 5 lines
Any suggestions how to resolve that best? Restrict the affinity of the
rtdm_task_initcaller? Permanently or maybe just temporarily? Or is there some way to resolve that deeper inside xnthread_* APIs?
xnthread_pin_initial()may help.
It does, because of the contained set_cpus_allowed_ptr(). It's basically that permanent mask adjustment of the caller I mentioned above. The use case for xnthread_pin_initial is cobalt_map_user() where the target xnthread is corresponding to the current task and caller. Here we are over a separate, pure Linux task. I guess it's safer (/wrt unknown callers) to restore current's affinity after xnthread_start().
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Quoted 26 lines · Jan Kiszka
Quoted 10 lines · Philippe Gerum
Quoted 9 lines · Jan Kiszka
Hi Philippe,
while playing with maxcpus on x86, I ran into one issue again that I think I saw already but forgot to dig into back then: When an RTDM driver happens to create a kernel task (
rtdm_task_init) on a support outside of xenomai.supported_cpus, we will crash. That may happen because that command is run overmodule_init, or any other context that is not a Xenomai-blessed Linux task with therefore constraint affinity mask.More precisely: You had to boot with maxcpus < existing CPUs as well. I that case, the core would not initialize its internal per-cpu data structures (specifically nksched) for the initially offlined CPUs, and running
xnthread_startover them later on will cause that crash.Quoted 8 lines
Quoted 5 lines
Any suggestions how to resolve that best? Restrict the affinity of the
rtdm_task_initcaller? Permanently or maybe just temporarily? Or is there some way to resolve that deeper inside xnthread_* APIs?
xnthread_pin_initial()may help.
Quoted 7 lines
It does, because of the contained
set_cpus_allowed_ptr(). It's basically that permanent mask adjustment of the caller I mentioned above. The use case forxnthread_pin_initialiscobalt_map_user()where the target xnthread is corresponding to the current task and caller. Here we are over a separate, pure Linux task. I guess it's safer (/wrt unknown callers) to restore current's affinity afterxnthread_start().
The cleanest way would likely involve phasing out xnthread_start() entirely. This is a relic from the ancient times when the 2.6 nucleus would create non-linux kernel threads, which could emerge in dormant and/or suspended state. I see no valid use case for this stuff anymore.
Signature · 1 line
Philippe.