Commit 1e955536 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix possible busywait in rtc_read()

If two processes are waiting in rtc_read(), only one will get the data.  The
other will madly spin around theloop in state TASK_RUNNING until another
interrupt happens.

Fix it by resetting TASK_INTERRUPTIBLE _inside_ the retry loop.
parent b04ed0ee
......@@ -284,12 +284,13 @@ static ssize_t rtc_read(struct file *file, char *buf,
add_wait_queue(&rtc_wait, &wait);
current->state = TASK_INTERRUPTIBLE;
do {
/* First make it right. Then make it fast. Putting this whole
* block within the parentheses of a while would be too
* confusing. And no, xchg() is not the answer. */
__set_current_state(TASK_INTERRUPTIBLE);
spin_lock_irq (&rtc_lock);
data = rtc_irq_data;
rtc_irq_data = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment