From: Tejun Heo <htejun@gmail.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
Eric Van Hensbergen <ericvh@gmail.com>,
Ron Minnich <rminnich@sandia.gov>, Ingo Molnar <mingo@elte.hu>,
Christoph Hellwig <hch@infradead.org>,
Miklos Szeredi <mszeredi@suse.cz>,
Brad Boyer <flar@allandria.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Roland McGrath <roland@redhat.com>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] poll: allow f_op->poll to sleep, take#5
Date: Thu, 27 Nov 2008 18:18:49 +0900 [thread overview]
Message-ID: <492E65F9.30208@gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.10.0811252313420.32523@alien.or.mcafeemobile.com>
Hello,
Davide Libenzi wrote:
> Hmmm, I just noticed that the set_current_state(TASK_INTERRUPTIBLE) at the
> beginning of the ->poll() loop has been dropped (and it makes sense since
> now ->poll() can sleep).
Yeah, that's exactly what the ->triggered condition replaces.
> w1) WR dev->events
> w2) MB
> w3) WR triggered (1)
> w4) WMB
> w5) WR task->state (RUNNING)
>
> Poller side:
>
> s1) WR task->state (TASK_INTERRUPTIBLE)
> s2) MB
> s3) RD triggered
> s4) IF0 => RD task->state (if !RUNNING -> sleep)
> s5) WR triggered (0)
> s6) MB
> s7) RD dev->events
>
> 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.
Yeah, it seems we'll need something which is equivalent to smp_wmb()
in try_to_wake_up(). So, the original set_mb() should have stayed
there while just adding the latter one. Will prep yet another take of
the patch. Thanks for the detailed analysis.
--
tejun
next prev parent reply other threads:[~2008-11-27 9:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-25 17:30 + poll-allow-f_op-poll-to-sleep-take-4.patch added to -mm tree Oleg Nesterov
2008-11-25 21:08 ` Davide Libenzi
2008-11-26 4:33 ` Tejun Heo
2008-11-26 4:40 ` [PATCH] poll: allow f_op->poll to sleep, take#5 Tejun Heo
2008-11-26 6:27 ` Davide Libenzi
2008-11-26 6:39 ` Tejun Heo
2008-11-26 19:36 ` Davide Libenzi
2008-11-27 9:18 ` Tejun Heo [this message]
2008-11-27 9:37 ` [PATCH] poll: allow f_op->poll to sleep, take#6 Tejun Heo
2008-11-28 4:35 ` Davide Libenzi
2008-11-28 4:44 ` Tejun Heo
2008-11-28 16:08 ` Oleg Nesterov
2008-11-27 20:13 ` [PATCH] poll: allow f_op->poll to sleep, take#5 Oleg Nesterov
2008-11-26 4:49 ` + poll-allow-f_op-poll-to-sleep-take-4.patch added to -mm tree Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=492E65F9.30208@gmail.com \
--to=htejun@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davidel@xmailserver.org \
--cc=ericvh@gmail.com \
--cc=flar@allandria.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=mingo@elte.hu \
--cc=mszeredi@suse.cz \
--cc=oleg@redhat.com \
--cc=rminnich@sandia.gov \
--cc=roland@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.