Re: [PATCH] mm: filemap: Avoid unnecessary barries and waitqueue lookups in unlock_page fastpath v4

From: Peter Zijlstra
Date: Thu May 15 2014 - 09:30:10 EST


On Thu, May 15, 2014 at 03:20:58PM +0200, Peter Zijlstra wrote:
> void __unlock_page(struct page *page)
> {
> struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(&page->flags, PG_locked);
> struct wait_queue_head_t *wqh = page_waitqueue(page);
> wait_queue_t *curr;

if (!PG_waiters && !waitqueue_active(wqh))
return;

> spin_lock_irq(&wqh->lock);
> list_for_each_entry(curr, &wqh->task_list, task_list) {
> unsigned int flags = curr->flags;
>
> if (curr->func(curr, TASK_NORMAL, 0, &key))
> goto unlock;
> }
> ClearPageWaiters(page);
> unlock:
> spin_unlock_irq(&wqh->lock);
> }
>
> Yes, the __unlock_page() will have the unconditional wqh->lock, but it
> should also call __unlock_page() a lot less, and it doesn't have that
> horrid timeout.
>
> Now, the above is clearly sub-optimal when !extended_page_flags, but I
> suppose we could have two versions of __unlock_page() for that.

Or I suppose the above would fix it too.

Attachment: pgpjRDwDh_xe_.pgp
Description: PGP signature