Re: [RFC][PATCH 5/7] sched,livepatch: Use wake_up_if_idle()
From: Petr Mladek
Date: Thu Sep 23 2021 - 08:19:22 EST
On Wed 2021-09-22 15:05:03, Miroslav Benes wrote:
> > @@ -405,8 +405,10 @@ void klp_try_complete_transition(void)
> > for_each_possible_cpu(cpu) {
> > task = idle_task(cpu);
> > if (cpu_online(cpu)) {
> > - if (!klp_try_switch_task(task))
> > - complete = false;
> > + int ret = klp_try_switch_task(task);
> > + if (ret == -EBUSY)
> > + wake_up_if_idle(cpu);
> > + complete = !ret;
>
> This is broken. You can basically change "complete" only to false (when it
> applies). This could leave some tasks in the old patching state.
I was a bit confused by Mirek's comment ;-) Anyway, the following works for me:
@@ -406,9 +406,12 @@ void klp_try_complete_transition(void)
task = idle_task(cpu);
if (cpu_online(cpu)) {
int ret = klp_try_switch_task(task);
- if (ret == -EBUSY)
- wake_up_if_idle(cpu);
- complete = !ret;
+ if (ret) {
+ complete = false;
+ /* Make idle task go through the main loop. */
+ if (ret == -EBUSY)
+ wake_up_if_idle(cpu);
+ }
} else if (task->patch_state != klp_target_state) {
/* offline idle tasks can be switched immediately */
clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
Best Regards,
Petr