Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3261998pxu; Tue, 8 Dec 2020 07:36:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQg9VgdnW2a5A1IvKoMSJ0KE7AceLDvfSHZc69oldpxkykFOVfmdc5LFeu2z+gNmCwbi8N X-Received: by 2002:a17:907:2108:: with SMTP id qn8mr23680784ejb.127.1607441789306; Tue, 08 Dec 2020 07:36:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607441789; cv=none; d=google.com; s=arc-20160816; b=wO7g2oSTnNMNLmqbXDGb80ystvHE0FeM9t3eHYG0Cl7ggd/nv+BwhGz7D+vrNJI867 ExcsFJWNa0Wzv+Jp5acur7bGHtjLEc0AW/6oVX5z7P4uM4lqhGGgHb7B5QEjrRTFh0Dt 90lR1B+slItzKNOynlBz93Pt7HE0MK5rHMkuCQQ7oJmiRLteQLuDm7rVlT61UxTwXG2I R5enC4yIbWq9oV8BjgHAXEcklkQRdJMibVGOLu72uY1y6d4TITqid2Fvg1ZGiy5tEp4A tuLb81yAAFbKCYX5h9lTDQMz/m/BHtDus9sc/HhRwEE8i5Z5ChZbzD9DQu9LjVVrMD0x KnGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=miua5ROGrphgyENa3zVBXUwOoAslKJxQNqStT5/JBjw=; b=eR9u40O3s49gArCg7HJK5Jp5T451bngrtjhNObdkrfv9tri0iVZLClITMARHc2r5+L dhFXDYqHby6elVYoHw2UYO82Et7GTEwc1TeHqIASIrK/JHGee7IAgrTgf2K0Sa4Jvzxk MafqDSUrBso1s5ZkGl26+LaO1nLyI/5ENJG3x6042JyRWbtoCJk1viUhFV8g5iDs67Zu mdybXLBK/HuJGnaUFdQ9blTKEUWRQcrG4R/j1amkLZgvXOBiM1p7/akU/cW6M+wMo8do cqiO7C7jdxMI5GSviv5X30EjO0pGBkli+MkoKHKw1U5ou+WtO31xT6bmS0xeNagu7c4Y f63A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aeSNODpx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si8583009ejj.266.2020.12.08.07.36.05; Tue, 08 Dec 2020 07:36:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aeSNODpx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730108AbgLHPbL (ORCPT + 99 others); Tue, 8 Dec 2020 10:31:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53252 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729386AbgLHPbK (ORCPT ); Tue, 8 Dec 2020 10:31:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607441384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=miua5ROGrphgyENa3zVBXUwOoAslKJxQNqStT5/JBjw=; b=aeSNODpx+XpA58Q7nHxCpu+D/zNUEmqUyZY5+/9dZrCkFK0ftRTWkouRc7As4As8msbv7u 1H6TJa5t0BbqCjJrt92G5QIxk6sAPJN6gIkbcbWBFRf0VVuhQRCUwZ1oBMr3S5TBu2NsuU 78TXZ2RfGLZUFw0HDp12CzlqQAtFYeg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-07-LZiWuNQKcBiRkqqRf3Q-1; Tue, 08 Dec 2020 10:29:41 -0500 X-MC-Unique: 07-LZiWuNQKcBiRkqqRf3Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90080858187; Tue, 8 Dec 2020 15:29:40 +0000 (UTC) Received: from llong.remote.csb (ovpn-119-227.rdu2.redhat.com [10.10.119.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id D57F260BE2; Tue, 8 Dec 2020 15:29:39 +0000 (UTC) Subject: Re: [PATCH v2 5/5] locking/rwsem: Remove reader optimistic spinning To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org, Davidlohr Bueso , Phil Auld References: <20201121041416.12285-1-longman@redhat.com> <20201121041416.12285-6-longman@redhat.com> <20201208100704.GU2414@hirez.programming.kicks-ass.net> From: Waiman Long Organization: Red Hat Message-ID: <234a49df-0f88-2dc1-968c-8bfe52ccf9d4@redhat.com> Date: Tue, 8 Dec 2020 10:29:39 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201208100704.GU2414@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/8/20 5:07 AM, Peter Zijlstra wrote: > On Fri, Nov 20, 2020 at 11:14:16PM -0500, Waiman Long wrote: > > >> @@ -1032,40 +901,16 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, int state, long count) >> * >> * We can take the read lock directly without doing >> * rwsem_optimistic_spin() if the conditions are right. > This comment no longer makes sense.. You are right. I forgot to take that out. >> - * Also wake up other readers if it is the first reader. >> */ >> - if (!(count & (RWSEM_WRITER_LOCKED | RWSEM_FLAG_HANDOFF)) && >> - rwsem_no_spinners(sem)) { >> + if (!(count & (RWSEM_WRITER_LOCKED | RWSEM_FLAG_HANDOFF))) { >> rwsem_set_reader_owned(sem); >> lockevent_inc(rwsem_rlock_steal); >> - if (rcnt == 1) >> - goto wake_readers; >> - return sem; >> - } >> >> - /* >> - * Save the current read-owner of rwsem, if available, and the >> - * reader nonspinnable bit. >> - */ >> - waiter.last_rowner = owner; >> - if (!(waiter.last_rowner & RWSEM_READER_OWNED)) >> - waiter.last_rowner &= RWSEM_RD_NONSPINNABLE; >> - >> - if (!rwsem_can_spin_on_owner(sem, RWSEM_RD_NONSPINNABLE)) >> - goto queue; >> - >> - /* >> - * Undo read bias from down_read() and do optimistic spinning. >> - */ >> - atomic_long_add(-RWSEM_READER_BIAS, &sem->count); >> - adjustment = 0; >> - if (rwsem_optimistic_spin(sem, false)) { > since we're removing the optimistic spinning entirely on the read side. > > Also, I was looking at skipping patch #4, which mucks with the reader > wakeup logic, and afaict this removal doesn't really depend on it. > > Or am I missing something? That is true. Patch 4 isn't essential for this series. So if you are general OK with the current patchset, I can send out v3 that remove patch 4 and make the your suggested change above. Cheers, Longman