From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbcEKS4x (ORCPT ); Wed, 11 May 2016 14:56:53 -0400 Received: from g2t4619.austin.hp.com ([15.73.212.82]:40026 "EHLO g2t4619.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751875AbcEKS4w (ORCPT ); Wed, 11 May 2016 14:56:52 -0400 Message-ID: <1462992562.2488.26.camel@j-VirtualBox> Subject: Re: [PATCH] locking/rwsem: Optimize write lock slowpath From: Jason Low To: Davidlohr Bueso Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Scott J Norton , Waiman Long , peter@hurleysoftware.com, jason.low2@hpe.com Date: Wed, 11 May 2016 11:49:22 -0700 In-Reply-To: <20160511183328.GA10711@linux-uzut.site> References: <1462821397.2701.16.camel@j-VirtualBox> <20160511114918.GG3190@twins.programming.kicks-ass.net> <20160511183328.GA10711@linux-uzut.site> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 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 Wed, 2016-05-11 at 11:33 -0700, Davidlohr Bueso wrote: > On Wed, 11 May 2016, Peter Zijlstra wrote: > > >On Mon, May 09, 2016 at 12:16:37PM -0700, Jason Low wrote: > >> When acquiring the rwsem write lock in the slowpath, we first try > >> to set count to RWSEM_WAITING_BIAS. When that is successful, > >> we then atomically add the RWSEM_WAITING_BIAS in cases where > >> there are other tasks on the wait list. This causes write lock > >> operations to often issue multiple atomic operations. > >> > >> We can instead make the list_is_singular() check first, and then > >> set the count accordingly, so that we issue at most 1 atomic > >> operation when acquiring the write lock and reduce unnecessary > >> cacheline contention. > >> > >> Signed-off-by: Jason Low > > Acked-by: Davidlohr Bueso > > (one nit: the patch title could be more informative to what > optimization we are talking about here... ie: reduce atomic ops > in writer slowpath' or something.) Yeah, the "optimize write lock slowpath" subject is a bit generic. I'll make the title more specific in the next version. Thanks, Jason