lkml.org 
[lkml]   [2019]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/2] mm: introduce put_user_page*(), placeholder versions
On Tue, Jan 15, 2019 at 5:56 PM Jerome Glisse <jglisse@redhat.com> wrote:
> On Tue, Jan 15, 2019 at 04:44:41PM -0800, John Hubbard wrote:
[..]
> To make it clear.
>
> Lock code:
> GUP()
> ...
> lock_page(page);
> if (PageWriteback(page)) {
> unlock_page(page);
> wait_stable_page(page);
> goto retry;
> }
> atomic_add(page->refcount, PAGE_PIN_BIAS);
> unlock_page(page);
>
> test_set_page_writeback()
> bool pinned = false;
> ...
> pinned = page_is_pin(page); // could be after TestSetPageWriteback
> TestSetPageWriteback(page);
> ...
> return pinned;
>
> Memory barrier:
> GUP()
> ...
> atomic_add(page->refcount, PAGE_PIN_BIAS);
> smp_mb();
> if (PageWriteback(page)) {
> atomic_add(page->refcount, -PAGE_PIN_BIAS);
> wait_stable_page(page);
> goto retry;
> }
>
> test_set_page_writeback()
> bool pinned = false;
> ...
> TestSetPageWriteback(page);
> smp_wmb();
> pinned = page_is_pin(page);
> ...
> return pinned;
>
>
> One is not more complex than the other. One can contend, the other
> will _never_ contend.

The complexity is in the validation of lockless algorithms. It's
easier to reason about locks than barriers for the long term
maintainability of this code. I'm with Jan and John on wanting to
explore lock_page() before a barrier-based scheme.

\
 
 \ /
  Last update: 2019-01-16 03:01    [W:0.119 / U:22.312 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site