lkml.org 
[lkml]   [2020]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/12] mm: add support for async page locking
On Tue, May 26, 2020 at 01:51:15PM -0600, Jens Axboe wrote:
> +static int __wait_on_page_locked_async(struct page *page,
> + struct wait_page_queue *wait, bool set)
> +{
> + struct wait_queue_head *q = page_waitqueue(page);
> + int ret = 0;
> +
> + wait->page = page;
> + wait->bit_nr = PG_locked;
> +
> + spin_lock_irq(&q->lock);
> + if (set)
> + ret = !trylock_page(page);
> + else
> + ret = PageLocked(page);
> + if (ret) {
> + __add_wait_queue_entry_tail(q, &wait->wait);
> + SetPageWaiters(page);
> + if (set)
> + ret = !trylock_page(page);
> + else
> + ret = PageLocked(page);

Between the callers and this function, we actually look at PG_lock three
times; once in the caller, then after taking the spinlock, then after
adding ourselves to the waitqueue. I understand the first and third, but
is it really worth doing the second test? It feels unlikely to succeed
and only saves us setting PageWaiters.

\
 
 \ /
  Last update: 2020-06-01 16:27    [W:0.220 / U:11.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site