Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched,livepatch: Use wake_up_if_idle()

Make sure to prod idle CPUs so they call klp_update_patch_state().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Tested-by: Petr Mladek <pmladek@suse.com>
Tested-by: Vasily Gorbik <gor@linux.ibm.com> # on s390
Link: https://lkml.kernel.org/r/20210929151723.162004989@infradead.org

+8 -1
+4
include/linux/sched/idle.h
··· 11 11 CPU_MAX_IDLE_TYPES 12 12 }; 13 13 14 + #ifdef CONFIG_SMP 14 15 extern void wake_up_if_idle(int cpu); 16 + #else 17 + static inline void wake_up_if_idle(int cpu) { } 18 + #endif 15 19 16 20 /* 17 21 * Idle thread specific functions to determine the need_resched
+4 -1
kernel/livepatch/transition.c
··· 413 413 for_each_possible_cpu(cpu) { 414 414 task = idle_task(cpu); 415 415 if (cpu_online(cpu)) { 416 - if (!klp_try_switch_task(task)) 416 + if (!klp_try_switch_task(task)) { 417 417 complete = false; 418 + /* Make idle task go through the main loop. */ 419 + wake_up_if_idle(cpu); 420 + } 418 421 } else if (task->patch_state != klp_target_state) { 419 422 /* offline idle tasks can be switched immediately */ 420 423 clear_tsk_thread_flag(task, TIF_PATCH_PENDING);