Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp999226imm; Fri, 13 Jul 2018 09:43:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpculdGPwudrESPO10ItDsoWRYbYGzojUaMXQILoJ7MvGYlZMP9dry5meJzpwHia/gcO7xk2 X-Received: by 2002:a63:460d:: with SMTP id t13-v6mr6668636pga.201.1531500239573; Fri, 13 Jul 2018 09:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531500239; cv=none; d=google.com; s=arc-20160816; b=XkoK3MHgQTALwJuVPhZsJ6iiMsLxXV/203oXnuwsVABdhE4PH0VwpaxAnNkspuIYop k5wTnO0wdUhy5okP5rMvQKyUfdqjJWU0hMkRo1W5ujEbGGjchH7whiV8TPn1fzTKXoZ1 SMotQrHsJLvtl2sGskU9BjeYJMKhvgZoFKRlNrwTChcbPcxuKgPW9Hd6fx5HMqSM3E7+ YW/n0BuM+U1rv37XBrW7nYcdaR/BKM5DI/wxckSqgXEt1yizSRleUzS0wbepw9UrWYaP qZ39na68Qx3ElN7PR4GF1Rsl2+s1U99b2X7zrceSU2/IlHoP6zbzH2HPa5nIKTGn97jt YEfg== 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:arc-authentication-results; bh=gy8pDiKzZTUCeNJYIlT1RtKr2J6ltkl0oC11SnsZcbA=; b=xIVKTuxXPJ27xGny7R1tXwaqnx3OZYKdgrSfPL2f0MMUmDLghMe2R5wsl1/SHmRcjg g7V5ZJRKRVSKNhhfsEI9UK0HBxXjEFMCdMCTfl2cYZYULlpVZmGX3S/ZADMSND6Aed0W +u3mYHju53vI5I5KC0SqQxx65+HNRJmMcIzGYGEv/ToFiWoN80fF54xJS6KtFBMfplqZ /uLOFP+yTssypdLGshfkoeIJKx7//BdbGk9ef0tnbtuX1Qc+i3VNi5EvA3Us0ih2sHmB ALBs3ZlWlLnHpQjKFVaJoNqHsfKMqYwKRgCzd6JC8/9fjiTbAQM6i3Kcv9vaBnTgdVtj +phw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rhXTGAl9; 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 d8-v6si22298255pgq.162.2018.07.13.09.43.43; Fri, 13 Jul 2018 09:43:59 -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=bombadil.20170209 header.b=rhXTGAl9; 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 S2387696AbeGMQ6S (ORCPT + 99 others); Fri, 13 Jul 2018 12:58:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39432 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731972AbeGMQ6S (ORCPT ); Fri, 13 Jul 2018 12:58:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=gy8pDiKzZTUCeNJYIlT1RtKr2J6ltkl0oC11SnsZcbA=; b=rhXTGAl9KpvajFikYYMyZu8Mj t3r7QDqM/pFy7vcad5xklklsLHLHQRVnwY26CJl36g21uWjD4ceyMNzgvu0KDLyZ5tO2Y/XtbUm2T xdrKyQdI2qQmOVpzljkPbW7qSJZmbgDIopbT+PSYQFoILaqhpKSbSxY80Cn/xn5GrU7Shazf9iJKK cX3JTMeY1PJQO1uflp4B3L4PYLmUEq1QXKtmusxBuJ4RE4UjT1TeV4GFPRHJhMki1rW0ihKCl4VvQ p6ZG9JQirfBk8CIXYhMbV7d2FCBSaj8P1ZJE2prHq2xqYLj5NawFvnP5Ck1U+TKn7H5Jj6JGndQyF TuZVIevhA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe19V-0005V1-Mr; Fri, 13 Jul 2018 16:42:41 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8E78720289CB2; Fri, 13 Jul 2018 18:42:39 +0200 (CEST) Date: Fri, 13 Jul 2018 18:42:39 +0200 From: Peter Zijlstra To: Michael Ellerman Cc: Linus Torvalds , Paul McKenney , Alan Stern , andrea.parri@amarulasolutions.com, Will Deacon , Akira Yokosawa , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nick Piggin , Linux Kernel Mailing List Subject: Re: [PATCH v2] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Message-ID: <20180713164239.GZ2494@hirez.programming.kicks-ass.net> References: <20180712134821.GT2494@hirez.programming.kicks-ass.net> <20180712172838.GU3593@linux.vnet.ibm.com> <20180712180511.GP2476@hirez.programming.kicks-ass.net> <20180713110851.GY2494@hirez.programming.kicks-ass.net> <87tvp3xonl.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tvp3xonl.fsf@concordia.ellerman.id.au> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael, On Fri, Jul 13, 2018 at 11:15:26PM +1000, Michael Ellerman wrote: > I reran some numbers today with some slightly updated tests. > > It varies quite a bit across machines and CPU revisions. > > On one I get: > > Lock/Unlock Time Time % Total Cycles Cycles Cycles Delta > lwsync/lwsync 79,290,859,955 100.0 % 290,160,065,087 145 - > lwsync/sync 104,903,703,237 132.3 % 383,966,199,430 192 47 > > Another: > > Lock/Unlock Time Time % Total Cycles Cycles Cycles Delta > lwsync/lwsync 71,662,395,722 100.0 % 252,403,777,715 126 - > lwsync/sync 84,932,987,977 118.5 % 299,141,951,285 150 23 > > > So 18-32% slower, or 23-47 cycles. Very good info. Note that another option is to put the SYNC in lock() it doesn't really matter which of the two primitives gets it. I don't suppose it really matters for timing either way around. > Next week I can do some macro benchmarks, to see if it's actually > detectable at all. > > The other question is how they behave on a heavily loaded system. > > > My personal preference would be to switch to sync, we don't want to be > the only arch finding (or not finding!) exotic ordering bugs. > > But we'd also rather not make our slow locks any slower than they have > to be. I completely understand, but I'll get you beer (lots) if you do manage to make SYNC happen :-) :-)