From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: [PATCH v3 01/29] asm-generic: add generic futex for !CONFIG_SMP Date: Tue, 23 Sep 2014 23:47:59 +0200 (CEST) Message-ID: References: <1410168160-3624-1-git-send-email-lftan@altera.com> <1410168160-3624-2-git-send-email-lftan@altera.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: In-Reply-To: Sender: linux-doc-owner@vger.kernel.org To: "LF.Tan" Cc: Linux-Arch , "linux-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , Arnd Bergmann , Ley Foon Tan , Chung-Lin Tang List-Id: linux-arch.vger.kernel.org On Tue, 23 Sep 2014, LF.Tan wrote: > On Mon, Sep 8, 2014 at 5:22 PM, Ley Foon Tan 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? Thanks, tglx From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from www.linutronix.de ([62.245.132.108]:50257 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756593AbaIWVsE (ORCPT ); Tue, 23 Sep 2014 17:48:04 -0400 Date: Tue, 23 Sep 2014 23:47:59 +0200 (CEST) From: Thomas Gleixner Subject: Re: [PATCH v3 01/29] asm-generic: add generic futex for !CONFIG_SMP In-Reply-To: Message-ID: References: <1410168160-3624-1-git-send-email-lftan@altera.com> <1410168160-3624-2-git-send-email-lftan@altera.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-arch-owner@vger.kernel.org List-ID: To: "LF.Tan" Cc: Linux-Arch , "linux-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , Arnd Bergmann , Ley Foon Tan , Chung-Lin Tang Message-ID: <20140923214759.Qgm82WcGpYpT7nAJ3m_VAz15o1geod0YnPgXbcqpgwA@z> On Tue, 23 Sep 2014, LF.Tan wrote: > On Mon, Sep 8, 2014 at 5:22 PM, Ley Foon Tan 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? Thanks, tglx