From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755196Ab3LTIyw (ORCPT ); Fri, 20 Dec 2013 03:54:52 -0500 Received: from merlin.infradead.org ([205.233.59.134]:49640 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754589Ab3LTIyv (ORCPT ); Fri, 20 Dec 2013 03:54:51 -0500 Date: Fri, 20 Dec 2013 09:54:26 +0100 From: Peter Zijlstra To: Linus Torvalds Cc: Davidlohr Bueso , Linux Kernel Mailing List , Ingo Molnar , Darren Hart , Thomas Gleixner , Paul McKenney , Mike Galbraith , Jeff Mahoney , Jason Low , Waiman Long , Tom Vaden , "Norton, Scott J" , "Chandramouleeswaran, Aswin" , Ingo Molnar Subject: Re: [PATCH v3 4/4] futex: Avoid taking hb lock if nothing to wakeup Message-ID: <20131220085426.GZ21999@twins.programming.kicks-ass.net> References: <1387478746-5436-1-git-send-email-davidlohr@hp.com> <1387478746-5436-5-git-send-email-davidlohr@hp.com> <1387496569.8363.12.camel@buesod1.americas.hpqcorp.net> <1387506141.8363.47.camel@buesod1.americas.hpqcorp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 19, 2013 at 07:13:09PM -0800, Linus Torvalds wrote: > I think we might have to order the two reads with an smp_rmb - making > sure that we check the lock state first - but I think it should be > otherwise pretty solid. > Yeah, I said "spin_contended()" myself initially, but it needs to be > "spin_is_locked()". It's hopefully unlikely to ever actually be > contended (which in ticket lock terms is "head is _more_ than one away > from the tail"). Right, which would give us something like: LOCK m is_locked m list_{add,del} RMB UNLOCK m list_empty Where the rmb matches the release/unlock. This guarantees that when we see the unlock we must also see the list modification.