lkml.org 
[lkml]   [2014]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v3 01/29] asm-generic: add generic futex for !CONFIG_SMP
From
On Wed, Sep 24, 2014 at 5:47 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Tue, 23 Sep 2014, LF.Tan wrote:
>> On Mon, Sep 8, 2014 at 5:22 PM, Ley Foon Tan <lftan@altera.com> wrote:
>> > Follow m68k futex implementation for !CONFIG_SMP.
>
> Great. Follow arch/random implementation blindly and copy all the bugs
> in it.
>
>> > +static inline int
>> > +futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
>> > + u32 oldval, u32 newval)
>> > +{
>> > + u32 val;
>> > +
>> > + if (unlikely(get_user(val, uaddr) != 0))
>> > + return -EFAULT;
>> > +
>> > + if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
>> > + return -EFAULT;
>> > +
>> > + *uval = val;
>> > +
>> > + return 0;
>> > +}
>
> Care to explain how this works reliably and resembles proper cmpxchg
> semantics under all circumstances?

kernel/futex.c:cmpxchg_futex_value_locked() is already called to
pagefault_disable() before call to futex_atomic_cmpxchg_inatomic().
For UP kernel and pagefault_disable() also means there is no preemption.

Regards
Ley Foon


\
 
 \ /
  Last update: 2014-09-24 13:01    [W:1.077 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site