From: Oleg Nesterov <oleg@redhat.com>
To: Tejun Heo <tj@kernel.org>
Cc: 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>,
Davide Libenzi <davidel@xmailserver.org>,
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@vger.kernel.org
Subject: Re: + poll-allow-f_op-poll-to-sleep-take-4.patch added to -mm tree
Date: Tue, 25 Nov 2008 18:30:32 +0100 [thread overview]
Message-ID: <20081125173032.GA21539@redhat.com> (raw)
Hi!
Minor question about mbs, just trying to understand the patch...
> +static int pollwake(wait_queue_t *wait, unsigned mode, int sync, void *key)
> +{
> + struct poll_wqueues *pwq = wait->private;
> + DECLARE_WAITQUEUE(dummy_wait, pwq->polling_task);
> +
> + set_mb(pwq->triggered, 1);
> +
> + /*
> + * Perform the default wake up operation using a dummy
> + * waitqueue.
> + *
> + * TODO: This is hacky but there currently is no interface to
> + * pass in @sync. @sync is scheduled to be removed and once
> + * that happens, wake_up_process() can be used directly.
> + */
> + return default_wake_function(&dummy_wait, mode, sync, key);
> +}
> +
> +int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
> + ktime_t *expires, unsigned long slack)
> +{
> + int rc = -EINTR;
> +
> + set_current_state(state);
> + if (!pwq->triggered)
> + rc = schedule_hrtimeout_range(expires, slack, HRTIMER_MODE_ABS);
> + __set_current_state(TASK_RUNNING);
So, why do we need this mb() in pollwake() ?
try_to_wake_up() has a full barrier semantics, note the wmb() before
task_rq_lock(). Since spin_lock() itself is STORE, the setting of
pwq->triggered can't be further re-ordered with the reading of p->state.
Or any other reason ?
> + /* clear triggered for the next iteration */
> + pwq->triggered = 0;
And don't we (in theory) actually need the mb() here instead?
Let's suppose do_poll() starts the next iteration, so we are doing
pwq->triggered = 0;
->poll(file)
if (!check_file(file))
return 0;
return POLLXXX;
We don't have any barriers in between (unless fget_light bumps
->f_count), so this can be reordered as
->poll(file)
if (!check_file(file))
return 0;
pwq->triggered = 0;
And, if pollwake() happens in between we can miss the event, no?
Oleg.
next reply other threads:[~2008-11-25 17:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-25 17:30 Oleg Nesterov [this message]
2008-11-25 21:08 ` + poll-allow-f_op-poll-to-sleep-take-4.patch added to -mm tree 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
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=20081125173032.GA21539@redhat.com \
--to=oleg@redhat.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=rminnich@sandia.gov \
--cc=roland@redhat.com \
--cc=tj@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox