From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252Ab3LTTaS (ORCPT ); Fri, 20 Dec 2013 14:30:18 -0500 Received: from g5t0009.atlanta.hp.com ([15.192.0.46]:28001 "EHLO g5t0009.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751514Ab3LTTaP (ORCPT ); Fri, 20 Dec 2013 14:30:15 -0500 Message-ID: <1387567810.2704.19.camel@buesod1.americas.hpqcorp.net> Subject: Re: [PATCH v3 4/4] futex: Avoid taking hb lock if nothing to wakeup From: Davidlohr Bueso To: Linus Torvalds Cc: Linux Kernel Mailing List , Ingo Molnar , Darren Hart , Peter Zijlstra , Thomas Gleixner , Paul McKenney , Mike Galbraith , Jeff Mahoney , Jason Low , Waiman Long , Tom Vaden , "Norton, Scott J" , "Chandramouleeswaran, Aswin" , Ingo Molnar Date: Fri, 20 Dec 2013 11:30:10 -0800 In-Reply-To: References: <1387478746-5436-1-git-send-email-davidlohr@hp.com> <1387478746-5436-5-git-send-email-davidlohr@hp.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.6.4 (3.6.4-3.fc18) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2013-12-19 at 15:14 -0800, Linus Torvalds wrote: > > So I still think this can be done without that new counter field, or > any new atomics. > > hb_waiters_pending() could be something like > > spin_contended(hb->lock) || !list_empty(&hb->chain) > > which considering where you increment the new count should be > equivalent to your "!!hb->waiters". The smp_mb_after_atomic_inc()" on > the spinlock side would become smp_mb_after_spin_lock() instead. So we'd need the barrier right after the ticket increment (ie: the xadd TICKET_LOCK_INC in x86), and cannot rely on the barrier after the lock is taken as we could miss waiters that are just spinning trying to take it. Is this implicitly guaranteed across all archs? Thanks, Davidlohr