Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4198467yba; Wed, 17 Apr 2019 06:42:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRp7ZWlr0qW/xdE/++9craDHTGKmKf4W0Ew/8m+wbXTNvGXlgg9XmxNO7GteYcdWNsBQ+G X-Received: by 2002:aa7:8145:: with SMTP id d5mr89167163pfn.215.1555508568254; Wed, 17 Apr 2019 06:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555508568; cv=none; d=google.com; s=arc-20160816; b=w4vVnDDYNdpwKoELsO4K+C2PBoCZeQb0CvRt6/PRqW8ploL00DWP0DXvYQSuKMO/2k h7jU+DjjMuDgiDumoSz/OH5e1yRucRT4WZXGEAz7ElEmx6yMMaJU56bCeaVucpmuSF/9 M+pRewukC40emL4H1gjM15/CmEQUdFGC2JVxYZ9q+DEHe4NiQvqr/WJJz5D4JFwuWtR3 DHw8XFLapMHW70YTBz2zkFWdGKqAo8ZsLxk70X1Wm9UEqx/nWyrKcpTZwC3hJgeF1D1A 0mercMdKVPXTtYx2ViqK9QFxT8l1gMfZhOg53zXHHnA1NlEDLSF72kmgFWzauyUJHSLV yMog== 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=Zv/MxQNlcnE/NTFtxq8iHLXcYTq6O6gWh9P8aV5JkY8=; b=aAHNYcVFhvggmr9Q8Cm3p6urzRgAPur+Gc+PbmQj53a/IY/jcdycIayfKLaxE/lh4D lRnAUb1SiRhpWlxleurjnotgTTPtlhm+3LFwRDj9L+cIkH5IErO7j/rL27peIQGSv7yC RjST8f7RHtV9PQwJXzA9WxMyo0dNKNf5VHfUEgYlycHUnJwn1OHeGZ5aDBlF+3CXGkPf Nq6wPhPZribS7V0+n4v935OdVFUqIbXJsNbZ90ZP1bMieHKAMo7XazTXSKiK0O60CBlw YhtNAex1xkiY0hs8Bg0tpr7vD/+UgsA3FVCdZDFS1A1PWTkKV7/6vAerBJ2uZCER2eM6 pg7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=LGcZz8DL; 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 d2si1082782pgv.22.2019.04.17.06.42.32; Wed, 17 Apr 2019 06:42:48 -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=LGcZz8DL; 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 S1732302AbfDQNjs (ORCPT + 99 others); Wed, 17 Apr 2019 09:39:48 -0400 Received: from merlin.infradead.org ([205.233.59.134]:57522 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729356AbfDQNjs (ORCPT ); Wed, 17 Apr 2019 09:39:48 -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=Zv/MxQNlcnE/NTFtxq8iHLXcYTq6O6gWh9P8aV5JkY8=; b=LGcZz8DL9x/PYJoP4ZVgjh8Za kanp3v7Pak5hISnoBVBvZhqBo6bi0zxjYgIliuMgXlq/uGh9Yc4UiGoZkymq4/MDJXbXl07E9bnK2 2HARlUHF94PaGp6KODmZLila3uESRL+I0diu0FfCKcAgHYeyrZWE2tbre/HWrRE2fXA9+HeaZn1z2 6mdVKQOtuxD2G+eY8HQzMg0IPjnoKmPoPmT9aJIBe0w0LiXdeIx1/aV2mqOO4iI2atkV23f0h5bBL ZdAoBC7viKdwYHvQWrGE15jh7jAAWnveJ0Zq2vDo8RWxIi3/3zOfWEWSsqKo86afwOZ65peivcTHt S7/Nk6htQ==; 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 1hGkmp-0003B7-8J; Wed, 17 Apr 2019 13:39:39 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 057B529B52926; Wed, 17 Apr 2019 15:39:38 +0200 (CEST) Date: Wed, 17 Apr 2019 15:39:37 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Davidlohr Bueso , Linus Torvalds , Tim Chen , huang ying Subject: Re: [PATCH v4 10/16] locking/rwsem: Wake up almost all readers in wait queue Message-ID: <20190417133937.GG4038@hirez.programming.kicks-ass.net> References: <20190413172259.2740-1-longman@redhat.com> <20190413172259.2740-11-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190413172259.2740-11-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 Sat, Apr 13, 2019 at 01:22:53PM -0400, Waiman Long wrote: > When the front of the wait queue is a reader, other readers > immediately following the first reader will also be woken up at the > same time. However, if there is a writer in between. Those readers > behind the writer will not be woken up. > > Because of optimistic spinning, the lock acquisition order is not FIFO > anyway. The lock handoff mechanism will ensure that lock starvation > will not happen. > > Assuming that the lock hold times of the other readers still in the > queue will be about the same as the readers that are being woken up, > there is really not much additional cost other than the additional > latency due to the wakeup of additional tasks by the waker. Therefore > all the readers up to a maximum of 256 in the queue are woken up when > the first waiter is a reader to improve reader throughput. > > With a locking microbenchmark running on 5.1 based kernel, the total > locking rates (in kops/s) on a 8-socket IvyBridge-EX system with > equal numbers of readers and writers before and after this patch were > as follows: > > # of Threads Pre-Patch Post-patch > ------------ --------- ---------- > 4 1,641 1,674 > 8 731 1,062 > 16 564 924 > 32 78 300 > 64 38 195 > 240 50 149 > > There is no performance gain at low contention level. At high contention > level, however, this patch gives a pretty decent performance boost. Right, so this basically completes the convertion from task-fair (FIFO) to phase-fair. https://cs.unc.edu/~anderson/papers/rtsj10-for-web.pdf