public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: [2/3] filtered buffer_head wakeups
Date: Tue, 4 May 2004 23:11:21 -0700	[thread overview]
Message-ID: <20040505061121.GX1397@holomorphy.com> (raw)
In-Reply-To: <20040505060849.GW1397@holomorphy.com>

On Tue, May 04, 2004 at 11:08:49PM -0700, William Lee Irwin III wrote:
> Precisely the same filtered wakeups for pages as before. Drop in a
> fresh wakeup primitive that uses a key to discriminate between the
> waiters for different objects on a hashed waitqueue, and make the
> page waiting functions use it.

Now, make bh's use the new wakeup primitive also. This has the bugfix
vs. the prior version that autoremoved waitqueue wakeup functions are
made to match autoremove API usage in __wait_event_filtered().


-- wli

Index: wake-2.6.6-rc3-mm1/fs/buffer.c
===================================================================
--- wake-2.6.6-rc3-mm1.orig/fs/buffer.c	2004-04-30 15:06:46.000000000 -0700
+++ wake-2.6.6-rc3-mm1/fs/buffer.c	2004-05-04 13:16:16.000000000 -0700
@@ -74,7 +74,7 @@
 
 	smp_mb();
 	if (waitqueue_active(wq))
-		wake_up_all(wq);
+		wake_up_filtered(wq, bh);
 }
 EXPORT_SYMBOL(wake_up_buffer);
 
@@ -93,10 +93,10 @@
 void __wait_on_buffer(struct buffer_head * bh)
 {
 	wait_queue_head_t *wqh = bh_waitq_head(bh);
-	DEFINE_WAIT(wait);
+	DEFINE_FILTERED_WAIT(wait, bh);
 
 	do {
-		prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
+		prepare_to_wait(wqh, &wait.wait, TASK_UNINTERRUPTIBLE);
 		if (buffer_locked(bh)) {
 			struct block_device *bd;
 			smp_mb();
@@ -106,7 +106,7 @@
 			io_schedule();
 		}
 	} while (buffer_locked(bh));
-	finish_wait(wqh, &wait);
+	finish_wait(wqh, &wait.wait);
 }
 
 static void
Index: wake-2.6.6-rc3-mm1/fs/jbd/transaction.c
===================================================================
--- wake-2.6.6-rc3-mm1.orig/fs/jbd/transaction.c	2004-04-30 15:06:46.000000000 -0700
+++ wake-2.6.6-rc3-mm1/fs/jbd/transaction.c	2004-05-04 13:16:16.000000000 -0700
@@ -638,7 +638,7 @@
 			jbd_unlock_bh_state(bh);
 			/* commit wakes up all shadow buffers after IO */
 			wqh = bh_waitq_head(jh2bh(jh));
-			wait_event(*wqh, (jh->b_jlist != BJ_Shadow));
+			wait_event_filtered(*wqh, jh2bh(jh), (jh->b_jlist != BJ_Shadow));
 			goto repeat;
 		}
 
Index: wake-2.6.6-rc3-mm1/include/linux/wait.h
===================================================================
--- wake-2.6.6-rc3-mm1.orig/include/linux/wait.h	2004-05-04 13:16:00.000000000 -0700
+++ wake-2.6.6-rc3-mm1/include/linux/wait.h	2004-05-04 13:16:27.000000000 -0700
@@ -146,7 +146,6 @@
 		break;							\
 	__wait_event(wq, condition);					\
 } while (0)
-
 #define __wait_event_interruptible(wq, condition, ret)			\
 do {									\
 	wait_queue_t __wait;						\
@@ -273,7 +272,28 @@
 			.task_list = LIST_HEAD_INIT(name.wait.task_list),\
 		},							\
 	}
-	
+
+#define __wait_event_filtered(wq, key, condition) 			\
+do {									\
+	DEFINE_FILTERED_WAIT(__wait, key);				\
+	wait_queue_head_t *__wqh = &(wq);				\
+	wait_queue_t *__wqe = &__wait.wait;				\
+	for (;;) {							\
+		prepare_to_wait(__wqh, __wqe, TASK_UNINTERRUPTIBLE);	\
+		if (condition)						\
+			break;						\
+		schedule();						\
+	}								\
+	finish_wait(__wqh, __wqe);					\
+} while (0)
+
+
+#define wait_event_filtered(wq, key, condition)				\
+do {									\
+	if (!(condition))						\
+		__wait_event_filtered(wq, key, condition);		\
+} while (0)
+
 #endif /* __KERNEL__ */
 
 #endif

  reply	other threads:[~2004-05-05  6:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-05  6:06 [0/3] filtered wakeups respun William Lee Irwin III
2004-05-05  6:08 ` William Lee Irwin III
2004-05-05  6:11   ` William Lee Irwin III [this message]
2004-05-05  6:16     ` [3/3] wake-one PG_locked/BH_Lock semantics William Lee Irwin III
2004-05-05  6:42       ` Michael J. Cohen
2004-05-05  9:29         ` Michael J. Cohen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040505061121.GX1397@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox