Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1173294imm; Fri, 13 Jul 2018 12:57:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfwHOqFQjYvLJg/Kb8PsAAiaXrGkifUy3+tYiDhD9WzCcoTCnFVNMf+BUCURf4CjnHGMUqV X-Received: by 2002:a63:1b17:: with SMTP id b23-v6mr7398091pgb.275.1531511874736; Fri, 13 Jul 2018 12:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531511874; cv=none; d=google.com; s=arc-20160816; b=bceHKz6hvzsFsSgdXtnWzAqP5tvhngAgXwY9yXhasRBS/Dt9V3Lcrl+T5lXOVOQGo/ baaw7dhgJjERL9Gy6iOoZ2x7vZkx17y9WaZHXwN/Gpkn9u0Sepc2eawH2vxMBNaskM4Q E8VCNFJ+S8VCX8KYM8O+TS0I/dEvaYSTzMrBObG/Y3s1xbJLxhdYqRw1jcXzM1i50FH5 E9UBTu7hiBV9eCorpXKURpeKb6yd9PNHYhWY0+5aTHppCDdqhfu5R54ybm22+uz/hX/8 Si4JWD1bphJgxCXJ9sdaH86O5NZU5Gu1d5LVySmrYBtmvhAFUGLkgAHwp5t1T6Nwkowu fBBw== 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=Q/Js3KytNOsqi8HibIuYO/2oMnnNCudNRagaMbRTuYQ=; b=oXUuYUVusxMQNduKWyUM23Q/oFtcn3SYwFqbFkVRh/c/EAvJtEtCAYaMSvSh9T83bZ ZnFgnAbrQo9IBdZnCC5lVmXsMivKO3zDCofp+ZbaxBTfx7sMvqtSIgvwK9bTdcEwmDrO 4wUiGMhTAgJyMYj04ETYZbAQctk3MHcGa9UPm1oLqy5JGYlO+a8W4Z92UBrrZQaes606 UOvUOIGu8y9Nkp0ln1ovNma9S7W058qv0/qvP3RZvqueg/ocYwWcsHm4BNdPIzrb47Kt xlG5v/td7mOL2EYjCYSlI3W0Wmy5Twz/AdDeBkxpveMn8Ak8PQ+niTdh7iALe5UNkPB3 n0xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GhT+VVgb; 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 d26-v6si23662249pge.679.2018.07.13.12.57.39; Fri, 13 Jul 2018 12:57:54 -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=@amarulasolutions.com header.s=google header.b=GhT+VVgb; 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 S1731900AbeGMUNF (ORCPT + 99 others); Fri, 13 Jul 2018 16:13:05 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38000 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731329AbeGMUNF (ORCPT ); Fri, 13 Jul 2018 16:13:05 -0400 Received: by mail-wr1-f66.google.com with SMTP id m1-v6so13459299wrg.5 for ; Fri, 13 Jul 2018 12:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Q/Js3KytNOsqi8HibIuYO/2oMnnNCudNRagaMbRTuYQ=; b=GhT+VVgbaAiOoTjtSfPs6IOGU86aNx8DgS3RNWSiDdbn9NV+oqf9PYgDtOF+Q07sq6 I68tu9jv5GNojizhLidVDCcGEOSRD8xZzSmw/eKGnCoqZ1766z6BaV6Zvn9CXX0ojDdf UKKonJziT5VEgGa1smTRXK2MeJBQWCA67vxSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Q/Js3KytNOsqi8HibIuYO/2oMnnNCudNRagaMbRTuYQ=; b=Drx7iCZqwoRsAuUJO4qsLOdyoEeNSZ6srV9J91J/6vxRnm4aW+tngdTPY/wPDz4mYv 0oAjEdGo3/HLajg0Fx7cyVBQdow2tphBA6MkKVe3v2aovutcFEocGEtT82p5ho5QoLdJ ajcHZ176nvW3TetTnxaclw4ekC7U/xxr2XU0+f4RdGWKK/C/eIx3enaSnkz113PeSM3T mKB78bfj+dIiBvCALiLQGRb+nvUi9khLaQ6kIkZdMGth5NZwrq6nOsmdseyIJVN81V/z CCygdnRbXzLI1fRFCQI/j5kxS4w9ZokcrqLOyG4MqGVd/4kzErhSlN/cWOTTlTTU1J3t uaaA== X-Gm-Message-State: AOUpUlEC6xaAbbvYLaJvW6M21R8lWUhB73StSVXO85h24j4vJsg1OPZ4 7MaPscABMgfKPs3vSHZqc56laQ== X-Received: by 2002:adf:f6c4:: with SMTP id y4-v6mr6260907wrp.4.1531511819713; Fri, 13 Jul 2018 12:56:59 -0700 (PDT) Received: from andrea ([94.230.152.15]) by smtp.gmail.com with ESMTPSA id w4-v6sm10329687wrt.40.2018.07.13.12.56.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 12:56:58 -0700 (PDT) Date: Fri, 13 Jul 2018 21:56:50 +0200 From: Andrea Parri To: Peter Zijlstra Cc: Michael Ellerman , Linus Torvalds , Paul McKenney , Alan Stern , 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: <20180713195650.GA2408@andrea> 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> <20180713164239.GZ2494@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180713164239.GZ2494@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 13, 2018 at 06:42:39PM +0200, Peter Zijlstra wrote: > > 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 :-) :-) One trivia about seems due: it's of course very easy to stick a full or a "tso" fence in one's spin_lock() implementation, or to tight the semantics of such a primitive; removing this fence, or weakening the semantics is another matter... (/me reminding about that spin_is_locked() discussion...) Andrea