Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp927089yba; Fri, 3 May 2019 12:50:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHIoujbwvA53BtvoPmmhW5wKGfwzeR3mXXxOe3aPmKz/yAK/w9EK/ku2DZpVU2Ghr9XwyK X-Received: by 2002:a63:28c8:: with SMTP id o191mr13095537pgo.164.1556913012926; Fri, 03 May 2019 12:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556913012; cv=none; d=google.com; s=arc-20160816; b=QexA3VmXFAYSsNzCvolBeljpUtPHEuXPGD483X0F3+qlVak4vDFjwndW9F1YjY8+sX J1vWJIWv7aq5rPVEvLdiUu2WNuMpIbSGHV/1fLqG9OjxLKAYagcRxMS4aFUYyHagQ6Ys dOxCclv7L2YC5GXLJsw+5yH92ZPEG6H2b7UOm0CLhsTSDuK1nOm9GP9qpHBCd4/1+VcX I8hqVqlwuL1DifbwH6Y5tn5PD+Bq5Y6sRrsLIORRahbF+ATLjoxBqKus9iJcvK8dAlGp dDBdo6Co3/oyAPDt0Z9vhtOutqdcB5TEOqQt8j2V+lRlBoCzTz1smsToxel5WOo20pg5 6QSg== 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; bh=VveNzZAjXPBlYkWe2poT9sM0nBecoUnFUlLniFmqy38=; b=XEZF4ioF50oRuEumKkBGhpLA0iK2/JK6LdIxhjzO/aXp2zVneEOu5Lb+iyv1OywoXj Y452MW+yXOeTwlZWDmDMbqfz6hZLTg32NsTyZ2SFAlm0l6zJZqZrqWcZ4nj+R4DpdqTO ZEHXXqtA5VWjfD40w92jQ96qCiRi2VadFRUoJt8cJexjR8q1HWEYIc+bvtYNRwx9BPGI 5AUp12tUMzRK9D0QzkXcAGVGRVhf0moeAkayI34g1PKXW1eSRX+HpG8WJP1HDfd+3sGb mIwRpzlo5GAROqTeUQoI2zEbwUgUg6b9pUXNxElhWo/nI59OV+a4PyEcW5yN+agzANcM IgVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QXskVGEG; 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 i76si3713956pgd.558.2019.05.03.12.49.56; Fri, 03 May 2019 12:50: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=pass header.i=@linux-foundation.org header.s=google header.b=QXskVGEG; 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 S1727244AbfECTk4 (ORCPT + 99 others); Fri, 3 May 2019 15:40:56 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:41194 "EHLO mail-lj1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfECTkz (ORCPT ); Fri, 3 May 2019 15:40:55 -0400 Received: by mail-lj1-f179.google.com with SMTP id k8so6182224lja.8 for ; Fri, 03 May 2019 12:40:54 -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=VveNzZAjXPBlYkWe2poT9sM0nBecoUnFUlLniFmqy38=; b=QXskVGEGvKifmiGq0XwJk+jLIWyk2HquWywFpIRDLlglZjN3GPkI4xyp+M2/GjUy95 nvgp4UbOqLkdLtBy1tbU9hnCLo3S7Or1YJxBoCHN7LZpzhj+djviLLsDFMQ8U6cZJA8m uqwoEPfAUULAYl55QiZti76rKbbs12Z71hD20= 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=VveNzZAjXPBlYkWe2poT9sM0nBecoUnFUlLniFmqy38=; b=qiYInDHFJ3z2vFUI8dFDfhhiWGRlgtCwMMsaxfhHFtVkYehjAT600xhfmJhgU1NS9h FNY5Shli4zUcw2iy7fpAoR0/CD1pUeTEKdLXDisrisNYphJLv2CvvNcM1QbrHzL0iDxa BjyPWhFsjjFjex+BphQVaNBv18Eeb5sXqgbscEdWTBGvOIbujSna9z6JIl6hs/HeDD58 gz8w/7I0UzRT0/dV7mXpGuaBWvKeQZaD5dR7qg+/hkzUEraSL3m2nEstGX/Pn7UU0A0w 6H3HpJUHw6rMCnUunGM0GedbLlBGLNPO3oRiIspzkj3X9a/mFnhHPyl2vDYjf6DqluSk P3HA== X-Gm-Message-State: APjAAAVfWIYCC6UsWWHdeoII40D6sg5u4HgH9E4U472qZwp+0kRFjM/K qxrInFmzLvfiyiGgwpJPu8Z8nan/RcU= X-Received: by 2002:a2e:9546:: with SMTP id t6mr6118540ljh.51.1556912452793; Fri, 03 May 2019 12:40:52 -0700 (PDT) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id i64sm659715lfe.18.2019.05.03.12.40.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 12:40:51 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id o16so5186122lfl.7 for ; Fri, 03 May 2019 12:40:50 -0700 (PDT) X-Received: by 2002:a19:f50e:: with SMTP id j14mr5925434lfb.11.1556912450582; Fri, 03 May 2019 12:40:50 -0700 (PDT) MIME-Version: 1.0 References: <20190429145159.GA29076@hc> <20190502082741.GE13955@hc> <20190502231858.GB13168@dc5-eodlnx05.marvell.com> In-Reply-To: <20190502231858.GB13168@dc5-eodlnx05.marvell.com> From: Linus Torvalds Date: Fri, 3 May 2019 12:40:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] Disable lockref on arm64 To: Jayachandran Chandrasekharan Nair Cc: Jan Glauber , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" 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 Thu, May 2, 2019 at 4:19 PM Jayachandran Chandrasekharan Nair wrote: >> > I don't really see the point your are making about hardware. If you > look at the test case, you have about 64 cores doing CAS to the same > location. At any point one of them will succeed and the other 63 will > fail - and in our case since cpu_relax is a nop, they sit in a tight > loop mostly failing. No. My point is that the others will *not* fail, if your cache coherency acts sane. Here's the deal: with a cmpxchg loop, no cacheline should *ever* be in shared mode as part of the loop. Agreed? Even if the cmpxchg is done with ldx/stx, the ldx should do a read-for-write cycle, so at no single time will you ever have a shared cacheline. And once one CPU gets ownership of the line, it doesn't lose it immediately, so the next cmpxchg will *succeed*. So at most, the *first* cmpxchg will fail (because that's the one that was fed not by a previous cmpxchg, but by a regular load (which we'd *like* to do as a "load-for-ownership" load, but we don't have the interfaces to do that). But the second cmpxchg should basically always succeed, unless something exceptional happened (maybe an interrupt, maybe something big like that). Ergo: if you have a case of failing cmpxchg a lot, your cache coherency is simply bad. Your hardware people should be ashamed of themselves for letting go of the cacheline without just letting the next cmpxchg succeed. Notice how there is *NO* ping-pong. Sure, the cacheline moves around, but every time it moves around just once, a thread makes progress. None of this "for every progrress, there are 63 threads that fail" garbage that you're claiming is normal. It's not normal, and it's not inevitable. If it really happens, it's a sign of bad hardware. Just own it, and talk to the hw people, and make sure it gets fixed in ThunderX3. Ok? Linus