Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3877941imm; Tue, 17 Jul 2018 11:51:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdgskQnsdA8LygLqKHqDRhjR9WmY+XGR6JbTKaQigfa+T72hv15hCx3wW0vF6c8x9R/SC5D X-Received: by 2002:a63:6849:: with SMTP id d70-v6mr2660932pgc.7.1531853461069; Tue, 17 Jul 2018 11:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531853461; cv=none; d=google.com; s=arc-20160816; b=N+ZhPdY1AYZ8D5M7REGECdV5XdNKTxJT9A0yLZxs71Awl/bu9bE/jHzNKFnAIA+PZA GEIecc7ITbXLt2aV/IAwmNoBjeK4gOtvrhZLfm/uNyvEj4yTvcCP+bKdK1nNtzgUzZ6E cTJZacAZXPF3kNU+GrzPbpxNtLQokhXg1RpgTULdmmJK8kSamQKd+13EdSSV3Ts3JxXk P91PL9pupty3RNTUswLnasIRszWAK0rYAf2avZSIRtHtZFdyEMt/lcfXXjLadLLybGDp zOAK++XmhFwK6iTCBv4ePLS012jPgepas2Tpt+hPUwKEMYBYw8esZY2Cn78icPogwSgD fpUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=BXgjsYoGEi0t/icWaJRMbUapyFLjYc7yBQPgK570efI=; b=v4wBJ3KSOz650ethfIUwo/LTC6QRaSLfgYDjGEkXJR+vxd14h50v3HDirR1IoBboVq UH0HLAdMNM7NYYIR3q+H/FYearsP6SeWBeN3jvsJD7wAO71TQg7vnpypwrBbi7Ema+/X 3jLUMH/HTwuHjebL9+s8UqM0Wn1uYf8pJKezC2sm7jcYplsC2BXsO/xJ/p+e7obRlNlH hADpHj1WN+kqdEofcUJsqXjSUgEJFyXlYfaAefmGRB3mSGh6uISvcGoKMSDIf0RuxFNy Zakxsd7FN2YKHmS+b+zCp5lG8VwFImYWJI2kyfJf8NRz1PF0o4gFEVUNNT3nO0nnQ5zm 6YDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=KgY9GqI8; 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 f67-v6si1524581plb.460.2018.07.17.11.50.45; Tue, 17 Jul 2018 11:51:01 -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=pass header.i=@linux-foundation.org header.s=google header.b=KgY9GqI8; 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 S1730092AbeGQTXu (ORCPT + 99 others); Tue, 17 Jul 2018 15:23:50 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:38906 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729708AbeGQTXu (ORCPT ); Tue, 17 Jul 2018 15:23:50 -0400 Received: by mail-it0-f66.google.com with SMTP id v71-v6so605856itb.3 for ; Tue, 17 Jul 2018 11:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BXgjsYoGEi0t/icWaJRMbUapyFLjYc7yBQPgK570efI=; b=KgY9GqI8SHLYRmxBgYmdCMfJ94SUc9eUH2rv2ZIZ2picUBTcxYiwElXVLFhDUVP9ok X886Y4irw915rmRPPW8g+V588PknRnjV2XRo69E6fUfPDASM9qFzq3mlFkK3yJPqd/Ql d00UsCPAMecdauOpwf75U0qwRb7dq/tJJlWAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BXgjsYoGEi0t/icWaJRMbUapyFLjYc7yBQPgK570efI=; b=KKGSxuSvGXyMWFfm+OBjUavve1za0WyItRSyWHdGkZXyHvDaELJdvG6wWGR9JgcA7c 01YEW7DN8zrFMjRY/5j+5bMiM+Hs/AVH8o6hGiCEr367lVFBMGC64ZZ0yR3DTVAAPb7C TGyqkuHnyjZ4vG68RNSxzjBW9OyKW9B0vH7WkBbruwvT2Mgr5Vk3fwo+fFUKA2aOjN19 lWkUhFXjqw2aEycfl7YxJdpOjRrDauTm+SUnuHk9lfEq7ma/zDKjyr8D+PfJMwTbydkK SnX6uExT0rVl9j79/Nmvh805IMSAcqHcwAMMxk/8Fp9dtC4vbcTOjpxuBqQD+WmXCdOu sf0w== X-Gm-Message-State: AOUpUlFqiWid675CoFIy1ZgXW+Y8c3GxUwG556QQzf8NRzX45xg9bbbS 68YXnAuJzLeKBwUXQDeBMLf1NAh8gJzI3kAj0WE= X-Received: by 2002:a24:94f:: with SMTP id 76-v6mr2572971itm.113.1531853392872; Tue, 17 Jul 2018 11:49:52 -0700 (PDT) MIME-Version: 1.0 References: <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> <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> In-Reply-To: From: Linus Torvalds Date: Tue, 17 Jul 2018 11:49:41 -0700 Message-ID: Subject: Re: [PATCH v2] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire To: Paul McKenney Cc: Michael Ellerman , Peter Zijlstra , 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 Content-Type: text/plain; charset="UTF-8" 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:44 AM Linus Torvalds wrote: > > (a) lwsync is a memory barrier for all the "easy" cases (ie > load->store, load->load, and store->load). That last one should have been "store->store", of course. So 'lwsync' gives smp_rmb(), smp_wmb(), and smp_load_acquire() semantics (which are the usual "no barrier needed at all" suspects for things like x86). What lwsync lacks is store->load ordering. So: > (b) lwsync is *not* a memory barrier for the store->load case. BUT, this is where isync comes in: > (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!). which is why I think that a spinlock implementation that uses isync would give us the semantics we want, without the use of the crazy expensive 'sync' that Michael tested (and which apparently gets horrible 10% scheduler performance regressions at least on some powerpc CPU's). Linus