Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1461961lqm; Thu, 2 May 2024 16:13:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwKVyb7LkiEjqbfdOWP6s0ReKMPAzjfGzzYUJ/Rfg4A9iz2HrqNdQT5Ia5rR34e71zk9+K6Phke2X0GhgN3L89lR3hhv2JMG1F9VzjoA== X-Google-Smtp-Source: AGHT+IGax4BlRbKHCwLUKaNb6/ob2VPO5uWuc9jCurSjSJhQFvG91x7esPiuDr+HKV3u+gjWu5NT X-Received: by 2002:a05:651c:208:b0:2d8:57a4:968d with SMTP id y8-20020a05651c020800b002d857a4968dmr645044ljn.12.1714691580973; Thu, 02 May 2024 16:13:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714691580; cv=pass; d=google.com; s=arc-20160816; b=j7J3KfiE3/abkUlXaPtJNZu5gNdVY6DLnAvkn9pd5QcSBGfixqMmoUDLggPWHkxBJr +N9vxaVz9c3linlhwM3XnXS0gCYwLipAYwtaEUuu9D3ltu8ISz3A6p+Pe9U6EZBq5fRR SE/UB37hm/EVuWoLI3LnwXHdg0nS9OlSYX0pM1cc4qx1uwcIPpp/Ad1limGzrG/mfuz5 +Wjevhn2tOeciZePhRMQ0TLQ7S4Ilm5YuwYJub8ysPNARuXGEe1bRVdrp/Q2Dc6a4gGN pspFtfPeKK1zpEmb017Pj6+/i1SGL/DIyQ+EyVRezQYF0G06ZvBBGFiP1T9oKPAszqiu jgew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=qNJ0KH21yEW18QmTqmB3qRA0fDsEX4+ssckTSRO3Nic=; fh=zAPYh1UeyTzQsjkaTKcX1v2JK7j9pipq3fFBln4yugs=; b=Rq5bCT8g5+R8yG8wuvcQ1MnbIkykQSMSMu33AVmrCobC2aVi99K4cF/xpIh/xwNgj4 +EBZE8lIw+cKxs1R8hu3s33Yk++3DY+pixfTMbulJG7/Y5FtncNRugm04kz5QGUWS52q MOFCxq/fy3TC6l8VkbzNFKw462CIt+hva6QBbn9+JG0SOC8hCpzXF1Clcr/T4MC6t47x ZMf7LkHJvDKVkHnpCIpJ6Crc23mtwUFp2Gx8NKFmUZu1yOzWDRtop7mc1ypOu962n8y5 Q3I+egaMJEyRIfiWIMvEslk/3IZJ853VADw/bfzr+MLZ7mMg1AhOTMFeot/72yIxFipx dtOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ETNdkf05; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-167047-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w7-20020aa7d287000000b00572147bf99fsi865900edq.529.2024.05.02.16.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 16:13:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167047-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ETNdkf05; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-167047-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 88E141F24EDB for ; Thu, 2 May 2024 23:13:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E0B446542; Thu, 2 May 2024 23:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ETNdkf05" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 83ADF42056; Thu, 2 May 2024 23:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714691565; cv=none; b=rNmjdacY1BDMfANrBxG35sPprSnVlCK6aBTO9b4AAvy2ug3vbfCFeM5OHt4yUpuETI2jtP00tuNZwKV292RvYG4R9CQpIe2WU3sgYMV8LP0MLF6mBrGMZ6dPxaubl+JXmDq24p9nZ3l0HirMyVwfsdBy5O4htgKAgMw2ZMvK3kU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714691565; c=relaxed/simple; bh=TtQvW0/ZSCONrgzyA1qdsSq+lg8LR2BWPI/SrrOPqTA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IacIV/QifQf9cVV0qYZm7LvwvxikM2bQ0xx03TU/kgShrSiLvsI6hIlqPonxh0dy1iSNUhCXb8LfgOS8EwFXNYLEBRW2bf+Gg835mznMaNgy/ytkrZHeF/VnDoIS+/6Gv2YlodJp5qvR6rp6ubpf6ITZzmS7WkRtpryOVTbJdDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ETNdkf05; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 236F0C113CC; Thu, 2 May 2024 23:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714691565; bh=TtQvW0/ZSCONrgzyA1qdsSq+lg8LR2BWPI/SrrOPqTA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=ETNdkf05c90wLRFtuo3itrE3t33QU2QVWuu5jYT48FmyzfrkNcO7kOVGonsQUSCbY f2sOBPJBmFuj0D/OtHLAc2WxtGhAWObLauu9sV+0Ahx8kTqrcjtCiVFfhouj1aww5c 3A8K5ZXOn+ukFgZ7lu46UXPV1wUKaeEmSZn/rXCqK8DFMVDUVhlS7zG4T5UOLYWEcN xKiO0eZ51H6Tc/DW8tM1BeY07nxAuLbqI0ZuiQ8kMMassJwXQzQgAHyqjQy9HMpjAY UEJ+GeqML7Wn7ZLrYQf7yicsOooQgJbRWAFkVIIvpqerR6uRcAMo7y7XCb32lmQ49V Yan4bS1qgAFaQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C644DCE0991; Thu, 2 May 2024 16:12:44 -0700 (PDT) Date: Thu, 2 May 2024 16:12:44 -0700 From: "Paul E. McKenney" To: Al Viro Cc: John Paul Adrian Glaubitz , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, elver@google.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, dianders@chromium.org, pmladek@suse.com, arnd@arndb.de, torvalds@linux-foundation.org, kernel-team@meta.com, Andi Shyti , Palmer Dabbelt , Masami Hiramatsu , linux-sh@vger.kernel.org Subject: Re: [PATCH v2 cmpxchg 12/13] sh: Emulate one-byte cmpxchg Message-ID: <3dac400c-d18f-4f4e-b598-cad6948362d6@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240501230130.1111603-12-paulmck@kernel.org> <1376850f47279e3a3f4f40e3de2784ae3ac30414.camel@physik.fu-berlin.de> <6f7743601fe7bd50c2855a8fd1ed8f766ef03cac.camel@physik.fu-berlin.de> <9a4e1928-961d-43af-9951-71786b97062a@paulmck-laptop> <20240502205345.GK2118490@ZenIV> <0a429959-935d-4800-8d0c-4e010951996d@paulmck-laptop> <20240502220757.GL2118490@ZenIV> 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 Content-Disposition: inline In-Reply-To: <20240502220757.GL2118490@ZenIV> On Thu, May 02, 2024 at 11:07:57PM +0100, Al Viro wrote: > On Thu, May 02, 2024 at 02:18:48PM -0700, Paul E. McKenney wrote: > > > If you are only ever doing atomic read-modify-write operations on the > > byte in question, then agreed, you don't care about byte loads and stores. > > > > But there are use cases that do mix smp_store_release() with cmpxchg(), > > and those use cases won't work unless at least byte store is implemented. > > Or I suppose that we could use cmpxchg() instead of smp_store_release(), > > but that is wasteful for architectures that do support byte stores. > > > > So EV56 adds the byte loads and stores needed for those use cases. > > > > Or am I missing your point? > > arch/alpha/include/cmpxchg.h: > #define arch_cmpxchg(ptr, o, n) \ > ({ \ > __typeof__(*(ptr)) __ret; \ > __typeof__(*(ptr)) _o_ = (o); \ > __typeof__(*(ptr)) _n_ = (n); \ > smp_mb(); \ > __ret = (__typeof__(*(ptr))) __cmpxchg((ptr), \ > (unsigned long)_o_, (unsigned long)_n_, sizeof(*(ptr)));\ > smp_mb(); \ > __ret; \ > }) > > Are those smp_mb() in there enough? > > I'm probably missing your point, though - what mix of cmpxchg and > smp_store_release on 8bit values? One of RCU's state machines uses smp_store_release() to start the state machine (only one task gets to do this) and cmpxchg() to update state beyond that point. And the state is 8 bits so that it and other state fits into 32 bits to allow a single check for multiple conditions elsewhere. Thanx, Paul