Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3923554imm; Tue, 17 Jul 2018 12:40:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdDrb60ST2o/sAS+xIPSKlj0SMZu33LhOQkOBAOxOcetb6B/FOob5Ma9MYW3sn2sWiZlA6z X-Received: by 2002:a62:ee01:: with SMTP id e1-v6mr2032684pfi.2.1531856414961; Tue, 17 Jul 2018 12:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531856414; cv=none; d=google.com; s=arc-20160816; b=vSkzLQjPsAskqW7068iV66ROPF+BuXgTGehEKo61mi3pBJCL0LhEOIZhR00ZUFKC2Y hxTEbqRvRcVAum22n5hHjiaf9GGwsvf57BHJKgVVmQglpzGKXXe6PfEjtOrCfdnj3gP0 xQJXPOgbtNN8/YyTOon0T3VVQhcFOeQinarLr3j1ZaonTTfkiQtf0HK+uI80OwudtiFj UzDZqMV9wtVISjZoTSonmuG35UdmsBmCQAlkz+uwsEpf8TIbDtyYsI71ClW9G/Hdgg30 Rz4wyU1/z05gVw9Dst0LM1CSB7ENVqDZe/8iIWEAgyU1QOOxEhc1c5ewmWVoLAHPQVTt B6nQ== 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:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=BlqejUpASjKibQ7QlEXDa2EEemwwxK5l6ca9qGE81QI=; b=gi3p6hXG4ASFqigjnuHP7ddPwl2WpM2PY7iBJRNIOUmh/HpiMsIx97LBr6fmQa25oF Yyg3GICYAJerkHfzkm2tgNF1cRyph9kOVY8yTpFpYTkHo9rzaM5NCumb2WMd3y2CqQMg r2GEqSzdVNT5Ix1RDx5ilbqPRMFLIqITJVxd4G/fqHbAyXE5BTLdjCvSaHIc7b2mEcd0 lCXxH6zApBLKd6EcL4szKGb50x6Ijd+edVIiqEYvb/P3SAmaTxAQ9QxxSu5HVMetwdtt k9YsXgvOp5LY8cnyEWomNifsznrVaBxev1tTqmJsyzeKJprPpv2L4noDpgk1pED0OPeN tenw== 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 x19-v6si1645640pgl.660.2018.07.17.12.40.00; Tue, 17 Jul 2018 12:40:14 -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 S1730397AbeGQUL6 (ORCPT + 99 others); Tue, 17 Jul 2018 16:11:58 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:45946 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729704AbeGQUL4 (ORCPT ); Tue, 17 Jul 2018 16:11:56 -0400 Received: (qmail 3318 invoked by uid 2102); 17 Jul 2018 15:37:50 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 17 Jul 2018 15:37:50 -0400 Date: Tue, 17 Jul 2018 15:37:50 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Linus Torvalds cc: Paul McKenney , Michael Ellerman , Peter Zijlstra , , 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: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Jul 2018, Linus Torvalds wrote: > On Tue, Jul 17, 2018 at 11:31 AM Paul E. McKenney > wrote: > > > > 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. > > That's only true when looking at isync in isolation. > > Read the part I quoted. The AIX documentation implies that the > *sequence* of load-compare-conditional branch-isync is a memory > barrier, even if isync on its own is now. I'm not a huge expert on the PowerPC architecture, but I do have a pretty good understanding of the widely accepted memory model published by the Peter Sewell's group at Cambridge (PPCMEM). According to that model, load-compare-conditional branch-isync is _not_ a full memory barrier. > So I'm just saying that > > (a) isync-on-lock is supposed to be much cheaper than sync-on-lock > > (b) the AIX documentation at least implies that isync-on-lock (when > used together the the whole locking sequence) is actually a memory > barrier > > Now, admittedly the powerpc barrier instructions are unfathomable > crazy stuff, so who knows. But: > > (a) lwsync is a memory barrier for all the "easy" cases (ie > load->store, load->load, and store->load). > > (b) lwsync is *not* a memory barrier for the store->load case. > > (c) isync *is* (when in that *sequence*) a memory barrier for a > store->load case (and has to be: loads inside a spinlocked region MUST > NOT be done earlier than stores outside of it!). Why not? Instructions are allowed to migrate _into_ critical sections, just not _out_ of them. So a store preceding the start of a spinlocked region can migrate in and be executed after a load that is inside the region. Alan Stern > So a unlock/lock sequence where the unlock is using lwsync, and the > lock is using isync, should in fact be a full memory barrier (which is > the semantics we're looking for). > > So doing performance testing on sync/lwsync (for lock/unlock > respectively) seems the wrong thing to do. Please test the > isync/lwsync case instead. > > Hmm? What am I missing?