Re: [rfc] optimise unlock_page



On Wed, May 09, 2007 at 07:30:27AM +1000, Benjamin Herrenschmidt wrote:
On Tue, 2007-05-08 at 13:40 +0200, Nick Piggin wrote:
This patch trades a page flag for a significant improvement in the unlock_page
fastpath. Various problems in the previous version were spotted by Hugh and
Ben (and fixed in this one).

Comments?

--

Speed up unlock_page by introducing a new page flag to signal that there are
page waitqueue waiters for PG_locked. This means a memory barrier and a random
waitqueue hash cacheline load can be avoided in the fastpath when there is no
contention.

I'm not 100% familiar with the exclusive vs. non exclusive wait thingy
but wake_up_page() does __wake_up_bit() which calls __wake_up() with
nr_exclusive set to 1. Doesn't that mean that only one waiter will be
woken up ?

If that's the case, then we lose because we'll have clear PG_waiters but
only wake up one of them.

Waking them all would fix it but at the risk of causing other
problems... Maybe PG_waiters need to actually be a counter but if that
is the case, then it complicates things even more.

Any smart idea ?

It will wake up 1 exclusive waiter, but no limit on non exclusive waiters.
Hmm, but it won't wake up waiters behind the exclusive guy... maybe the
wake up code can check whether the waitqueue is still active after the
wakeup, and set PG_waiters again in that case?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [rfc] optimise unlock_page
    ... page waitqueue waiters for PG_locked. ... waitqueue hash cacheline load can be avoided in the fastpath when there is no ... It will wake up 1 exclusive waiter, but no limit on non exclusive waiters. ...
    (Linux-Kernel)
  • Re: MANUAL reset event from other primitives
    ... is an some thread wrappers for compatibility with the old Mac OS ... all waiters, or something like that. ... semaphore, but there still seems to be a gap I can't fill. ... event raises the semaphore enough to wake everyone up. ...
    (comp.programming.threads)
  • Re: MANUAL reset event from other primitives
    ... The only thing in Carbon ... all waiters, or something like that. ... semaphore, but there still seems to be a gap I can't fill. ... event raises the semaphore enough to wake everyone up. ...
    (comp.programming.threads)
  • Re: [tip PATCH v6 8/8] RFC: futex: add requeue_pi calls
    ... rt_mutex prior to returning to userspace, and must wake it if it can ... so as to not leave the rt_mutex with waiters and no owner. ... get_futex_value_lockedfails? ... If the lock is still contended, ...
    (Linux-Kernel)
  • Re: [PATCH -v7][RFC]: mutex: implement adaptive spinning
    ... necessarily wake things up like it should. ... and then we check the waiters after that. ... slowpath (ie it wasn't just a normal "locked increment". ...
    (Linux-Kernel)

Loading