On Mon, May 09, 2022 at 11:52:27AM -0400, Rik van Riel wrote: > Does this look like an approach that could work? > > ---8<--- > sched,livepatch: call stop_one_cpu in klp_check_and_switch_task > > If a running task fails to transition to the new kernel live patch after the > first attempt, use the stopper thread to preempt it during subsequent attempts > at switching to the new kernel live patch. > > <INSERT EXPERIMENTAL RESULTS HERE> It would be helpful to add more info about the original problem being solved, and how this is supposed to fix it. > +static int kpatch_dummy_fn(void *dummy) s/kpatch/klp/ > +{ > + return 0; > +} > + > /* > * Try to safely switch a task to the target patch state. If it's currently > * running, or it's sleeping on a to-be-patched or to-be-unpatched function, or > @@ -315,6 +321,9 @@ static bool klp_try_switch_task(struct task_struct *task) > case -EBUSY: /* klp_check_and_switch_task() */ > pr_debug("%s: %s:%d is running\n", > __func__, task->comm, task->pid); > + /* Preempt the task from the second KLP switch attempt. */ > + if (klp_signals_cnt) > + stop_one_cpu(task_cpu(task), kpatch_dummy_fn, NULL); I must be missing something, how is briefly preempting a kthread supposed to actually transition it? Won't it likely go back to running on the CPU before the next periodic klp_transition_work_fn() check? -- Josh