[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081127201358.GA19874@redhat.com>
Date: Thu, 27 Nov 2008 21:13:58 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Davide Libenzi <davidel@...ilserver.org>
Cc: Tejun Heo <htejun@...il.com>,
Eric Van Hensbergen <ericvh@...il.com>,
Ron Minnich <rminnich@...dia.gov>, Ingo Molnar <mingo@...e.hu>,
Christoph Hellwig <hch@...radead.org>,
Miklos Szeredi <mszeredi@...e.cz>,
Brad Boyer <flar@...andria.com>,
Al Viro <viro@...iv.linux.org.uk>,
Roland McGrath <roland@...hat.com>,
Mauro Carvalho Chehab <mchehab@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists