Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1509217lqe; Mon, 8 Apr 2024 10:50:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2dMhJqZDzEQ1gBa8Ke/bq8yPVIIgeZbdDY/DPhs6L6aLMbQFYiCJMr7DZFa5ofcWffWlDaU9njey3LciUG2oWcnU5vivGDTXQNxqT7w== X-Google-Smtp-Source: AGHT+IEfwP8ePdiLI/NdsqdlaenuOZ0jx3ruS8en8zK4gWnzKCN4a/3okaDxCtJf0thNkfjQPuUJ X-Received: by 2002:a50:d653:0:b0:56e:2d93:3f7f with SMTP id c19-20020a50d653000000b0056e2d933f7fmr9312860edj.39.1712598620309; Mon, 08 Apr 2024 10:50:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712598620; cv=pass; d=google.com; s=arc-20160816; b=KqRsKzv+d9GjVJ0s0YWClx/K+ETSrY1z+fTccWe80MXXGTFghjkBNazM8aDNswxE3y 71V243fl4NpnzY3uBMvoBBUwC9LMVBgmsmA+XHG8opsN/ZDnR/jZyNogz2bJoWBbwj5p wgbjoRO89InrXxuSTiBbnsIFKo7LKpfbYS0y125/gdnCA9zwCkC5rFQ5EB7YSYg3dPkA lVKmC9oEZE+2W7dzY7cQwSexRlowwqSc4l3mkx9PSBm1Oo1ehKUgfxqK9L4E1cfRETzZ Lf927f5OHx/N8x3Bsdg092tNOQPEGMCUy05ttvDQIfoM0aPPXAeCrtPQnPpgIF/u1GY6 y0wQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gzvzWhqOADotHk29jtrFl76VJP28MQN7Lscp6SWU/xw=; fh=w9S2XPug8Iuwyxj1huAxJ8xgXHl/EkJ/564y4G32wHQ=; b=axt9RrD69QRuwAjxu9XjQKmT6/jfGrKTQ+lNtR3JRglotricYlJDO+GLO7ETSqHzcM mtr7tkDO3YAUhppzwVRHqZVJdTM9Xjzn7wCF7ktxcaM8hAvj7I2d2IVnWJ0SnfyxPv9u Y2z/UyvFk3Nvz+UrER1XA9FxvSc8SMLsANmaidOYSp0BCIvyqc7ScNt7P4DbEB/w93Hl 1els6jMII6QB3EQFa5sK5MH7zTQlH8OVnBc7/YbLlUd62LkmfVDyY3XNdFURlvtX/+Xd VF6ZjdDfVj/3KA5UF1E4oPYRNBXWP6IlwcUW3qEMp9ashRSHczGYjiEGcKwy7NwVf+45 /iYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pkDaCYAs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135770-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 p3-20020a056402500300b0056e237c99c0si4085934eda.433.2024.04.08.10.50.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135770-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=pkDaCYAs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135770-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 0D36F1F22634 for ; Mon, 8 Apr 2024 17:50:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B15AE145330; Mon, 8 Apr 2024 17:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pkDaCYAs" 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 C524B8662A; Mon, 8 Apr 2024 17:49:46 +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=1712598586; cv=none; b=YlTXkV1D3XVOcbzDq3FLZBr9+UZ0J1Ncdaez6QouZvNExsRjISvxBAfY5s5SJeLQzyKmSMXQWeRe1LkrFijq74oiGARGRWhWZ2/duFAUZLsAVPG0+QBmT+3/I2pJ+MEfeqt+guXCqMyu5F7BshdpSLqPRk0PbXnvvN+hKFYiL1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712598586; c=relaxed/simple; bh=c2cXyTpfqV8tv5AG0/sE+MGJrrEmGRkliM6KcM6nVj0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AEr++b6yvvmh21GcWdg5Eib5gRpogvBOUYv842MIpA5IG5nSKmcWdhNH32oDE5t9oUtIE2nq88lKyvyY86xTRkEnQMOGRAObeQDKtGtV4Bg7qiwxEwUOeo7A7MhoSTVtIczwcM1TzAP3XI0KIcO0UtJAOJsr4zjraDhMROooBtI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pkDaCYAs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B31DC43394; Mon, 8 Apr 2024 17:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712598586; bh=c2cXyTpfqV8tv5AG0/sE+MGJrrEmGRkliM6KcM6nVj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkDaCYAs8wLBAmNJrQPXv0CPsOdpVGkdbWveLaEfw1DCONWIadMw4soW1dhYpyu94 Fdnlow2GF5HBAOWrscn4a3d48e6Df1PgZASM6kmDIH/NTP9D6dGKvJi8+Ez1zIqO8t qGS9UyZYitPRSyzVY/qDb61ftb1KhNpVZHDdS6C4Pv+TD8hO7fMyrO1ED+gxNTk0fB X+b7tRdoLdz3ubZ1PyfPI1w/hxtjxi5MKUsuJogRQPqXgZnbJEK6dkoAQxikoxAoNk HwQ/eRmDx6HqLJmZX4XRDGNqZGfScEnjz3dVkET7J8Sl24WpKn7kgJo4LM11uzmy8j 3fsbrcPuREMqw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 417E2CE13F0; Mon, 8 Apr 2024 10:49:46 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: elver@google.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, dianders@chromium.org, pmladek@suse.com, torvalds@linux-foundation.org, Arnd Bergmann , Al Viro , "Paul E . McKenney" Subject: [PATCH cmpxchg 03/14] sparc32: unify __cmpxchg_u{32,64} Date: Mon, 8 Apr 2024 10:49:33 -0700 Message-Id: <20240408174944.907695-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> References: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Al Viro Add a macro that expands to one of those when given u32 or u64 as an argument - atomic32.c has a lot of similar stuff already. Signed-off-by: Al Viro Signed-off-by: Paul E. McKenney --- arch/sparc/lib/atomic32.c | 41 +++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c index e15affbbb5238..0d215a772428e 100644 --- a/arch/sparc/lib/atomic32.c +++ b/arch/sparc/lib/atomic32.c @@ -159,32 +159,23 @@ unsigned long sp32___change_bit(unsigned long *addr, unsigned long mask) } EXPORT_SYMBOL(sp32___change_bit); -u32 __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) -{ - unsigned long flags; - u32 prev; - - spin_lock_irqsave(ATOMIC_HASH(ptr), flags); - if ((prev = *ptr) == old) - *ptr = new; - spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); - - return prev; -} +#define CMPXCHG(T) \ + T __cmpxchg_##T(volatile T *ptr, T old, T new) \ + { \ + unsigned long flags; \ + T prev; \ + \ + spin_lock_irqsave(ATOMIC_HASH(ptr), flags); \ + if ((prev = *ptr) == old) \ + *ptr = new; \ + spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);\ + \ + return prev; \ + } + +CMPXCHG(u32) +CMPXCHG(u64) EXPORT_SYMBOL(__cmpxchg_u32); - -u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new) -{ - unsigned long flags; - u64 prev; - - spin_lock_irqsave(ATOMIC_HASH(ptr), flags); - if ((prev = *ptr) == old) - *ptr = new; - spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); - - return prev; -} EXPORT_SYMBOL(__cmpxchg_u64); unsigned long __xchg_u32(volatile u32 *ptr, u32 new) -- 2.40.1