Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp650424imm; Wed, 8 Aug 2018 03:25:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz2MU/UZhA8rBAQVqDGLFb3b6xmWzkR1HzEHHc4IktzGEOMZEOAuJa8OoUx7w92s5F7gokC X-Received: by 2002:a62:e30c:: with SMTP id g12-v6mr2295096pfh.25.1533723947499; Wed, 08 Aug 2018 03:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533723947; cv=none; d=google.com; s=arc-20160816; b=PXcNtjG+Nu6DOYvMEpd+JbN9UmYcgE7T8CumpVmJu+ad7E28TeeAFG0ch1bXk/zZEY 7r6B99F6v2KsMeGrdtB99uYO9wVxwmaKQGrxDEeYG/qFb1rChIuzHdd9X588lnVpnhL9 a3GTwX4hEp7HlM9He76Uz8K5R4tjHAoF2ch5fbNeiYYjZC7zNcVt7KD/eGn1ClhdLqt3 lqimVmsb5m8y/9V5sFGS7BIGyuAoM2Xumw0wDyO95tGQhWDbTRCJE6OnaD1jaCaX/2UK a+IsVnMtulybLIttrWviRbJMJpz5ATKz7vzHTcrsYBH/j74cEjl/ifPaMhJYxV3dspqJ IjbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=yYzFMc3JiAMW7Ob7yYI4sR6+rqXI/oFBhnpQGwGSiDA=; b=jfYtyg+rV6lZjSvw/3pLH4iT+KXu3HQE3wb5yCf2676mB3SDgEBW6YNMAn8+uo7coK ErBVEoAYC1iWF5wYywZHWu2jhe/QrtaV4gcDjbDDToKJRe3MlzRvxFCacQINskU4IK3z 5pBKzvXHqg3LHzB8z9JWPQZr8bAggv30w4FZZ1GqE0+GDjcaRNSVk7FDVTuYVLAaCI5N IDuvqcK/6e3UlCzEX8zKDAK3fmZ8bcGXBIrvtBNiQ3B9k/bqxscX8g0E5uqjA1CtLEpI 5N/f1at1wsW1eUIY6flBpQ9nK+GHi0O8zCZYN6Um7uNFs377nQGncr/Pl564bWLa7uLG Suvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y38-v6si4000077pgl.73.2018.08.08.03.25.32; Wed, 08 Aug 2018 03:25:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbeHHMnA (ORCPT + 99 others); Wed, 8 Aug 2018 08:43:00 -0400 Received: from foss.arm.com ([217.140.101.70]:36802 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbeHHMnA (ORCPT ); Wed, 8 Aug 2018 08:43:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A51EF18A; Wed, 8 Aug 2018 03:23:57 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 75E383F2EA; Wed, 8 Aug 2018 03:23:57 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id CEA991AE180A; Wed, 8 Aug 2018 11:24:01 +0100 (BST) Date: Wed, 8 Aug 2018 11:24:01 +0100 From: Will Deacon To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Joe Mario , Davidlohr Bueso Subject: Re: [PATCH v3] locking/rwsem: Exit read lock slowpath if queue empty & no writer Message-ID: <20180808102401.GC28557@arm.com> References: <1532459425-19204-1-git-send-email-longman@redhat.com> <55866c24-ff40-22cb-1390-6c9055bd2cb7@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55866c24-ff40-22cb-1390-6c9055bd2cb7@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Waiman, On Tue, Aug 07, 2018 at 07:29:49PM -0400, Waiman Long wrote: > On 07/24/2018 03:10 PM, Waiman Long wrote: > > diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c > > index 3064c50..01fcb80 100644 > > --- a/kernel/locking/rwsem-xadd.c > > +++ b/kernel/locking/rwsem-xadd.c > > @@ -233,8 +233,19 @@ static void __rwsem_mark_wake(struct rw_semaphore *sem, > > waiter.type = RWSEM_WAITING_FOR_READ; > > > > raw_spin_lock_irq(&sem->wait_lock); > > - if (list_empty(&sem->wait_list)) > > + if (list_empty(&sem->wait_list)) { > > + /* > > + * In case the wait queue is empty and the lock isn't owned > > + * by a writer, this reader can exit the slowpath and return > > + * immediately as its RWSEM_ACTIVE_READ_BIAS has already > > + * been set in the count. > > + */ > > + if (atomic_long_read(&sem->count) >= 0) { > > + raw_spin_unlock_irq(&sem->wait_lock); > > + return sem; > > + } > > adjustment += RWSEM_WAITING_BIAS; > > + } > > list_add_tail(&waiter.list, &sem->wait_list); > > > > /* we're now waiting on the lock, but no longer actively locking */ > > Will this patch be eligible to go into 4.19 or 4.20? It's probably worth reposting with the Acks you've received, so that Ingo can easily pick it up into -tip (but it might be a bit close for 4.19 at this point). Will