lkml.org 
[lkml]   [2011]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [RFC] get_write_access()/deny_write_access() without inode->i_lock
    Date
    Al Viro <viro@ZenIV.linux.org.uk> wrote:

    > + for (v = atomic_read(&inode->i_writecount); v >= 0; v = v1) {
    > + v1 = atomic_cmpxchg(&inode->i_writecount, v, v + 1);
    > + if (likely(v1 == v))
    > + return 0;
    > + }

    You don't need to reissue the atomic_read(). atomic_cmpxchg() returns the
    current value of the memory location. Just set v to v1 before going round the
    loop again.

    David


    \
     
     \ /
      Last update: 2011-06-20 14:49    [W:0.024 / U:0.776 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site