Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3871939imm; Tue, 17 Jul 2018 11:44:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdqQ6BUuylRZj08GyTDGcGvULVZnjk5fW4uw27p3EuJC4DC9Ha9D2cRFucuVlqiT9wGNXRL X-Received: by 2002:a63:ad07:: with SMTP id g7-v6mr2672676pgf.19.1531853052105; Tue, 17 Jul 2018 11:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531853052; cv=none; d=google.com; s=arc-20160816; b=FM8zMAJdt8yJTVhaTeUa65gz7BBscU195YeGO3sGjdlFS55sKK56OrmEpef6+gGJQt JvtnVcM9uO2U/LAOurffaXtmeBcHmRvJ1VcHSjDn+F+4G/0V1F2SSoYhJEk6mJC9jnev FCXf22Wu6zJN2CVD0byPdVh+tkDE3F8Kv1TpQZ6+dDw4QcVviuid58FiwyEjk5X1VX4R b9/pzy52gOEqPDWRXHLribfU70O7urnYe/VkcHQy/QtQKdG1K/aZhOhz4+cW9VDNcrvJ 5KrQGyp5TteYoQrDuYyk19U7q0yT4YIfSt/o0XZY7GXn6kUH+28eiqF/Dtp/qtW4VEpS zWWQ== 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=mbhi9UOHjJoUMSiF5CPD0d0YTUQMuKa7eRANov79eqU=; b=VrXnE4X+wyg97z4qcn5P6XypwIVRaZMSjPQiYG5f8HrvEmpJmtZTCuMveMFhiINv5i mLJ0x+tOLcq1Gf7sHEdhscaqWm+v+Y0ZeZ+jNTfyp+j3ZbrvLzhEB6Cec7OgZBZvkW+8 2lBCdAIgVPVrYTkta2dIVz1hf5hw8eFRdP9pUQ2BBJ9PaI3kqPNZaMh80BM5WPGzBDxq Q5WDVEWKgPuj9vubzYgu3Pc4+85I8nXJp1y6ZyAWiDE6FwaV/nrS6xz+FoBj8brXARVy c6si7gqFXWR6AytZnkVaITWoNxeMrjzLydBBRNSGj9/sOPM/L9UkvZQmcF0NBwL3eNG3 07tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=a7lBy4oz; 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 q9-v6si1581367pgc.685.2018.07.17.11.43.56; Tue, 17 Jul 2018 11:44:12 -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=a7lBy4oz; 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 S1730380AbeGQTRP (ORCPT + 99 others); Tue, 17 Jul 2018 15:17:15 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49506 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729741AbeGQTRP (ORCPT ); Tue, 17 Jul 2018 15:17:15 -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=mbhi9UOHjJoUMSiF5CPD0d0YTUQMuKa7eRANov79eqU=; b=a7lBy4ozIeW6L6lDPksDRnHzF m/N2Dv9jrQVf/diClKhXtznADcoa71ng0NV8ke1e6jfDrWulSW0////f8ei7VZYRuYflP552CBaVh N3LpqG1UX2aFIyLej2j7a4Fwc1mv5jQZIueLSBQxoChziRXYn1kHomCv8VwOPDWN+O9rH+Yyk95m4 zNqRxkfg5zBvAaeXK2SuUmLF+aEX4KPs9EbRvyyOZPOgeSQQ2rChjT7q84/BfV6PHxweQoB3kTBsa GTnfTE/9mrkkcdJcY1czv0+CURUbdJq12dhnBW4qhVvSMsnoR2n6K/QTAgLOfiRv9fpJsnvKwufJE RutOqkdOA==; 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 1ffUw5-0002rJ-3W; Tue, 17 Jul 2018 18:42:57 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D7C5220275F36; Tue, 17 Jul 2018 20:42:55 +0200 (CEST) Date: Tue, 17 Jul 2018 20:42:55 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: Linus Torvalds , Michael Ellerman , 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: <20180717184255.GM2494@hirez.programming.kicks-ass.net> References: <20180712180511.GP2476@hirez.programming.kicks-ass.net> <20180713110851.GY2494@hirez.programming.kicks-ass.net> <87tvp3xonl.fsf@concordia.ellerman.id.au> <20180713164239.GZ2494@hirez.programming.kicks-ass.net> <87601fz1kc.fsf@concordia.ellerman.id.au> <87va9dyl8y.fsf@concordia.ellerman.id.au> <20180717183341.GQ12945@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180717183341.GQ12945@linux.vnet.ibm.com> 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 On Tue, Jul 17, 2018 at 11:33:41AM -0700, Paul E. McKenney wrote: > On Tue, Jul 17, 2018 at 09:19:15AM -0700, Linus Torvalds wrote: > > > > In particular, I find: > > > > "isync is not a memory barrier instruction, but the > > load-compare-conditional branch-isync sequence can provide this > > ordering property" > > > > so why are you doing "sync/lwsync", when it sounds like "isync/lwsync" > > (for lock/unlock) is the right thing and would already give memory > > barrier semantics? > > The PowerPC guys will correct me if I miss something here... > > The isync provides ordering roughly similar to lwsync, but nowhere near > as strong as sync, and it is sync that would be needed to cause lock > acquisition to provide full ordering. The reason for using lwsync instead > of isync is that the former proved to be faster on recent hardware. > The reason that the kernel still has the ability to instead generate > isync instructions is that some older PowerPC hardware does not provide > the lwsync instruction. If the hardware does support lwsync, the isync > instructions are overwritten with lwsync at boot time. Isn't ISYNC the instruction-sync pipeline flush instruction? That is used as an smp_rmb() here to, together with the control dependency from the LL/SC, to form a LOAD->{LOAD,STORE} (aka LOAD-ACQUIRE) ordering? Where LWSYNC provides a TSO like ordering and SYNC provides a full transitive barrier aka. smp_mb() (althgouh I think it is strictly stronger than smp_mb() since it also implies completion, which smp_mb() does not). And since both LL/SC-CTRL + ISYNC / LWSYNC are strictly CPU local, they cannot be used to create RCsc ordering.