Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp909808lqm; Wed, 1 May 2024 22:07:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/TiDUR6hTApE19aZ00HfOZkZMDfO5NnNkpvZjVhJ+nHmLtvqZy4BSQ6s1BXAFQSt42ij8Dr5e9EVrBX0e1Zt6vST80LsXFa3i+4dmkw== X-Google-Smtp-Source: AGHT+IEH/UlEmxbNX5BDAwQ/Vh585pg4WjMiZyHp4vrjv/uZYmI8md80CPH4Ra6zqoBxdBCmtTsf X-Received: by 2002:a17:90a:9f90:b0:2b3:7af1:a9e5 with SMTP id o16-20020a17090a9f9000b002b37af1a9e5mr2252886pjp.42.1714626426706; Wed, 01 May 2024 22:07:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714626426; cv=pass; d=google.com; s=arc-20160816; b=tOLHT/t5LlnQ4kidu7JbvGllW5b7el9lTlbtZeV74zjvDeUhe8IenLaFC07xuVsJED 63C2rzPHvPNqKNFdXKt8QL7XU6TJHwlICnXS1dIYL1YK7a7SBIk4kHjlUOOl/Hqb+pyO SpfSqKDY6Ckwdgzyge9yJ+RMro52dhv2BpzZZhtRhcqjX8US2NXvcaTVLqP0mYOO8KnO 4bayBfsaOm342r3ccJ7Hv2l48Ru+WHxGJKo9jzvk5+p5T5lb8QuRMzWQff0UO2nVe/AN qyeLRqyX+76Caz6/zMprWnUFHut8XLME21JjlhHcCwwPE9tv37pI9vxSjxyulctaMBPd c+Qw== 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=KALOsWH8PAgIfHsRHOFAu6TYuqfnS+0Wq9wJErjFdkU=; fh=9YlKqQu2QdLurYpvQdaLG6ISAxR01C7HLMr9lbFwQp4=; b=xOIHM8XWKU0/qt4GjBnqwxDLKLQfuV7SHgr3vubzg+WYUPJiYXNG9c2XDQpLtISqso KNpwHWplutJFaDIKeHNrfdnSdE58NuNSDi4LisveU3+WB6plG5zsE61kRChi5Zz5cOlz NSxlQTo0pCEnJPej293y1onMVqnV0r18/oiZEahFe2cAPYlQ02jxSs6iNlGND0AJRR82 /gg9S2GkU1WBaNJbCBe1IrfnODUh+hYdVBItvZoYCIxhrdVvTIQTNi+UXWp1yMledh4B +40SgxDxEpSwhyZ+jdK3ymKH69LwZAWxRU3d4NYqSmJmOtdALlVmKt3s93B5a/ol6fFn +7EQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnSMxQW8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165975-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f5-20020a17090ac28500b002b2d10c9aa6si342521pjt.75.2024.05.01.22.07.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 22:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165975-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnSMxQW8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165975-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165975-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 55EB52835FD for ; Thu, 2 May 2024 05:07:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A82D2200AE; Thu, 2 May 2024 05:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gnSMxQW8" 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 C07C41CD2D; Thu, 2 May 2024 05:06:59 +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=1714626419; cv=none; b=DsLN3TTxL/aRY6Lg6V18CxvxqoeX/qEKEaxXb/jZWaBcjiPZNu1qvOwJVURBI20t+FsKU3RAsVKUUVkCoLgjHA6vZwhn5hH39WKS8wXZMbAnAvS7X0pf4rBFffOjTe9rVSwBNSkOiWSbGI3WGGFZyMejWWQO6mgrKCcQotAWLiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714626419; c=relaxed/simple; bh=E7hJC5ZIIkCJLDzLl6XTgvU7+hlkT0mW1ai+1Wl/Kn8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S4TLOFHRZBmpoKLtSbb+S1ajD2YXzmV873Z3zvC9NX7VKIaGIsPnNsFCJ/U0jifacVd0CiNt/cOOaXCNfmpswNgKh/C0+eyhwEQ7JL8K5L+V+kVfPzeJ9oEd6pHlR+Vfl3lKEsQkX8j0rA2R/7Ixd+eIh6rsG/GU2GWZrb1jGBk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gnSMxQW8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AFE6C116B1; Thu, 2 May 2024 05:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714626419; bh=E7hJC5ZIIkCJLDzLl6XTgvU7+hlkT0mW1ai+1Wl/Kn8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=gnSMxQW86lyw4bC7kidm+imxxPMXM7NAPf1aq6G8F8jnGqmif128wIocH4fc4QXln VWivrS8So+wiASlffzJe+PYqSBv+fVtOv4QOAMPjubNtH4QQRPAxaV9pEttbssJc6C QiMtWbPVSORwiVXRkcaoLueNOf7JqQ9GhsjPMRvHoWxf7hZ99Egf2/3TZD517OAPHg YsB1wEhn6JLAc+F8R+N7XCFiXzbUW1y4j/4D0iD7ueyrypVnaWoYPS8Yj/FDgx0sjC vKaCgQqlarO/3/MZ/3vTPbePj+SLt84VWdzgWrIfL5YtQ4otJBjN6qBdYPDgcRkQDE lcc9eSBfjwF3w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DBC29CE1073; Wed, 1 May 2024 22:06:58 -0700 (PDT) Date: Wed, 1 May 2024 22:06:58 -0700 From: "Paul E. McKenney" To: John Paul Adrian Glaubitz Cc: 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: Reply-To: paulmck@kernel.org References: <20240501230130.1111603-12-paulmck@kernel.org> <1376850f47279e3a3f4f40e3de2784ae3ac30414.camel@physik.fu-berlin.de> 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: <1376850f47279e3a3f4f40e3de2784ae3ac30414.camel@physik.fu-berlin.de> On Thu, May 02, 2024 at 06:52:53AM +0200, John Paul Adrian Glaubitz wrote: > Hi Paul, > > On Wed, 2024-05-01 at 16:01 -0700, Paul E. McKenney wrote: > > Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh. > > > > [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] > > [ paulmck: Apply feedback from Naresh Kamboju. ] > > [ Apply Geert Uytterhoeven feedback. ] > > > > Signed-off-by: Paul E. McKenney > > Cc: Andi Shyti > > Cc: Palmer Dabbelt > > Cc: Masami Hiramatsu > > Cc: Arnd Bergmann > > Cc: > > --- > > arch/sh/Kconfig | 1 + > > arch/sh/include/asm/cmpxchg.h | 3 +++ > > 2 files changed, 4 insertions(+) > > > > diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig > > index 2ad3e29f0ebec..f47e9ccf4efd2 100644 > > --- a/arch/sh/Kconfig > > +++ b/arch/sh/Kconfig > > @@ -16,6 +16,7 @@ config SUPERH > > select ARCH_HIBERNATION_POSSIBLE if MMU > > select ARCH_MIGHT_HAVE_PC_PARPORT > > select ARCH_WANT_IPC_PARSE_VERSION > > + select ARCH_NEED_CMPXCHG_1_EMU > > select CPU_NO_EFFICIENT_FFS > > select DMA_DECLARE_COHERENT > > select GENERIC_ATOMIC64 > > diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h > > index 5d617b3ef78f7..1e5dc5ccf7bf5 100644 > > --- a/arch/sh/include/asm/cmpxchg.h > > +++ b/arch/sh/include/asm/cmpxchg.h > > @@ -9,6 +9,7 @@ > > > > #include > > #include > > +#include > > > > #if defined(CONFIG_GUSA_RB) > > #include > > @@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old, > > unsigned long new, int size) > > { > > switch (size) { > > + case 1: > > + return cmpxchg_emu_u8(ptr, old, new); > > case 4: > > return __cmpxchg_u32(ptr, old, new); > > } > > Thanks for the patch. However, I don't quite understand its purpose. > > There is already a case for 8-byte cmpxchg in the switch statement below: > > case 1: \ > __xchg__res = xchg_u8(__xchg_ptr, x); \ > break; > > Does cmpxchg_emu_u8() have any advantages over the native xchg_u8()? That would be 8-bit xchg() rather than 8-byte cmpxchg(), correct? Or am I missing something subtle here that makes sh also support one-byte (8-bit) cmpxchg()? Thanx, Paul