Commit 57ccc4fb authored by Jan Kiszka's avatar Jan Kiszka
Browse files

cobalt: Fix handling of invalid thread affinities during hardening



The I-pipe implementation was lucky in its approach to not wake up the
RT thread in case the non-RT part migrated to an unsupported CPU. For
unclear reasons, the scheduled cancellation made it to the thread and
avoided any lockup. On dovetail, this fails.

So switch both implemenations to the safer pattern of actually
completing the migration, using the previous affinity of the thread. It
will still be canceled right after that, now also over dovetail.

As cobalt_affinity_ok's return value becomes irrelevant, refactor this
function to cobalt_adjust_affinity without and return code.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent dc78bd06
......@@ -307,8 +307,10 @@ void resume_oob_task(struct task_struct *p) /* inband, oob stage stalled */
* relax_thread/harden_thread handlers.
*/
xnthread_run_handler_stack(thread, harden_thread);
if (cobalt_affinity_ok(p))
xnthread_resume(thread, XNRELAX);
cobalt_adjust_affinity(p);
xnthread_resume(thread, XNRELAX);
/*
* In case we migrated independently of the user return notifier, clear
......
......@@ -171,8 +171,10 @@ void ipipe_migration_hook(struct task_struct *p) /* hw IRQs off */
* relax_thread/harden_thread handlers.
*/
xnthread_run_handler_stack(thread, harden_thread);
if (cobalt_affinity_ok(p))
xnthread_resume(thread, XNRELAX);
cobalt_adjust_affinity(p);
xnthread_resume(thread, XNRELAX);
/*
* In case we migrated independently of the user return notifier, clear
......
......@@ -773,7 +773,7 @@ int cobalt_handle_setaffinity_event(struct task_struct *task)
}
#ifdef CONFIG_SMP
bool cobalt_affinity_ok(struct task_struct *task) /* nklocked, IRQs off */
void cobalt_adjust_affinity(struct task_struct *task) /* nklocked, IRQs off */
{
struct xnthread *thread = xnthread_from_task(task);
struct xnsched *sched;
......@@ -812,12 +812,12 @@ bool cobalt_affinity_ok(struct task_struct *task) /* nklocked, IRQs off */
* in xnthread_harden().
*/
xnthread_set_info(thread, XNCANCELD);
return false;
return;
}
sched = xnsched_struct(cpu);
if (sched == thread->sched)
return true;
return;
/*
* The current thread moved to a supported real-time CPU,
......@@ -829,8 +829,6 @@ bool cobalt_affinity_ok(struct task_struct *task) /* nklocked, IRQs off */
xnthread_run_handler_stack(thread, move_thread, cpu);
xnthread_migrate_passive(thread, sched);
return true;
}
#endif /* CONFIG_SMP */
......
......@@ -164,9 +164,9 @@ extern struct xnthread_personality cobalt_personality;
int cobalt_handle_setaffinity_event(struct task_struct *task);
#ifdef CONFIG_SMP
bool cobalt_affinity_ok(struct task_struct *task);
void cobalt_adjust_affinity(struct task_struct *task);
#else
#define cobalt_affinity_ok(task) (true)
static inline void cobalt_adjust_affinity(struct task_struct *task) { }
#endif
int cobalt_handle_taskexit_event(struct task_struct *task);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment