[PATCH 1/10] random pt2: cleanup waitqueue logic, fix missed wakeup

From: Matt Mackall
Date: Fri Jan 14 2005 - 19:52:37 EST


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@xxxxxxxxxxx>

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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/