Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp8836lqn; Thu, 11 Apr 2024 12:02:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKFYLROAS15lojgji2sRkcoXNjVYidmX78J/PQF2aYBmEU0CMKrpHQfIEsxgRc5TMlE3QQmvCB05LCA+UMsD3lz4HtjtNOoXJ6uHkg6g== X-Google-Smtp-Source: AGHT+IHJas8lKyT2juauRTP613f8dJTPf/+WhUIYw1eWyZVDC3wWYrkpkUtAYCvlRbsTrc4XhYgk X-Received: by 2002:a50:baa4:0:b0:568:b622:f225 with SMTP id x33-20020a50baa4000000b00568b622f225mr467420ede.30.1712862126254; Thu, 11 Apr 2024 12:02:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712862126; cv=pass; d=google.com; s=arc-20160816; b=Lv+SB6hx8w87QadDG5yY7wOK5Lw3HQ86uiF591qxW4pDfbZI8E5ySXfpfGZfHCGM8X sBtOaHb3x0Ofp3XRqu3uoaj+Vdx7BF5r4tA0NbITU0VfQEs+G7U2mMe3HgpoTmyHCL/l T/5gCHFA9YpH+/4ofLjEd3KX1uBKhgSsCG/6Iqa6iHLfCndRQzhF1sas3BtShFoKTvk/ fydwRG4eGHyYA0OXgcevIA+9H4lOolonlT/i5INq4uV7r/u9SrDa3nkIONu6SgvlkLkZ W/of6S9TFgCRtFl4aoKm+rvSdW2ZvZZIrpTUZ6TBxmzHIinGkX9hd1dZqa8Cq5KilpTf Xyfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=XQYB8GnvNyTYVMhPz5B5OEswTYl0MJBynqxacK4LWHU=; fh=dF1qbPNMepuFTsHem5VhNG/hTBJU73cfcdGmE63FYsI=; b=WBpmrnnUowhiXmcOMVzNnXuyWETw0PXPts01x2eZZ1m9uPLw0Yv545s0EXnKWyU1MU 1DSSh590P1KAItreq7A/aS8puhYyJroL8fsqVqF0OsRoWcGm3j/dWJVf2pSO3CZ+liO5 VQrSzhq6bZxKJJ3+y/zhgro2YDWezmad4ZLJqK4D37iaOX08e/IX95xViz3xy6k6XLN+ w7+6X8SO/5Pj9YOY1ytmqcfcz3aNqeDCSIx5Qw+mGSj2zAr1lkWixK4an/Ls+K8vopvu J987MYkjntu5/e9D28arKQ2+/5szYuMMjeRAMD645t/r54RgqDsLIelwcNd19XVykpCQ vY3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marcan.st header.s=default header.b=SxfDLmbn; arc=pass (i=1 spf=pass spfdomain=marcan.st dkim=pass dkdomain=marcan.st dmarc=pass fromdomain=marcan.st); spf=pass (google.com: domain of linux-kernel+bounces-141486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p12-20020a05640243cc00b0056e07a85daasi976243edc.453.2024.04.11.12.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 12:02:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@marcan.st header.s=default header.b=SxfDLmbn; arc=pass (i=1 spf=pass spfdomain=marcan.st dkim=pass dkdomain=marcan.st dmarc=pass fromdomain=marcan.st); spf=pass (google.com: domain of linux-kernel+bounces-141486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 211881F2B438 for ; Thu, 11 Apr 2024 18:45:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 722E6205E32; Thu, 11 Apr 2024 18:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marcan.st header.i=@marcan.st header.b="SxfDLmbn" Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB5E315E88 for ; Thu, 11 Apr 2024 18:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.63.210.85 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712861027; cv=none; b=TVZNE49AqQmQm3BtYjJenEjWl4Gb0bKzZfgH5jh8jXpwlSKKy7TODV2ZHua+6AEXxqS21LEQ9tSErQOf2uY8uD6h1VedF+B7ghvBwkAWnvtJA8plppWzuaWjzRPmB3O4UjbDTEESyeLlH05/5wMrCaTa+dD95pO2VH1FMAOZ8jM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712861027; c=relaxed/simple; bh=a3JvUEhgYK+th3NCl2xP4vXg/lpXBSLqgc8nLV72rpU=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=nmBr969aRNWhXgNzpLhMIlw2aEw9BDl78QFRs+VW5qP6+yHKgd/zCSYICYrfPdweqXgACcZ6Hekz0CAarpQ4OwWAaaeYY67Ezm41PTX0pi+aThsWsDwSZgftiWrtQWaMzIcD6xE7498Q2OI7pPBtcmOYqbqZpxr0JC2Vo+M/SW8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=marcan.st; spf=pass smtp.mailfrom=marcan.st; dkim=pass (2048-bit key) header.d=marcan.st header.i=@marcan.st header.b=SxfDLmbn; arc=none smtp.client-ip=212.63.210.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 162A24269B; Thu, 11 Apr 2024 18:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1712861022; bh=a3JvUEhgYK+th3NCl2xP4vXg/lpXBSLqgc8nLV72rpU=; h=Date:Subject:From:To:Cc:References:In-Reply-To; b=SxfDLmbn4C0FHradf1Xvj6eoisfqZiNOMVhNdxdgHo1NXlIB/dbWS/wzj7bn6DGW/ NTt6SGUM8bZrQe1tL93LuYhRW67a4Imuzypj7Kyz8L5KRHP0KQqoTXOLfWYVI7bvAe M+fdkh7Z1E0OnNt1boNhIk7u9FsTO0sAekynhELR0de5yFs2lr1xtmxYdeDa6pehzF LKJiq4QJpwlqoQ+p63rnkcUDDB/Lo/UPQrqmsa+qVuYvSLpezbl3c9OIl/YtYiEgD+ sOsykq2DUWdG71dSOs48cNQHSHF+9gaFcPhQ8Kyp0Uu/YkyzblwkZj7kL+KuaSH0MS TcEp9qwJBnqDw== Message-ID: Date: Fri, 12 Apr 2024 03:43:36 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/4] arm64: Support the TSO memory model From: Hector Martin To: Will Deacon Cc: Catalin Marinas , Marc Zyngier , Mark Rutland , Zayd Qumsieh , Justin Lu , Ryan Houdek , Mark Brown , Ard Biesheuvel , Mateusz Guzik , Anshuman Khandual , Oliver Upton , Miguel Luis , Joey Gouly , Christoph Paasch , Kees Cook , Sami Tolvanen , Baoquan He , Joel Granados , Dawei Li , Andrew Morton , Florent Revest , David Hildenbrand , Stefan Roesch , Andy Chiu , Josh Triplett , Oleg Nesterov , Helge Deller , Zev Weiss , Ondrej Mosnacek , Miguel Ojeda , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Asahi Linux References: <20240411-tso-v1-0-754f11abfbff@marcan.st> <20240411132853.GA26481@willie-the-truck> <28ab55b3-e699-4487-b332-f1f20a6b22a1@marcan.st> Content-Language: en-US In-Reply-To: <28ab55b3-e699-4487-b332-f1f20a6b22a1@marcan.st> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024/04/11 23:19, Hector Martin wrote: >> >> An alternative option is to go down the SPARC RMO route and just enable >> TSO statically (although presumably in the firmware) for Apple silicon. >> I'm assuming that has a performance impact for native code? > > Correct. We already have this as a bootloader option, but it is not > desirable. Plus, userspace code still needs a way to *discover* that TSO > is enabled for correctness, so it can automatically decide whether to > use stronger or weaker instructions. To add some numbers to this (I was just made aware of this paper): https://www.sra.uni-hannover.de/Publications/2023/tosting-arcs23/wrenger_23_arcs.pdf Using TSO globally has, on average, a 9% performance hit, so that is clearly off the table as a general solution. Meanwhile, more detailed microbenchmarks often show TSO as having better performance than outright using acquire/release instructions without TSO. Therefore, just giving up on TSO and using acq/rel semantics for emulators is also not an acceptable solution. Additionally, the general load/store instructions on ARM have more flexible addressing modes than the synchronizing ones, and since general x86 emulation requires *all* loads and stores to be like this in a non-TSO model (without much more complex/expensive program analysis to determine where this can be elided), the perf impact is definitely worse for emulation (e.g. stack accesses are affected) than for a microbenchmark where only the "target" test instructions are being modified. - Hector