Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5161000ybi; Tue, 4 Jun 2019 02:11:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4xV1PRpji/9wpZjaUuCR79giYjCm1xd7gN/9dKg31pkWIZ48tWUDFIbx3YBwdfqx804sc X-Received: by 2002:a63:c006:: with SMTP id h6mr15500431pgg.368.1559639515212; Tue, 04 Jun 2019 02:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639515; cv=none; d=google.com; s=arc-20160816; b=rCsaIRUqzDrgK5orRRCYqftLZRZT7Ek0AGwgeANSjQS1Sw56sHV8kI69zY8SiNHRCK 0QNlt30mxyYyVIydVjX40Yc5U6Uk1zJa9MrqcwdcBRAGq19b7Qdt9zAYON2R+b8gNoaQ rOLNOdaNdsCPd5CwQbasDom6KXqU9Jbf+Ia7B6xD+gh5HSi8dlX0HXIPwSJF68FETlji eJI4UfbxonTSy3m6/c51ZCbGPous742q4T0UNNr/Fh0Kkd1i6t1uSOxz7hCjoeSfx5Z/ Z1+eba8ik55z6QUSep8VpCnzJj9NDBUfn9y6x51+Dn19Q5Sk0qOqfK9pQRA5neWWdqLy /nag== 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:dkim-signature; bh=m/c3FgrUfhn4KG9UznydNu1bp5nGuO9Yr6Nn9DVwU2I=; b=G5hH6rsWAWH6xN47rCU8kZrjCdDRXKCGLImIUB72SJtSniUuTxBgY+SVBchQvTVBZ6 CCZcQpK5c3VJEwCs7OdASnGgjvRGhuQmesoEXpgpTQHV3g3z27S0+0/uSut0tQLlI2aQ tTtNOveJNTWYX+EgWja9op/gBBVv6DerN8AlnMMGPiqS9OlW3npS9zKPa4Hz5ztpAs+V FwKvgITGGn8TNU3r8KBQCECiJyrYV5HFFbagL7/+uiEH7pbc361ulTAr1APZdzPp3NtH KtQ/6BLBvbVT1brdKSB0dyY4YvIBu1S0tM5ICJxmsoq1QC/HK7rKx9tSL+VjLSOLJ8UC j85Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=QhMtqMIc; 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 k13si20627942pll.64.2019.06.04.02.11.39; Tue, 04 Jun 2019 02:11:55 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=QhMtqMIc; 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 S1727150AbfFDJKL (ORCPT + 99 others); Tue, 4 Jun 2019 05:10:11 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34422 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbfFDJKL (ORCPT ); Tue, 4 Jun 2019 05:10:11 -0400 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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=m/c3FgrUfhn4KG9UznydNu1bp5nGuO9Yr6Nn9DVwU2I=; b=QhMtqMIcZIv85zDrVleDnKMDE jGU0NCY8syc8w7oZYS3KIKp2VW+nsL2rTgZIGec4AUU07p4Ir7ab+bmy5FbBm12opml274lqfHQVv xLVD1Vhd/Avw0GtIiHp+wBt3csju+DK58d+8pwWaK9is9EvmmMcc2iLoW59iA6ShyN8OVL03SAzlb dm83B+UgB142Eg53DlUT0azEuitwt69Cm/d7mML1j+O/DAncHSpvQRBNEusrnAEfij04W63Xw6lO4 6M+g6O3XFHClcCwqOy7lROGTwuZSWtj7t3RSa11ByBbrvu9aQNMfEp34qIdJaqApt2qtGVRflriHW CXNNaDrfg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY5SD-00033n-GM; Tue, 04 Jun 2019 09:10:01 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 438742083FE28; Tue, 4 Jun 2019 11:10:00 +0200 (CEST) Date: Tue, 4 Jun 2019 11:10:00 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org, x86@kernel.org, Davidlohr Bueso , Linus Torvalds , Tim Chen , huang ying Subject: Re: [PATCH v8 15/19] locking/rwsem: Adaptive disabling of reader optimistic spinning Message-ID: <20190604091000.GH3402@hirez.programming.kicks-ass.net> References: <20190520205918.22251-1-longman@redhat.com> <20190520205918.22251-16-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190520205918.22251-16-longman@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 20, 2019 at 04:59:14PM -0400, Waiman Long wrote: > Reader optimistic spinning is helpful when the reader critical section > is short and there aren't that many readers around. It makes readers > relatively more preferred than writers. When a writer times out spinning > on a reader-owned lock and set the nospinnable bits, there are two main > reasons for that. > > 1) The reader critical section is long, perhaps the task sleeps after > acquiring the read lock. > 2) There are just too many readers contending the lock causing it to > take a while to service all of them. > > In the former case, long reader critical section will impede the progress > of writers which is usually more important for system performance. > In the later case, reader optimistic spinning tends to make the reader > groups that contain readers that acquire the lock together smaller > leading to more of them. That may hurt performance in some cases. In > other words, the setting of nonspinnable bits indicates that reader > optimistic spinning may not be helpful for those workloads that cause it. > > Therefore, any writers that have observed the setting of the writer > nonspinnable bit for a given rwsem after they fail to acquire the lock > via optimistic spinning will set the reader nonspinnable bit once they > acquire the write lock. Similarly, readers that observe the setting > of reader nonspinnable bit at slowpath entry will also set the reader > nonspinnable bit when they acquire the read lock via the wakeup path. So both cases set the _reader_ nonspinnable bit?