From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: Re: [PATCH v10 07/19] qspinlock: Use a simple write to grab the lock, if applicable Date: Fri, 09 May 2014 21:05:25 -0400 Message-ID: <536D7B55.6030208@hp.com> References: <1399474907-22206-1-git-send-email-Waiman.Long@hp.com> <1399474907-22206-8-git-send-email-Waiman.Long@hp.com> <20140508190004.GO2844@laptop.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140508190004.GO2844@laptop.programming.kicks-ass.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Peter Zijlstra Cc: linux-arch@vger.kernel.org, Rik van Riel , Raghavendra K T , Oleg Nesterov , Gleb Natapov , kvm@vger.kernel.org, Konrad Rzeszutek Wilk , Scott J Norton , x86@kernel.org, Paolo Bonzini , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Ingo Molnar , Chegu Vinod , David Vrabel , "H. Peter Anvin" , xen-devel@lists.xenproject.org, Thomas Gleixner , "Paul E. McKenney" , Linus Torvalds , Boris Ostrovsky List-Id: linux-arch.vger.kernel.org On 05/08/2014 03:00 PM, Peter Zijlstra wrote: > On Wed, May 07, 2014 at 11:01:35AM -0400, Waiman Long wrote: >> @@ -94,23 +94,29 @@ static inline struct mcs_spinlock *decode_tail(u32 tail) >> * can allow better optimization of the lock acquisition for the pending >> * bit holder. >> */ >> -#if _Q_PENDING_BITS == 8 >> - >> struct __qspinlock { >> union { >> atomic_t val; >> - struct { >> #ifdef __LITTLE_ENDIAN >> + u8 locked; >> + struct { >> u16 locked_pending; >> u16 tail; >> + }; >> #else >> + struct { >> u16 tail; >> u16 locked_pending; >> -#endif >> }; >> + struct { >> + u8 reserved[3]; >> + u8 locked; >> + }; >> +#endif >> }; >> }; >> >> +#if _Q_PENDING_BITS == 8 > That doesn't make sense, that struct __qspinlock only makes sense when > _Q_PENDING_BITS == 8. I need to use the locked field (the 2nd strcut) in get_qlock() where I grab the lock by setting the lock byte directly. Since the endian-aware structure is already in place, I reused it and have to expose it even when _Q_PENDING_BITS isn't 8. I will document that more clearly in the code to avoid this confusion. -Longman From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g6t1526.atlanta.hp.com ([15.193.200.69]:58691 "EHLO g6t1526.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756507AbaEJBFu (ORCPT ); Fri, 9 May 2014 21:05:50 -0400 Message-ID: <536D7B55.6030208@hp.com> Date: Fri, 09 May 2014 21:05:25 -0400 From: Waiman Long MIME-Version: 1.0 Subject: Re: [PATCH v10 07/19] qspinlock: Use a simple write to grab the lock, if applicable References: <1399474907-22206-1-git-send-email-Waiman.Long@hp.com> <1399474907-22206-8-git-send-email-Waiman.Long@hp.com> <20140508190004.GO2844@laptop.programming.kicks-ass.net> In-Reply-To: <20140508190004.GO2844@laptop.programming.kicks-ass.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-arch@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Paolo Bonzini , Konrad Rzeszutek Wilk , Boris Ostrovsky , "Paul E. McKenney" , Rik van Riel , Linus Torvalds , Raghavendra K T , David Vrabel , Oleg Nesterov , Gleb Natapov , Scott J Norton , Chegu Vinod Message-ID: <20140510010525.lPGJHNFsF1jkOY1XAfwjfLRnZUe4P_-3hjxFJAcuF98@z> On 05/08/2014 03:00 PM, Peter Zijlstra wrote: > On Wed, May 07, 2014 at 11:01:35AM -0400, Waiman Long wrote: >> @@ -94,23 +94,29 @@ static inline struct mcs_spinlock *decode_tail(u32 tail) >> * can allow better optimization of the lock acquisition for the pending >> * bit holder. >> */ >> -#if _Q_PENDING_BITS == 8 >> - >> struct __qspinlock { >> union { >> atomic_t val; >> - struct { >> #ifdef __LITTLE_ENDIAN >> + u8 locked; >> + struct { >> u16 locked_pending; >> u16 tail; >> + }; >> #else >> + struct { >> u16 tail; >> u16 locked_pending; >> -#endif >> }; >> + struct { >> + u8 reserved[3]; >> + u8 locked; >> + }; >> +#endif >> }; >> }; >> >> +#if _Q_PENDING_BITS == 8 > That doesn't make sense, that struct __qspinlock only makes sense when > _Q_PENDING_BITS == 8. I need to use the locked field (the 2nd strcut) in get_qlock() where I grab the lock by setting the lock byte directly. Since the endian-aware structure is already in place, I reused it and have to expose it even when _Q_PENDING_BITS isn't 8. I will document that more clearly in the code to avoid this confusion. -Longman