public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: + poll-allow-f_op-poll-to-sleep-take-4.patch added to -mm tree
@ 2008-11-25 17:30 Oleg Nesterov
  2008-11-25 21:08 ` Davide Libenzi
  2008-11-26  4:33 ` Tejun Heo
  0 siblings, 2 replies; 14+ messages in thread
From: Oleg Nesterov @ 2008-11-25 17:30 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Eric Van Hensbergen, Ron Minnich, Ingo Molnar, Christoph Hellwig,
	Miklos Szeredi, Davide Libenzi, Brad Boyer, Al Viro,
	Roland McGrath, Mauro Carvalho Chehab, Andrew Morton,
	linux-kernel

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.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-11-28 16:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox