Skip to contentSkip to conversation

smp fix for recalc_task_prio()

PATCH In review Mike Galbraith 1 participant 2 messages Mar 18, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smp fix for recalc_task_prio()

Greetings,

The patchlet below fixes an smp buglet where a task goes to sleep on one cpu and wakes up on another, causing recalc_task_prio() to be called with now < p->timestamp.

If this isn't 2.6.16 material, and I can respin against mm.

-Mike

kernel/sched.c renamed from kernel/sched.c.org +10 -0
@@ -685,6 +685,16 @@
 	unsigned long long __sleep_time = now - p->timestamp;
 	unsigned long sleep_time;
 
+	/*
+	 * On SMP systems, a task can go to sleep on one CPU and
+	 * wake up on another.  When this happens, the timestamp
+	 * is rounded to the nearest tick, which can lead to now
+	 * being less than p->timestamp for short sleeps. Ignore
+	 * these, they're insignificant.
+	 */
+	if (unlikely(now < p->timestamp))
+		__sleep_time = 0ULL;
+
 	if (unlikely(p->policy == SCHED_BATCH))
 		sleep_time = 0;
 	else {
#1 lore raw
Quoted 7 lines · Mike Galbraith

Greetings,

The patchlet below fixes an smp buglet where a task goes to sleep on one cpu and wakes up on another, causing recalc_task_prio() to be called with now < p->timestamp.

If this isn't 2.6.16 material, and I can respin against mm.

Sigh. Forgot sob line.

-Mike

kernel/sched.c renamed from kernel/sched.c.org +10 -0
@@ -685,6 +685,16 @@
 	unsigned long long __sleep_time = now - p->timestamp;
 	unsigned long sleep_time;
 
+	/*
+	 * On SMP systems, a task can go to sleep on one CPU and
+	 * wake up on another.  When this happens, the timestamp
+	 * is rounded to the nearest tick, which can lead to now
+	 * being less than p->timestamp for short sleeps. Ignore
+	 * these, they're insignificant.
+	 */
+	if (unlikely(now < p->timestamp))
+		__sleep_time = 0ULL;
+
 	if (unlikely(p->policy == SCHED_BATCH))
 		sleep_time = 0;
 	else {