lkml.org 
[lkml]   [2014]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/1] mm: fix the theoretical compound_lock() vs prep_new_page() race
On Fri, Jan 10, 2014 at 05:12:27PM +0100, Oleg Nesterov wrote:
> The recent "[PATCH v6 tip/core/locking 3/8] Documentation/memory-barriers.txt:
> Prohibit speculative writes" from Paul says:
>
> No SMP architecture currently supporting Linux allows speculative writes,
>
> ...
>
> +ACCESS_ONCE(), which preserves the ordering between
> +the load from variable 'a' and the store to variable 'b':
> +
> + q = ACCESS_ONCE(a);
> + if (q) {
> + ACCESS_ONCE(b) = p;
> + do_something();
> + }
>
>
> We can't use ACCESS_ONCE(), but I think that
>
> if (PageTail(page)) {
> barrier();
> compound_lock(page_head);
> }
>
> should obviously work (even if compound_lock() didn't imply mb).

The compiler can actually screw you over if that's preceded by something
like: SetPageTail(page). In which case it can prove that if (PageTail())
is a non-condition.

But yes, barring that, the version with barrier() in should stop the
compiler from doing most terrible things and it ought to work out.


\
 
 \ /
  Last update: 2014-01-10 18:21    [W:0.151 / U:1.688 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site