public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/10] random pt2: cleanup waitqueue logic, fix missed wakeup
@ 2005-01-15  0:49 Matt Mackall
  2005-01-15  0:49 ` [PATCH 2/10] random pt2: kill pool clearing Matt Mackall
  0 siblings, 1 reply; 10+ messages in thread
From: Matt Mackall @ 2005-01-15  0:49 UTC (permalink / raw)
  To: Andrew Morton, Theodore Ts'o; +Cc: linux-kernel

Original code checked in output pool for missed wakeup avoidance,
while waker (batch_entropy_process) checked input pool which could
result in a missed wakeup.

Move to wait_event_interruptible style
Delete superfluous waitqueue

Signed-off-by: Matt Mackall <mpm@selenic.com>

Index: rnd/drivers/char/random.c
===================================================================
--- rnd.orig/drivers/char/random.c	2005-01-12 21:27:58.178748133 -0800
+++ rnd/drivers/char/random.c	2005-01-12 21:27:58.951649596 -0800
@@ -1587,7 +1587,6 @@
 static ssize_t
 random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
 {
-	DECLARE_WAITQUEUE(wait, current);
 	ssize_t n, retval = 0, count = 0;
 
 	if (nbytes == 0)
@@ -1613,20 +1612,20 @@
 				retval = -EAGAIN;
 				break;
 			}
+
+			DEBUG_ENT("sleeping?\n");
+
+			wait_event_interruptible(random_read_wait,
+				random_state->entropy_count >=
+						 random_read_wakeup_thresh);
+
+			DEBUG_ENT("awake\n");
+
 			if (signal_pending(current)) {
 				retval = -ERESTARTSYS;
 				break;
 			}
 
-			set_current_state(TASK_INTERRUPTIBLE);
-			add_wait_queue(&random_read_wait, &wait);
-
-			if (sec_random_state->entropy_count / 8 == 0)
-				schedule();
-
-			set_current_state(TASK_RUNNING);
-			remove_wait_queue(&random_read_wait, &wait);
-
 			continue;
 		}
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-01-15  1:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-15  0:49 [PATCH 1/10] random pt2: cleanup waitqueue logic, fix missed wakeup Matt Mackall
2005-01-15  0:49 ` [PATCH 2/10] random pt2: kill pool clearing Matt Mackall
2005-01-15  0:49   ` [PATCH 3/10] random pt2: combine legacy ioctls Matt Mackall
2005-01-15  0:49     ` [PATCH 4/10] random pt2: re-init all pools on zero Matt Mackall
2005-01-15  0:49       ` [PATCH 5/10] random pt2: simplify initialization Matt Mackall
2005-01-15  0:49         ` [PATCH 6/10] random pt2: kill memsets of static data Matt Mackall
2005-01-15  0:49           ` [PATCH 7/10] random pt2: kill dead extract_state struct Matt Mackall
2005-01-15  0:49             ` [PATCH 8/10] random pt2: kill 2.2 compat waitqueue defs Matt Mackall
2005-01-15  0:49               ` [PATCH 9/10] random pt2: kill redundant rotate_left definitions Matt Mackall
2005-01-15  0:49                 ` [PATCH 10/10] random pt2: kill misnamed log2 Matt Mackall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox