The previous patch lifted the deadline bandwidth check during the kexec process. As a result, DL tasks may be crowded onto the kexec CPU, which may starve the kexec task. At this point, the kexec task is the only task needed to make the reboot proceed, hence promoting it to a deadline task prevents this starvation.
Signed-off-by: Pingfan Liu <[email protected]> Cc: Waiman Long <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Pierre Gondois <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Baoquan He <[email protected]> To: [email protected] To: [email protected] --- kernel/kexec_core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 265de9d1ff5f5..0960bea1a8bab 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -41,6 +41,7 @@ #include <linux/objtool.h> #include <linux/kmsg_dump.h> #include <linux/dma-map-ops.h> +#include <uapi/linux/sched/types.h> #include <asm/page.h> #include <asm/sections.h> @@ -1183,6 +1184,20 @@ int kernel_kexec(void) } else #endif { + struct sched_attr attr = { + .size = sizeof(struct sched_attr), + .sched_policy = SCHED_DEADLINE, + .sched_nice = 0, + .sched_priority = 0, + /* + * Fake (unused) bandwidth; workaround to "fix" + * priority inheritance. + */ + .sched_runtime = NSEC_PER_MSEC, + .sched_deadline = 10 * NSEC_PER_MSEC, + .sched_period = 10 * NSEC_PER_MSEC, + }; + /* * CPU hot-removal path refers to kexec_in_progress, it * requires a sync to ensure no in-flight hot-removing. @@ -1202,6 +1217,13 @@ int kernel_kexec(void) */ cpu_hotplug_enable(); pr_notice("Starting new kernel\n"); + /* + * During hot-removing cpu, all DL tasks will be migrated to + * this cpu. To prevent this task from starving, promoting it + * to DL task. And soon, local interrupt will be disabled in + * machine_kexec(). + */ + sched_setattr_nocheck(current, &attr); machine_shutdown(); } -- 2.49.0
