Re: -rt scheduling: wakeup bug?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Mike Kravetz <kravetz@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, Thomas Gleixner <tglx@...>, Steven Rostedt <rostedt@...>, Clark Williams <williams@...>
Date: Tuesday, October 2, 2007 - 1:06 am

hi Mike,

* Mike Kravetz <kravetz@us.ibm.com> wrote:


I believe you are right - nice catch of this very nontrivial bug! The 
patch below is against .23-rc - do you think this fix (of moving the rt 
wakeup sequence to after the activate_task()) is adequate?

	Ingo

Index: linux-rt-rebase.q/kernel/sched.c
===================================================================
--- linux-rt-rebase.q.orig/kernel/sched.c
+++ linux-rt-rebase.q/kernel/sched.c
@@ -1819,6 +1819,13 @@ out_set_cpu:
 		cpu = task_cpu(p);
 	}
 
+out_activate:
+#endif /* CONFIG_SMP */
+
+	activate_task(rq, p, 1);
+
+	trace_start_sched_wakeup(p, rq);
+
 	/*
 	 * If a newly woken up RT task cannot preempt the
 	 * current (RT) task (on a target runqueue) then try
@@ -1849,28 +1856,21 @@ out_set_cpu:
 			smp_send_reschedule_allbutself_cpumask(p->cpus_allowed);
 
 		schedstat_inc(this_rq, rto_wakeup);
-	}
-
-out_activate:
-#endif /* CONFIG_SMP */
-
-	activate_task(rq, p, 1);
-
-	trace_start_sched_wakeup(p, rq);
-
-	/*
-	 * Sync wakeups (i.e. those types of wakeups where the waker
-	 * has indicated that it will leave the CPU in short order)
-	 * don't trigger a preemption, if the woken up task will run on
-	 * this cpu. (in this case the 'I will reschedule' promise of
-	 * the waker guarantees that the freshly woken up task is going
-	 * to be considered on this CPU.)
-	 */
-	if (!sync || cpu != this_cpu)
-		check_preempt_curr(rq, p);
-	else {
-		if (TASK_PREEMPTS_CURR(p, rq))
-			set_tsk_need_resched_delayed(rq->curr);
+	} else {
+		/*
+		 * Sync wakeups (i.e. those types of wakeups where the waker
+		 * has indicated that it will leave the CPU in short order)
+		 * don't trigger a preemption, if the woken up task will run on
+		 * this cpu. (in this case the 'I will reschedule' promise of
+		 * the waker guarantees that the freshly woken up task is going
+		 * to be considered on this CPU.)
+		 */
+		if (!sync || cpu != this_cpu)
+			check_preempt_curr(rq, p);
+		else {
+			if (TASK_PREEMPTS_CURR(p, rq))
+				set_tsk_need_resched_delayed(rq->curr);
+		}
 	}
 	if (rq->curr && p && rq && _need_resched())
 		trace_special_pid(p->pid, PRIO(p), PRIO(rq->curr));
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
RT scheduling: wakeup bug?, Mike Kravetz, (Mon Oct 1, 6:15 pm)
Re: -rt scheduling: wakeup bug?, Ingo Molnar, (Tue Oct 2, 1:06 am)
Re: -rt scheduling: wakeup bug?, Mike Kravetz, (Wed Oct 3, 1:37 pm)
Re: -rt scheduling: wakeup bug?, Ingo Molnar, (Thu Oct 4, 4:02 am)
Re: -rt scheduling: wakeup bug?, Mike Kravetz, (Tue Oct 2, 3:30 pm)
Re: -rt scheduling: wakeup bug?, Steven Rostedt, (Tue Oct 2, 3:37 pm)