From 2ee50b65e1000c7b2cda3ec8a6092c174dec3343 Mon Sep 17 00:00:00 2001
From: Andrew Morton <akpm@digeo.com>
Date: Thu, 31 Oct 2002 20:00:56 -0800
Subject: [PATCH] [PATCH] faster wakeups in the pipe code

Use prepare_to-wait/finish_wait to avoid bouncing the waitqueue
spinlock between the waker and the wakee all the time.
---
 fs/pipe.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index 8fcd6c03cbb6..ae448b0b1aa6 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -34,13 +34,12 @@
 /* Drop the inode semaphore and wait for a pipe event, atomically */
 void pipe_wait(struct inode * inode)
 {
-	DECLARE_WAITQUEUE(wait, current);
-	current->state = TASK_INTERRUPTIBLE;
-	add_wait_queue(PIPE_WAIT(*inode), &wait);
+	DEFINE_WAIT(wait);
+
+	prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE);
 	up(PIPE_SEM(*inode));
 	schedule();
-	remove_wait_queue(PIPE_WAIT(*inode), &wait);
-	current->state = TASK_RUNNING;
+	finish_wait(PIPE_WAIT(*inode), &wait);
 	down(PIPE_SEM(*inode));
 }
 
-- 
2.30.9