Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758242AbbDWSmO (ORCPT ); Thu, 23 Apr 2015 14:42:14 -0400 Received: from g2t2353.austin.hp.com ([15.217.128.52]:44079 "EHLO g2t2353.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755104AbbDWSmK (ORCPT ); Thu, 23 Apr 2015 14:42:10 -0400 Message-ID: <55393CD9.2060703@hp.com> Date: Thu, 23 Apr 2015 14:41:29 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: Peter Zijlstra CC: Ingo Molnar , linux-kernel@vger.kernel.org, Jason Low , Scott J Norton , Douglas Hatch Subject: Re: [PATCH] locking/rwsem: reduce spinlock contention in wakeup after up_read/up_write References: <1429322598-44362-1-git-send-email-Waiman.Long@hp.com> <20150418154014.GV27490@worktop.programming.kicks-ass.net> In-Reply-To: <20150418154014.GV27490@worktop.programming.kicks-ass.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1682 Lines: 43 On 04/18/2015 11:40 AM, Peter Zijlstra wrote: > On Fri, Apr 17, 2015 at 10:03:18PM -0400, Waiman Long wrote: >> @@ -478,7 +515,28 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem) >> { >> unsigned long flags; >> >> - raw_spin_lock_irqsave(&sem->wait_lock, flags); >> + /* >> + * If a spinner is present, it is not necessary to do the wakeup. >> + * Try to do wakeup only if the trylock succeeds to minimize >> + * spinlock contention which may introduce too much delay in the >> + * unlock operation. >> + * >> + * In case the spinning writer is just going to break out of the >> + * waiting loop, it will still do a trylock in >> + * rwsem_down_write_failed() before sleeping. >> + * IOW, if rwsem_has_spinner() is true, it will guarantee at least >> + * one trylock attempt on the rwsem. > successful trylock? I think we're having 'issues' on if failed trylocks > (and cmpxchg) imply full barriers. > >> + * >> + * spinning writer >> + * --------------- >> + * [S] osq_unlock() >> + * MB >> + * [RmW] rwsem_try_write_lock() >> + */ > Ordering comes in pairs, this is incomplete. I am sorry that I am a bit sloppy here. I have just sent out an updated patch to remedy this. I have added a smp_mb__after_atomic() to ensure proper memory ordering. However, I am not so sure if this primitive or just a simple smp_rmb() will be more expensive in other non-x86 architectures. Cheers, Longman -- 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/