Messages in this thread | | | Date | Thu, 27 Nov 2008 21:13:58 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH] poll: allow f_op->poll to sleep, take#5 |
| |
On 11/26, Davide Libenzi wrote: > > w1) WR dev->events > w2) WR triggered (1) > w3) WMB > w4) WR task->state (RUNNING) > ... > That is, an MB before w3 (triggered=1) and a set_mb(triggered,0) at > s5+s6. The spinlock on the queue taken before entering pollwake() is not > enough to guarantee the required ordering, since a LOCK is no guarantee > that operations before it are visible after the LOCK. > Without the MB at w2, it could happen [w3, s5, s7, w1] that will make us > miss the event *and* sleep.
I think you are very right. Actually, this is just like
W: fill_data(&DATA); wmb(); DATA_is_ready = 1; // triggered wake_up(wq);
S: set_current_state(state); if (DATA_is_ready) ret = poll(&DATA); else schedule();
without wmb() above poll(&DATA) can obviously return the wrong value.
Oleg.
| |