Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp106463lqh; Thu, 30 May 2024 15:57:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtYd03j1L+UibkHp8ZAKAXpHIp8hRgn2GIS8lzp/G4eZ0tn/U3rVjX5C6j1VdDsaLnLZ9GTsUs6nZSIBcm6NxkoETonYOB6STvGP+/sg== X-Google-Smtp-Source: AGHT+IGOOZ31IoiKNzw6ThiRmnVaNInVxFPRcELEUGDf2sUunba6Vy4ZDvtauAwTk5+q9TsS6SSJ X-Received: by 2002:a17:906:a2d0:b0:a58:f13d:d378 with SMTP id a640c23a62f3a-a681f87f4d2mr13465766b.13.1717109866348; Thu, 30 May 2024 15:57:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717109866; cv=pass; d=google.com; s=arc-20160816; b=CdxhgmzjZPqNL7NxsK0gLrAlcWPnvUBuGnhCHaAZd+20FpgargcMnsEbEKANROOYgV QMBvwfTMA7FmPgtPLVyHEFx3W+s/V7Jpa3Y2MqoQAqsLPiiPvaT+QJFNU0IoYR66DuNT a23BBCCcj540nXL16qIRgBCuT1QpORrKwxbb1TQZDX63rE4ZhXTtfJOEbMwLvLZLcwaZ y+eobz4SiDCrGLZVbBaRDsJzJhXtTI/q3gRkqz3/o6xJlgMM2xeNMOP0fNajXjTTpLXP 928/aX+YJy8dw1zWWsdByGDv7oAnnt5KJvK1e7Uf5iwItHCuV3MwJaaBCSz4cW+e1yfM BgIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date; bh=WwzhThpLvfKV3jaPuALiSJ2tq5BZ9pWFr0rhfxImyOg=; fh=OzINBu/MjnJ/GsQ6s+qc/dFU4Ezmt1dRiHR2Vub0/V0=; b=D3WLsl1ocz6tbfSpWausxnPi1YeOLNfRtkR+aqdh6eJ7llM13opA99z8TDmxpJxAr5 Ga/O0PYSxZEYF3naPSLoWVyvZBlpkCQBtONsVV3jT57MchAkZja8JP0nu1vud0ln1Cit O3BCzH4x9fzh39ha6B61rAXg9y1COKx0aG13snsc4UNiyPuFc2iBehqsl0hreQHLqJBl cwNmup+lDdvhc56RYOsClMdDCRTD6+XfSqL39j5RXz/AhBXivJg1bQEEBA56g2kS9tEZ ZS5HaacHxMKRxIhT/SG/d5FGlI9lHNAYb2QhOe6G47hW0jiz6bwUufYoA+4tfhzTG1TD FSQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-195994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195994-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a67eae70aa9si21945266b.754.2024.05.30.15.57.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 15:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195994-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-195994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195994-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 165631F2450F for ; Thu, 30 May 2024 22:57:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38B4B183070; Thu, 30 May 2024 22:57:40 +0000 (UTC) Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A58FE17545; Thu, 30 May 2024 22:57:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.133.224.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717109859; cv=none; b=qviG6vNQLC7KbELeCelYH/19d0PnnVu+Gk2WiNPJOADb4hDFEcZwY6n4Qz06jorBPstDjOQXbA6p56/hjov+58xJs3MyRgAyoYYlNMxA33MU3i6eQbEtTDw2K0Y2mtZZCzXBb6BUCi3pZ2pY5OYlRx9GvpH3NLBErZpsYYDjisw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717109859; c=relaxed/simple; bh=NQrd95QoApaEs9fJihobolQ+Eb73I7LZq0li/uDFwv0=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=VI2+7YW4sGcU9EBGVkSWFEMtKUQolWQBW1naxb6XZg+pz1vRquPI1gvDabzkApqb17wo3v1dKC+qk5wz/WhL1L+Gr2NYmfHvZoG1ZIga+qjfPIqBJRQ4zEt8eFIrWR0aryBg11rL1cHuxy6DXyQSZNVmLHN3mkZx4ngmdZmOGJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk; spf=none smtp.mailfrom=orcam.me.uk; arc=none smtp.client-ip=78.133.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=orcam.me.uk Received: by angie.orcam.me.uk (Postfix, from userid 500) id F388A92009C; Fri, 31 May 2024 00:57:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id EC40692009B; Thu, 30 May 2024 23:57:29 +0100 (BST) Date: Thu, 30 May 2024 23:57:29 +0100 (BST) From: "Maciej W. Rozycki" To: Linus Torvalds cc: "Paul E. McKenney" , John Paul Adrian Glaubitz , Arnd Bergmann , linux-alpha@vger.kernel.org, Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , Alexander Viro , Marc Zyngier , linux-kernel@vger.kernel.org, Michael Cree , Frank Scheiner Subject: Re: [PATCH 00/14] alpha: cleanups for 6.10 In-Reply-To: Message-ID: References: <20240503081125.67990-1-arnd@kernel.org> <272a909522f2790a30b9a8be73ab7145bf06d486.camel@physik.fu-berlin.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Wed, 29 May 2024, Linus Torvalds wrote: > > The only difference here is that with > > hardware read-modify-write operations atomicity for sub-word accesses is > > guaranteed by the ISA, however for software read-modify-write it has to be > > explictly coded using the usual load-locked/store-conditional sequence in > > a loop. > > I have some bad news for you: the old alpha CPU's not only screwed up > the byte/word design, they _also_ screwed up the > load-locked/store-conditional. > > You'd think that LL/SC would be done at a cacheline level, like any > sane person would do. > > But no. > > The 21064 actually did atomicity with an external pin on the bus, the > same way people used to do before caches even existed. Umm, 8086's LOCK#, anyone? > Yes, it has an internal L1 D$, but it is a write-through cache, and > clearly things like cache coherency weren't designed for. In fact, > LL/SC is even documented to not work in the external L2 cache > ("Bcache" - don't ask me why the odd naming). Board cache, I suppose. > So LL/SC on the 21064 literally works on external memory. > > Quoting the reference manual: > > "A.6 Load Locked and Store Conditional > The 21064 provides the ability to perform locked memory accesses through > the LDxL (Load_Locked) and STxC (Store_Conditional) cycle command pair. > The LDxL command forces the 21064 to bypass the Bcache and request data > directly from the external memory interface. The memory interface logic must > set a special interlock flag as it returns the data, and may > optionally keep the > locked address" > > End result: a LL/SC pair is very very slow. It was incredibly slow > even for the time. I had benchmarks, I can't recall them, but I'd like > to say "hundreds of cycles". Maybe thousands. Interesting and disappointing, given how many years the Alpha designers had to learn from the MIPS R4000. Which they borrowed from already after all and which they had first-hand experience with present onboard, from the R4000 DECstation systems built at their WSE facility. Hmm, I wonder if there was patent avoidance involved. > So actual reliable byte operations are not realistically possible on > the early alpha CPU's. You can do them with LL/SC, sure, but > performance would be so horrendously bad that it would be just sad. Hmm, performance with a 30 years old system? Who cares! It mattered 30 years ago, maybe 25. And the performance of a system that runs slowly is still infinitely better than one of a system that doesn't boot anymore, isn't it? > The 21064A had some "fast lock" mode which allows the data from the > LDQ_L to come from the Bcache. So it still isn't exactly fast, and it > still didn't work at CPU core speeds, but at least it worked with the > external cache. > > Compilers will generate the sequence that DEC specified, which isn't > thread-safe. > > In fact, it's worse than "not thread safe". It's not even safe on UP > with interrupts, or even signals in user space. Ouch, I find it a surprising oversight. Come to think of it indeed the plain unlocked read-modify-write sequences are unsafe. I don't suppose any old DECies are still around, but any idea how this was sorted in DEC's own commercial operating systems (DU and OVMS)? So this seems like something that needs to be sorted in the compiler, by always using a locked sequence for 8-bit and 16-bit writes with non-BWX targets. I can surely do it myself, not a big deal, and I reckon such a change to GCC should be pretty compact and self-contained, as all the bits are already within `alpha_expand_mov_nobwx' anyway. I'm not sure if Richard will be happy to accept it, but it seems to me the right thing to do at this point and with that in place there should be no safety concern for RCU or anything with the old Alphas, with no effort at all on the Linux side as all the burden will be on the compiler. We may want to probe for the associated compiler option though and bail out if unsupported. Will it be enough to keep Linux support at least until the next obstacle? Maciej