Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp779194imm; Fri, 13 Jul 2018 06:16:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcdVebm3vzYubgGEr/nsb5gkwUSJXPZvsQ3AtBTIcq1k8kYm+Z64S0YFzw4WEjFZhZ6g6SZ X-Received: by 2002:a63:524e:: with SMTP id s14-v6mr6171023pgl.35.1531487786092; Fri, 13 Jul 2018 06:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531487786; cv=none; d=google.com; s=arc-20160816; b=fFZw4RqNEK3XTN0EuduDdEULCRT4a/OHJyXhmqH6W+HlJnDZyV3b/4Ybkk+2gBIb0q 20qUyK92GYisblWi9F8df+PSoiOkm/ELa0JpSfMEYbfQuSUnnTyPlLutDjrkIVeePq15 bFzoUJHY8Gbtu4JtsBpv/nO33HheMs+CX/5GrfgcVitINwwKkj8+iDXxnsaqvVyppjFJ J+dPzn0UCHOaZXjwN1DJKjAYPq+Nl8JEoAcusi8iCM9oYXvFqWrRDzkqmULqThpBFobk oNRVMaUH8xnvEBIQ7k9I2ZoiMa7bfR9X2g/EasV6GEYGRnZm66oBqC6mFq6mJl4SP+fm kUcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=zKudXgDbQK2JOqiS+xUGd6w+nBem/udCLcyQLZg+nts=; b=tI3jrmmNJey0ycr1anZl0sArL9lS26VQjn4c4mzhIx4R+xVwMI5ymsNACqVU8mLbvO aiYGgklftktWTt/kemvmUs6m+/ZqZ6Z3JriJs0XmkyANMOHW60d6UvFaSs4syM/gdIE5 EMngnrN3GnbcfUDmLsZ+lqvqzoEvljVVm4ftsZgg+NhE5cFu527gFDKl9+w45g9yMkau 20SNwVxIT7jghIUVKtKrEgkjpmkrJXactq0+WTC9VyCv2rvLgjIpkV0E5NKh5UCHyiLS hY9WsA1qDgnNHyIKKczhCYCIpv4wqcIjD9LITCt7fj5VI1ZqxDDU/9XcdrJetdkjocT/ 8lTw== ARC-Authentication-Results: i=1; mx.google.com; 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 34-v6si23907278plc.346.2018.07.13.06.16.09; Fri, 13 Jul 2018 06:16:26 -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; 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 S1729723AbeGMNaK (ORCPT + 99 others); Fri, 13 Jul 2018 09:30:10 -0400 Received: from ozlabs.org ([203.11.71.1]:36861 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729623AbeGMNaK (ORCPT ); Fri, 13 Jul 2018 09:30:10 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41Rtb34SWGz9ryt; Fri, 13 Jul 2018 23:15:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Peter Zijlstra , Linus Torvalds Cc: 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 In-Reply-To: <20180713110851.GY2494@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> Date: Fri, 13 Jul 2018 23:15:26 +1000 Message-ID: <87tvp3xonl.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > On Thu, Jul 12, 2018 at 11:10:58AM -0700, Linus Torvalds wrote: >> On Thu, Jul 12, 2018 at 11:05 AM Peter Zijlstra wrote: >> > >> > The locking pattern is fairly simple and shows where RCpc comes apart >> > from expectation real nice. >> >> So who does RCpc right now for the unlock-lock sequence? Somebody >> mentioned powerpc. Anybody else? > > RISC-V followed, because the LKMM currently states it is allowed, in > fact LKMM is currently weaker than even PowerPC, which is what this > current discussion is about. > > A number of people, including myself, are arguing for stronger lock > ordering (RCsc) but getting the LKMM to be at least as strong as Power > (RCtsc as coined by Daniel) which disallows full RCpc. > >> How nasty would be be to make powerpc conform? I will always advocate >> tighter locking and ordering rules over looser ones.. > > mpe did a micro-bench a little while ago: > > http://lkml.iu.edu/hypermail/linux/kernel/1804.0/01990.html > > which says 30% more expensive for uncontended lock+unlock. Which I admit > is fairly yuck. No macro bench results though. 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. 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. cheers