Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp992750ybl; Thu, 12 Dec 2019 08:05:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxB68Hpur9ciATLlHVF+DgQGkz4gxUWOHooeQPDjJvARnxhByKQ0uqzCGLe3P1AmBTZvXad X-Received: by 2002:aca:568d:: with SMTP id k135mr5541259oib.45.1576166713147; Thu, 12 Dec 2019 08:05:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576166713; cv=none; d=google.com; s=arc-20160816; b=AVhXq0kXVegpZzEjaAsLtkQJy1+EbeHDNrXE1fPgBVQhqHqJk66l9B3mE08+qh6C5O hhVIEy0in8gtU41iHZL6S6h5C6QU6RpwWLc+9SezEwscLoQTmw6k6GfFsfzZYrVU9xGg 8MDunl2CVnBqg+FwijZImK0eTu8Hp+YgGSxNb1CBbpc6nIkcoEXGEvOsRWp8pjR5ELCs eUD7OHIgHNI5+9bxwpnnJRkv5mP/YeKWi05ywMhQs3FJARa7xmvSucn+38md2kmfJGc/ 1JpIOD759I48TdJpJFRNqiHrdKQItDvfFLuvHpee11tMHkcyt8294s0mfM72AOAU4kyc MKmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=beXsVnBCg65xtUboT75oX9AtZcA8LYYNBSRgmS4rw1c=; b=TgP23dEc2juoME06tJhHkjFdTsfJPwud+WQoseOLW7tReSOh/cnX7Gjoc3j8XpTRgX VeIgSIG83sal1aYD2l+xuy0GrrmPu2SLjt3gqNm8bpWrXcCicBbSvIupJfHYkuiNeiXb y40ZR9ERo8zFtoF99dpx50fBBkRzCla7LofeiRljFQ+f4rD/PG747A6VOasW7y8l2v6k hP5vlJ4Y8OxPLohO5lBHFuNBg7KyTi/6qoj0GEu3RBxtciHnaVshMY3yqtgkWbvR/MQU FT9GuRkRtZg7J+i+0QQLqaI3rwmsbsL5hcFIbh4g9dKxmpRovBy3g12sA9rHs96GjMK2 zu7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=BzKhVTSl; 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 a12si3368677oie.87.2019.12.12.08.04.52; Thu, 12 Dec 2019 08:05:13 -0800 (PST) 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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=BzKhVTSl; 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 S1729705AbfLLQCQ (ORCPT + 99 others); Thu, 12 Dec 2019 11:02:16 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:43708 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729247AbfLLQCQ (ORCPT ); Thu, 12 Dec 2019 11:02:16 -0500 Received: by mail-pj1-f68.google.com with SMTP id g4so1196363pjs.10 for ; Thu, 12 Dec 2019 08:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=beXsVnBCg65xtUboT75oX9AtZcA8LYYNBSRgmS4rw1c=; b=BzKhVTSlGuNyeBMHGRoibZUGNaJADrOyA/geMiSI5zz4CL7FspuNuY3+tcMVKuplhH GNjmWlJCQ2J75hPY2BaqO3toa054NHUqKbljgXRPEwqWw2ygX4nT3G5le3u+TclHCQrM v97ERCKgcxf20sEjQHKdpL+8t4PfWEip7808LrpGXrACv/wOjl2M0qulLRrvhsvyUH16 /C8c22rL2nJc7qUbOAscSEK+edP0L3IoiBfUNusiagp35oZh0YtEwiVOiOVZV56GA4gW zoXixR6n8/EbSeBI9CWH799fUk2lQz+mxjKxwe+eYSCpXDCLADWL9p8d4oG+hp6qW6Oz syMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=beXsVnBCg65xtUboT75oX9AtZcA8LYYNBSRgmS4rw1c=; b=sc697GXXj1p/hX23wHawCbbP2gTRJgwyyT/BIJJw5ixCgRs6sLE1oeY+3aRF/dFjwD FotR94neMDhwK+n7z15GfcLuzXZP42xA4ZLBt94QNMwXN4wlcvd7BuQZ66BzxrZW0H0+ 0KvXC1diaTPpjF7r/8uJ8kbvNAAZ5meP0tWdKkR47lMWhPXMdZWGCsshRWoDOXJYI5cz L5V4s8J2cJiQ0D8g2ASt79qCcId/TNC79UKawkOgBlzFwKF2+BF7pgGyBp3aYOteUO3b 8sMIvVSChwsNbJ0OUNv75oALJ6XnDS6PB+MjV6leG+1yZedZG5PxBPDmgr4J6wk74+Yz F4ww== X-Gm-Message-State: APjAAAV5xQqn0uepBz9D19YuLYYAnTKRO6ozeKgn27+zZB5QM36gvtXZ sRKWQUi0KBD9T2N+H7Qc6El7LA== X-Received: by 2002:a17:90a:86c2:: with SMTP id y2mr10998665pjv.72.1576166535330; Thu, 12 Dec 2019 08:02:15 -0800 (PST) Received: from ?IPv6:2601:646:c200:1ef2:51bf:c5fc:5a97:2793? ([2601:646:c200:1ef2:51bf:c5fc:5a97:2793]) by smtp.gmail.com with ESMTPSA id h6sm7089643pgq.61.2019.12.12.08.02.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Dec 2019 08:02:14 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v10 6/6] x86/split_lock: Enable split lock detection by kernel parameter Date: Thu, 12 Dec 2019 08:02:13 -0800 Message-Id: References: <20191212130421.GX2827@hirez.programming.kicks-ass.net> Cc: David Laight , "Luck, Tony" , Andy Lutomirski , "Yu, Fenghua" , Ingo Molnar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , "Raj, Ashok" , "Shankar, Ravi V" , linux-kernel , x86 , Will Deacon In-Reply-To: <20191212130421.GX2827@hirez.programming.kicks-ass.net> To: Peter Zijlstra X-Mailer: iPhone Mail (17A878) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Dec 12, 2019, at 5:04 AM, Peter Zijlstra wrote: >=20 > Waiting for a store-buffer drain is *expensive*. >=20 > Try timing: >=20 > LOCK INC (ptr); >=20 > vs >=20 > LOCK INC (ptr); > MFENCE >=20 > My guess is the second one *far* more expensive. MFENCE drains (and waits > for completion thereof) the store-buffer -- it must since it fences > against non-coherent stuff. MFENCE also implies LFENCE, and LFENCE is fairly slow despite having no arch= itectural semantics other than blocking speculative execution. AFAICT, in th= e absence of side channels timing oddities, there is no code whatsoever that= would be correct with LFENCE but incorrect without it. =E2=80=9CSerializati= on=E2=80=9D is, to some extent, a weaker example of this =E2=80=94 MOV to CR= 2 is *much* slower than MFENCE or LOCK despite the fact that, as far as the m= emory model is concerned, it doesn=E2=80=99t do a whole lot more. So the fact that draining some buffer or stalling some superscalar thingy is= expensive doesn=E2=80=99t necessarily mean that the lack of said draining i= s observable in the memory model. (LFENCE before RDTSC counts as =E2=80=9Ctiming=E2=80=9D here.)