Thread (26 messages) 26 messages, 5 authors, 2021-09-27

Re: [RFC][PATCH 5/7] sched,livepatch: Use wake_up_if_idle()

From: Petr Mladek <pmladek@suse.com>
Date: 2021-09-23 12:19:22
Also in: lkml

On Wed 2021-09-22 15:05:03, Miroslav Benes wrote:
quoted
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help