public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: + lock_page_killable-avoid-lost-wakeups.patch added to -mm tree
@ 2009-01-17 21:51 Oleg Nesterov
  2009-01-18  1:38 ` [PATCH v3] wait: prevent waiter starvation in __wait_on_bit_lock Johannes Weiner
  0 siblings, 1 reply; 28+ messages in thread
From: Oleg Nesterov @ 2009-01-17 21:51 UTC (permalink / raw)
  To: Chris Mason
  Cc: Peter Zijlstra, Matthew Wilcox, Chuck Lever, Nick Piggin,
	Andrew Morton, linux-kernel

I think the patch is correct, just a question,

>  int __lock_page_killable(struct page *page)
>  {
>  	DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
> +	int ret;
>
> -	return __wait_on_bit_lock(page_waitqueue(page), &wait,
> +	ret = __wait_on_bit_lock(page_waitqueue(page), &wait,
>  					sync_page_killable, TASK_KILLABLE);
> +	/*
> +	 * wait_on_bit_lock uses prepare_to_wait_exclusive, so if multiple
> +	 * procs were waiting on this page, we were the only proc woken up.
> +	 *
> +	 * if ret != 0, we didn't actually get the lock.  We need to
> +	 * make sure any other waiters don't sleep forever.
> +	 */
> +	if (ret)
> +		wake_up_page(page, PG_locked);

This patch assumes that nobody else calls __wait_on_bit_lock() with
action which can return !0. Currently this is correct, but perhaps
it makes sense to move this wake_up_page() into __wait_on_bit_lock ?

Note that we need to "transfer" the wakeup only if wake_up_page()
has already removed us from page_waitqueue(page), this means we
don't need to check ret != 0 twice in __wait_on_bit_lock(), afaics
we can do

	if ((ret = (*action)(q->key.flags))) {
		__wake_up_bit(wq, q->key.flags, q->key.bit_nr);
		// or just __wake_up(wq, TASK_NORMAL, 1, &q->key);
		break;
	}

IOW, imho __wait_on_bit_lock() is buggy, not __lock_page_killable(),
no?

Oleg.


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

end of thread, other threads:[~2009-02-02 15:49 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17 21:51 + lock_page_killable-avoid-lost-wakeups.patch added to -mm tree Oleg Nesterov
2009-01-18  1:38 ` [PATCH v3] wait: prevent waiter starvation in __wait_on_bit_lock Johannes Weiner
2009-01-18  2:32   ` Oleg Nesterov
2009-01-20 20:31     ` Johannes Weiner
2009-01-21 14:36       ` Oleg Nesterov
2009-01-21 21:38         ` [RFC v4] " Johannes Weiner
2009-01-22 20:25           ` Oleg Nesterov
2009-01-23  0:26             ` Dmitry Adamushko
2009-01-23  0:47               ` Oleg Nesterov
2009-01-23 10:07                 ` Dmitry Adamushko
2009-01-23 11:05                   ` Oleg Nesterov
2009-01-23 12:36                     ` Dmitry Adamushko
2009-01-23  9:59             ` Johannes Weiner
2009-01-23 11:35               ` Oleg Nesterov
2009-01-23 13:30                 ` Oleg Nesterov
2009-01-26 21:59                   ` [RFC v5] wait: prevent exclusive waiter starvation Johannes Weiner
2009-01-27  3:23                     ` Oleg Nesterov
2009-01-27 19:34                       ` [RFC v6] " Johannes Weiner
2009-01-27 20:05                         ` Oleg Nesterov
2009-01-27 22:31                           ` Johannes Weiner
2009-01-28  9:14                           ` [RFC v7] " Johannes Weiner
2009-01-29  4:42                             ` Oleg Nesterov
2009-01-29  7:37                               ` Andrew Morton
2009-01-29  8:31                                 ` Oleg Nesterov
2009-01-29  9:11                                   ` Andrew Morton
2009-01-29 14:34                                     ` Chris Mason
2009-02-02 15:47                                       ` Chris Mason
2009-01-23 19:24                 ` [RFC v4] wait: prevent waiter starvation in __wait_on_bit_lock Johannes Weiner

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