From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darren Hart Subject: Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex Date: Mon, 21 Jul 2014 10:41:09 -0700 Message-ID: References: <1405956271-34339-1-git-send-email-Waiman.Long@hp.com> <8761iq3bp3.fsf@tassilo.jf.intel.com> <871tte3bjw.fsf@tassilo.jf.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Andi Kleen , Waiman Long Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Davidlohr Bueso , Heiko Carstens , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jason Low , Scott J Norton List-Id: linux-api@vger.kernel.org On 7/21/14, 10:20, "Darren Hart" wrote: >On 7/21/14, 9:45, "Andi Kleen" wrote: > >>Andi Kleen writes: >> >>> Waiman Long writes: >>> >>>> This patch series introduces two new futex command codes to support >>>> a new optimistic spinning futex for implementing an exclusive lock >>>> primitive that should perform better than the same primitive using >>>> the wait-wake futex in cases where the lock owner is actively working >>>> instead of waiting for I/O completion. >>> >>> How would you distinguish those two cases automatically? >> >>Also BTW traditionally the spinning was just done in user space. >> >>This would be always even more efficient, because it would >>even avoid the syscall entry path. >> >>Given the glibc adaptive mutexes are not very good, but I'm sure those >>could be improved. > >I presented on something along these lines a few years back, and various >people have asked for the sample code over the years. Andi is right, >doing >this from user-space has the potential to be more efficient, the >challenge >is getting access to privileged information, such as the state of the >mutex owner. You don't want to spin if the owner is sleeping. I did this >by adding a tidrunning call to the vdso. My somewhat hacked solution is >still available here: > >http://git.infradead.org/users/dvhart/linux.git/shortlog/refs/heads/futex/ >t >idrunning/dev > > >I abandoned the spinning in the kernel thing due to the overhead of the >system call if I remember correctly. Also available here: > >http://git.infradead.org/users/dvhart/linux.git/shortlog/refs/heads/futex/ >f >utex-lock-adaptive > And the associated Linux Plumbers 2010 presentation which I can't seem to find archived anywhere else: http://dvhart.com/darren/files/kernel-assisted-userspace-adaptive-mutexes.p df We observed some significant improvements under some very specific use cases, but a more thorough dive into performance impact in the other cases as well as security implications with the vdso is still wanting. -- Darren Hart Open Source Technology Center darren.hart-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org Intel Corporation