---

 include/linux/sched.h |    1 +
 kernel/futex.c        |    5 ++++-
 kernel/sched.c        |    9 +++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff -puN kernel/futex.c~futex-wakeup-debug kernel/futex.c
--- 25/kernel/futex.c~futex-wakeup-debug	2004-01-25 23:40:34.000000000 -0800
+++ 25-akpm/kernel/futex.c	2004-01-25 23:40:34.000000000 -0800
@@ -491,8 +491,11 @@ static int futex_wait(unsigned long uadd
 	 * !list_empty() is safe here without any lock.
 	 * q.lock_ptr != 0 is not safe, because of ordering against wakeup.
 	 */
-	if (likely(!list_empty(&q.list)))
+	if (likely(!list_empty(&q.list))) {
+		current->flags |= PF_FUTEX_DEBUG;
 		time = schedule_timeout(time);
+		current->flags &= ~PF_FUTEX_DEBUG;
+	}
 	__set_current_state(TASK_RUNNING);
 
 	/*
diff -puN include/linux/sched.h~futex-wakeup-debug include/linux/sched.h
--- 25/include/linux/sched.h~futex-wakeup-debug	2004-01-25 23:40:34.000000000 -0800
+++ 25-akpm/include/linux/sched.h	2004-01-25 23:40:34.000000000 -0800
@@ -500,6 +500,7 @@ do { if (atomic_dec_and_test(&(tsk)->usa
 #define PF_SWAPOFF	0x00080000	/* I am in swapoff */
 #define PF_LESS_THROTTLE 0x00100000	/* Throttle me less: I clean memory */
 #define PF_SYNCWRITE	0x00200000	/* I am doing a sync write */
+#define PF_FUTEX_DEBUG	0x00400000
 
 #ifdef CONFIG_SMP
 #define SD_FLAG_NEWIDLE		1	/* Balance when about to become idle */
diff -puN kernel/sched.c~futex-wakeup-debug kernel/sched.c
--- 25/kernel/sched.c~futex-wakeup-debug	2004-01-25 23:40:34.000000000 -0800
+++ 25-akpm/kernel/sched.c	2004-01-25 23:40:34.000000000 -0800
@@ -716,6 +716,15 @@ static int try_to_wake_up(task_t * p, un
 	runqueue_t *this_rq;
 #endif
 
+	if (p->flags & PF_FUTEX_DEBUG) {
+		if (!signal_pending(p)) {
+			printk("%s %i waking %s: %i %i\n",
+				current->comm, (int)in_interrupt(),
+				p->comm, p->tgid, p->pid);
+			WARN_ON(1);
+		}
+	}
+
 	rq = task_rq_lock(p, &flags);
 	old_state = p->state;
 	if (!(old_state & state))

_