From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH] WAIT_BIT_QUEUE
Date: Mon, 10 May 2004 16:31:48 +0400 [thread overview]
Message-ID: <409F7634.D1834978@tv-sign.ru> (raw)
In-Reply-To: 20040510043010.0c9dd1e8.akpm@osdl.org
Andrew Morton wrote:
>
> Oleg Nesterov <oleg@tv-sign.ru> wrote:
> >
> > process waiting in wait_on_page_bit() will be woken only after
> > the required bit is cleared.
> >
> > so there is no need to recheck the bit in do/while loop, because
> > there is no false wakeups now.
>
> yup. Please see the new patches in 2.6.6-mm1 - the waiter puts the bit
> number into the waitqueue structure and the waker tests it before
> delivering the wakeup.
and it puts page or buffer_head in waitqueue instead of just flags.
> +static int page_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
> +{
> + struct page *page = key;
> + struct page_wait_queue *wq;
> +
> + wq = container_of(wait, struct page_wait_queue, wait);
> + if (wq->page != page || test_bit(wq->bit, &page->flags))
> + return 0;
> + else
> + return autoremove_wake_function(wait, mode, sync, NULL);
> +}
Why bother to check if (wq->page != page) ?
Yes, without this check waiting process can be waken _before_
wake_up_all(page_waitqueue(page)) but i see no problems here.
In fact, this can happen with clean kernel as well.
Let us suppose page_waitqueue(A) == page_waitqueue(B), and
we have two concurrent unlock_page() on these pages.
unlock_page(A) unlock_page(B)
TestClearPageLocked(A)
TestClearPageLocked(B)
wake_up_all(page_waitqueue(B)
wakes up process waiting for A,
it returns from wait_on_page_bit()
because !test_bit(bit_nr, &page->flags)
wake_up_all(page_waitqueue(A)
waiter already running.
So, I beleive, we need not key parameter in page_wake_function.
If we will put flags in waitqueue, bh_wake_function becomes identical
to page_wake_function, and we do not have to modify wakers at all,
there is no need to push page/buffer_head to wake_up().
So, new key parameter for wake_up becomes unneeded.
Oleg.
next prev parent reply other threads:[~2004-05-10 12:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-10 11:24 [PATCH] WAIT_BIT_QUEUE Oleg Nesterov
2004-05-10 11:30 ` Andrew Morton
2004-05-10 12:31 ` Oleg Nesterov [this message]
2004-05-10 14:55 ` Linus Torvalds
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=409F7634.D1834978@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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.