Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbbFWIiR (ORCPT ); Tue, 23 Jun 2015 04:38:17 -0400 Received: from foss.arm.com ([217.140.101.70]:50440 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751443AbbFWIiA (ORCPT ); Tue, 23 Jun 2015 04:38:00 -0400 Date: Tue, 23 Jun 2015 09:37:56 +0100 From: Will Deacon To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Arnd Bergmann , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Scott J Norton , Douglas Hatch Subject: Re: [PATCH v5 3/3] locking/qrwlock: Don't contend with readers when setting _QW_WAITING Message-ID: <20150623083756.GD31504@arm.com> References: <1434729002-57724-1-git-send-email-Waiman.Long@hp.com> <1434729002-57724-4-git-send-email-Waiman.Long@hp.com> <20150622162123.GI1583@arm.com> <5588CB2C.108@hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5588CB2C.108@hp.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1798 Lines: 42 On Tue, Jun 23, 2015 at 03:57:48AM +0100, Waiman Long wrote: > On 06/22/2015 12:21 PM, Will Deacon wrote: > > On Fri, Jun 19, 2015 at 04:50:02PM +0100, Waiman Long wrote: > >> The current cmpxchg() loop in setting the _QW_WAITING flag for writers > >> in queue_write_lock_slowpath() will contend with incoming readers > >> causing possibly extra cmpxchg() operations that are wasteful. This > >> patch changes the code to do a byte cmpxchg() to eliminate contention > >> with new readers. > > [...] > > > >> diff --git a/arch/x86/include/asm/qrwlock.h b/arch/x86/include/asm/qrwlock.h > >> index a8810bf..5678b0a 100644 > >> --- a/arch/x86/include/asm/qrwlock.h > >> +++ b/arch/x86/include/asm/qrwlock.h > >> @@ -7,8 +7,7 @@ > >> #define queued_write_unlock queued_write_unlock > >> static inline void queued_write_unlock(struct qrwlock *lock) > >> { > >> - barrier(); > >> - ACCESS_ONCE(*(u8 *)&lock->cnts) = 0; > >> + smp_store_release(&lock->wmode, 0); > >> } > >> #endif > > I reckon you could actually use this in the asm-generic header and remove > > the x86 arch version altogether. Most architectures support single-copy > > atomic byte access and those that don't (alpha?) can just not use qrwlock > > (or override write_unlock with atomic_sub). > > > > I already have a patch making this change, so I'm happy either way. > > Yes, I am aware of that. If you have a patch to make that change, I am > fine with that too. Tell you what; I'll rebase my patches on top of yours and post them after the merge window. Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/