Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1120247lqo; Thu, 9 May 2024 05:32:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3Y9WI5oloS/mHXA5TRsLSRi0hQ5qibVmGqGgaimq5d1TlBUdS3W1YUlQf3jTytN3mlP9R7+8mu/oIQRLZASSCWvZWt/yx0ucdBHJggQ== X-Google-Smtp-Source: AGHT+IH9UCWqG6/DETzs+eMkA+nRPoePyS3/J+mE2ucoYSzPzhD3Mt7Hr/JrRFwAMI7pykVpio30 X-Received: by 2002:a17:90a:e54b:b0:2b2:468c:9fdd with SMTP id 98e67ed59e1d1-2b6163a2be0mr5516646a91.8.1715257936002; Thu, 09 May 2024 05:32:16 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b670f585fcsi1382247a91.69.2024.05.09.05.32.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 05:32:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-174501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174501-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9638D28389B for ; Thu, 9 May 2024 12:32:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 712CB1A2C28; Thu, 9 May 2024 12:32:10 +0000 (UTC) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C47613175D for ; Thu, 9 May 2024 12:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715257928; cv=none; b=tnUPty0m52EtZxiU1R+2+NqysskhfkKfjN2mjLbk6gDZ5LjIwxGjhW4l8ajQxjh7z65MGBaXChKBSG8qkDanz6GbCMACKiKzr9b3o4S4DgYYLcf+4dKpg+JMo0YWjF068zrFOTOyUkzhTOm+WUD58KZI2MZk5PSIhN/r5bxi8DE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715257928; c=relaxed/simple; bh=xgZMRL2Kwcto3vC3Q/mNIYCP0B03xrT0cPEyuQHr8k4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IhhSq9qBeZ2MMpHsBcmr4I6sf+DqOyDT9+o4KqHyaq9ppqY4dvoAkUnjfX5cp2msafgw3u4HS2zUEPGEBHkJnRf5fThNMzUCyVf90wVn31jnHlNOPe3TGMbDHEDdlB0h5Oh9l4GDmR0IjxRX/aNmg6aeqGCaiSpwlMyuCrvH4AQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gompa.dev; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gompa.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5210684cee6so830617e87.0 for ; Thu, 09 May 2024 05:32:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715257922; x=1715862722; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xgZMRL2Kwcto3vC3Q/mNIYCP0B03xrT0cPEyuQHr8k4=; b=EOlXpAToprSbFSr/kMnL3G9JqLOMyuNX9dr0TghyB6DaYUeydN2xUOSefxgBlYt2Ea 9I4DHYt5Mo3uTSQQalqG+WAd+7N83+2Azinnguqc1IwoCEV2zx2hWSGbdvl7l8KPKj8V 2m+tjtcBRFuSbh6Mrkak8QKuN94CjBSKt3TBsQbM3076GtqirxOfKqA6hzWLWzaIYhbU 4Ndn+Mfll5/6aqCgR1/cOsFu8DvanEP+AzTHs54g7GLOS4zSudnLekRzOwGRxuOwPIZD Ec+i533LOLmTkqWMViBlUKoxJfgwWXdCGwWXbSH068BqD01UkGx1OZodYzQxwHr0VTOt bMQQ== X-Forwarded-Encrypted: i=1; AJvYcCUja8O+mrdSqXuJrt+BXPN2RflHuDIGH6dTkjEZAvwUjW03AOXv7Ds6h9WlRBRyQL4lC9HpyMVcAaZuHUCjxzJnisUdYOofllbj76e+ X-Gm-Message-State: AOJu0YxD9LmUJMCKwz9WU/uf7NcdNC0M7cIfUsEnlqOBp/CUdr1yA2YP z2qLtfgnWyaBXjPym31/K0FQ5tTOOAST9WiYl1goIQxx8Bz/vJqj2GyP3ABL2MFbfw== X-Received: by 2002:ac2:43c1:0:b0:51c:cd8d:2865 with SMTP id 2adb3069b0e04-5217cc4585bmr3034531e87.44.1715257922475; Thu, 09 May 2024 05:32:02 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-521f39d2d57sm278477e87.260.2024.05.09.05.32.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 May 2024 05:32:02 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2dcc8d10d39so9199581fa.3 for ; Thu, 09 May 2024 05:32:02 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVhnIQ28qPso6cFnmKwrtAyjDWodgWBX+TpZ6U5mdMd4GH1zP/MTDVC2mmWyn7wZ6R1JebAXDs6ud8D8nfa00NMWys/je8ouUsNXFMW X-Received: by 2002:a17:906:f1d5:b0:a59:c209:3e33 with SMTP id a640c23a62f3a-a59fb9492famr373848466b.15.1715257901263; Thu, 09 May 2024 05:31:41 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240411-tso-v1-0-754f11abfbff@marcan.st> <20240411132853.GA26481@willie-the-truck> <87seythqct.fsf@draig.linaro.org> In-Reply-To: From: Neal Gompa Date: Thu, 9 May 2024 06:31:04 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/4] arm64: Support the TSO memory model To: Catalin Marinas Cc: Ard Biesheuvel , =?UTF-8?B?QWxleCBCZW5uw6ll?= , Will Deacon , Hector Martin , Marc Zyngier , Mark Rutland , Zayd Qumsieh , Justin Lu , Ryan Houdek , Mark Brown , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 9, 2024 at 5:13=E2=80=AFAM Catalin Marinas wrote: > > On Tue, May 07, 2024 at 04:52:30PM +0200, Ard Biesheuvel wrote: > > On Tue, 7 May 2024 at 12:24, Alex Benn=C3=A9e = wrote: > > > I think the main use case here is for emulation. When we run x86-on-a= rm > > > in QEMU we do currently insert lots of extra barrier instructions on > > > every load and store. If we can probe and set a TSO mode I can assure > > > you we'll do the right thing ;-) > > > > Without a public specification of what TSO mode actually entails, > > deciding which of those barriers can be dropped is not going to be as > > straight-forward as you make it out to be. > > > > Apple's TSO mode is vertically integrated with Rosetta, which means > > that TSO mode provides whatever Rosetta needs to run x86 code > > correctly, and that it could mean different things on different > > generations of the micro-architecture. And whether Apple's TSO is the > > same as Fujitsu's is anyone's guess afaik. > > Indeed. Apart from using impdef registers, that's what I think is the > second biggest problem with this feature (and the corresponding > patches). We don't know the precise memory model, we can't tell whether > this TSO bit is stored in the TLB. If it is, is it per ASID/VMID? The > other problem Marc raised is what memory model is between two CPUs where > only one has the TSO bit set? Does it only break the TSO model or is > there a chance that it also breaks the default relaxed model? What other > TSO flavours are out there, how do they compare with the Apple one? > > > Running a game and seeing it perform better is great, but it is not > > the kind of rigor we usually attempt to apply when adding support for > > architectural features. Hopefully, there will be some architectural > > support for this in the future, but without any spec that defines the > > memory model it implements, I am not convinced we should merge this. > > There is FEAT_LRCPC (available on Apple Silicon from M2 onwards). Rather > than having a big knob to turn TSO on or off, this feature introduces > instructions that permit a code generator to get the TSO semantics in a > more efficient way (e.g. using LDAPR+STLR instead of the stricter > LDAR+STLR; not sure how well these are implemented on the Apple > Silicon). There are further improvements in FEAT_LRCPC{2,3} (with the > latter adding support for SIMD but not available in hardware yet). So > the direction from Arm is pretty clear, acknowledging that there is a > need for such TSO emulation but not in the way of undocumented impdef > registers. Whether more is needed here, I guess people working on > emulators could reach out to Arm or CPU vendors with suggestions (the > path to the architects is not straightforward, usually legal has a say, > but it's doable, there are formal channels already). > > I see the impdef hardware TSO options as temporary until CPU > implementations catch up to architected FEAT_LRCPC*. Given the problems > already stated in this thread, I think such hacks should be carried > downstream and (hopefully) will eventually vanish. Maybe those TSO knobs > currently make an emulation faster than FEAT_LRCPC* but that's feedback > to go to the microarchitects on the implementation (or architects on > what other instructions should be covered). > They cannot ever "vanish" because we are supporting every Mx platform back to the first one. The M1 series will never have FEAT_LRCPC. I do not think it is unreasonable to support this method when we know what the CPU platform is and FEAT_LRCPC does not exist. -- =E7=9C=9F=E5=AE=9F=E3=81=AF=E3=81=84=E3=81=A4=E3=82=82=E4=B8=80=E3=81=A4=EF= =BC=81/ Always, there's only one truth!