Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3054004pxu; Tue, 8 Dec 2020 02:10:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhecH5NK83nQ3kXNzfY2NJ7GOWQFehIPnd1Cr9D+0K0EaSP9zHCesLE6+v3Wj15U9wz3n/ X-Received: by 2002:a17:906:7687:: with SMTP id o7mr22849117ejm.209.1607422227530; Tue, 08 Dec 2020 02:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607422227; cv=none; d=google.com; s=arc-20160816; b=BQyCcyzoKyJGxt3ASxKPg6qc5VtjU1h1NHWIC7WP5RwJKPao7CMtGC2SXZzwFGFkIs Yyq5Myoqm85sNOjnHPAGPIUxNaB2XsX93nsUUrUYQdtPtOg2GkWABA+YwC62OYDLn8nP gvtWuUbWFmbc/O95ju6tKVFC9N5tObpYyxgxMbZJ9nlFGCa1szRZqq1BGRqiCblaMz8k 5dZdIlAdnU7etzYuZ5VYYodFX79iirgckdAFMZMwXeIUn+E7oPWkygef9C/xyfHtHxA6 x3/eeaB3U8qTKTpOWGNTtEQ7iRwR+2lYlJjo/C67F1eF6oJf8ZB3kldhcpaKI8dQLLGs isQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/cbg0yWJlkVgkdQRE8gAJUwBms4pTAlYLahKPvCS91M=; b=X9ecO9rB2CCOpXv9K0gjG7xGIY247ddncd6nv5z0Z9OsYsu4E3VyEDMtt4fEgujxXi W85/8VWdMIwPhEx57b5f5AHkel2SINbvMAkMSZldcqDNUhlAJDJPYohVegCAeOIqEhkw QBExkc4MTn1Zxv1ij1sZY58rHqX2sqtM2rKvNaZ5RP7TBmDfYayWWsYJMOJQY0M4iY+g yXuEdxbu4FEKqz+XQTMJWHK/KrHY7Ptr53gRvEm0hTJC/ZZXDyJeZRINBaq9adk2aNZ8 aQ2OEYHXLMFDgS8gz+wy5ecA/8YoitSAPHrZVV/6SAgV9BF1YjifFW9aCCRA1drju+Pu sgLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b="anEw8/6a"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si5191961edx.473.2020.12.08.02.10.03; Tue, 08 Dec 2020 02:10:27 -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=@infradead.org header.s=merlin.20170209 header.b="anEw8/6a"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728878AbgLHKHy (ORCPT + 99 others); Tue, 8 Dec 2020 05:07:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbgLHKHy (ORCPT ); Tue, 8 Dec 2020 05:07:54 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E754BC061749 for ; Tue, 8 Dec 2020 02:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/cbg0yWJlkVgkdQRE8gAJUwBms4pTAlYLahKPvCS91M=; b=anEw8/6aKdXJ8H7aopQ/mcvoGi VtFEhI9C5lnXYgwasWsNM5tP3WVp7eGbnZbc3banrikySSOtwAmyTl5myrRbIPf60CG5W5WcC57oM ONo3mNblKSo/Jb2fkvTKMnZG1pBqITR2yLGAtnRxA/CgYEsOuf563Kx6kwkQBmNHEjtWhRr+wW8XB VfHoEnCeLVEfx7RBhJq/Z7Pp7JW0EkEbqMukWC1ZwhyNf4W1TgSMmd4vf92WDUDvPTKjCOLGuI8Jf M+92435LMZVCO/xozf4dnAlQtVykwSZY+7jIQSau3btxeMAn7PO1zgG85PjCxUMZQSp41rDGASEcY clOK6C4g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmZtl-0007bU-BK; Tue, 08 Dec 2020 10:07:09 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 131E73007CD; Tue, 8 Dec 2020 11:07:05 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id F0E61200AABB2; Tue, 8 Dec 2020 11:07:04 +0100 (CET) Date: Tue, 8 Dec 2020 11:07:04 +0100 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org, Davidlohr Bueso , Phil Auld Subject: Re: [PATCH v2 5/5] locking/rwsem: Remove reader optimistic spinning Message-ID: <20201208100704.GU2414@hirez.programming.kicks-ass.net> References: <20201121041416.12285-1-longman@redhat.com> <20201121041416.12285-6-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201121041416.12285-6-longman@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.. > - * 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?