Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp780597lqm; Wed, 1 May 2024 16:03:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV57UTtCLwHeHkhLSGSZlJrQRGCzUhJtAHRRyqGDsb8KirzNQggbEUsQlxit+lt8GwBSMPzmbdtYpF81ZDb6pM1T3KvSQHP7MlbhTsqGg== X-Google-Smtp-Source: AGHT+IH/0C38DjJaTV4pV4I0NT9IhwU/Js0LhWlAltfRx3mE2CMFDtNACCzcNQ6F0kwvJ0xWkzdy X-Received: by 2002:a17:90b:1915:b0:2b2:9fea:4d04 with SMTP id mp21-20020a17090b191500b002b29fea4d04mr3873656pjb.44.1714604623747; Wed, 01 May 2024 16:03:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714604623; cv=pass; d=google.com; s=arc-20160816; b=flZ4LhahV9tYycKj6EeX49RxsHFWgfrBlMLeRT5yfMPRqNEQAkjNTzEAI2nsCPoOP9 JWzJHEcQoK/KEWfodUafY1CSKNQEizdH3wTgEHfkmjwr5RgGT8vXR6YyOi/w0fEhMBja /UzL/IbJik9WPGEzfG29+gqQHNLl/JiQJSfSoAVQakzO97z/vgbVBVBucz0KYaHINHHl M+4rFnka0Ah5s03qqxxplv/HGI6cxveiGnLqI9D9EFNYsZYQjUErXL+iGiEL5AtStwA1 4Rx/A6rb0Avs/jVBi2RiDm3Ke5UdWLilvJVPZ5CMjBd9VUMSjietFUQW4makMp3hSWtf 1YzQ== 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=Zlz3/cvqYWy6KB/xg1MK1MpG72Qtzx4fhinCkH5WKpk=; b=0Ge75OxRotU+Y59PH03YkPNGxxlWcacCrlyltFklKJBkrehor7xp9aL65K/L4cke0z Xhy3LEMMyRR7JEywyc1YD5bIIHtf4t+VDVL3ZCVDVFbOXMUD7WZVU9JbuWkWhTd13jjZ iBAA3ksS2FEZpScfM2iwYwnr6s0mxBhbQol9Cb8gM/5/VkU58FxCu6lJa4gUj2lTSNea rrz36rJ5PQRy7shlMBzEOk8prQOIE7O/BoVMZSa+eMtObpwFFfqc99pH9NT5JEab6Yzl i5TKO7ar+eO7s/2tAAQEZzCItPBA9+CWcGyVfxd8HkKICfUAdeUI8X6wszRxC8XWSrpn CRXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NGvXB9Ll; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165801-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m6-20020a17090a3f8600b002af49ea6474si2251360pjc.121.2024.05.01.16.03.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:03:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NGvXB9Ll; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165801-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B5CFDB21F28 for ; Wed, 1 May 2024 23:02:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 879F216ABFF; Wed, 1 May 2024 23:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NGvXB9Ll" 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 9C47A1C68D; Wed, 1 May 2024 23:01:32 +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=1714604492; cv=none; b=pc6AKr5xzLygtfBPiaSHDtYTJ+vxvXLWEvseu3/naOBMnTj3J9tK/FAfQ8BEeXhO+/GrVGf0tD0/I69eAUitOJr6ceisxBW0w1IyEo0Qv4vZeaFOl8DprJAB0KeL5aSkuYQQ+FAdtPgEx48jxh53/zyFc1nFaBnP+PpMlsSHVq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714604492; c=relaxed/simple; bh=c2cXyTpfqV8tv5AG0/sE+MGJrrEmGRkliM6KcM6nVj0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O0HyerSL3EeXHSl8kfNLJjg18Um8xeDJkCHhiYZPfFUFpm2YZXJnopqqS1S5JvNWR/uNaXBumJhBNJGy9zT8BxVryLjFU5dVvnba29+aDFFefMjgqqi4tUt+Mkuu5OeButp/v2kMEyGJdqNWLv+CKy6PuIkHPe3pjCtY//MzDBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NGvXB9Ll; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FAC4C113CC; Wed, 1 May 2024 23:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714604492; bh=c2cXyTpfqV8tv5AG0/sE+MGJrrEmGRkliM6KcM6nVj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGvXB9LlhqVYz9frifnxysqDrtE+jmWBR03s0B56jvhEG3Ymd7tVXjgkZAMxW6ivR +Zp68VPpFb0ljMEp0FbMzXL6pG632LywY7u5Olj0HqJaj05HqTQp3/d6F0SBzKGlDw tQqA8K4zfsUWBBJgGTXAjKQELAJq1Xrbxt66WKVOEe1G+vjbJfDh4Syqqv52/kuoT1 NhwUdtDaubhxyvyTFwoqK//sjsCB8EOz3PidkwlCzfhPgihJL/k4c65DvuQX9fpmO9 NG5Rfet6CiTDz4x0KKXHVtMw5FDKU2vVxDtjfQX3+Cl3XGLcDv6CMLbCtNRGgmmOdw RI3p9EBhOq2Og== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C23BFCE1415; Wed, 1 May 2024 16:01:31 -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, arnd@arndb.de, torvalds@linux-foundation.org, kernel-team@meta.com, Al Viro , "Paul E . McKenney" Subject: [PATCH v2 cmpxchg 03/13] sparc32: unify __cmpxchg_u{32,64} Date: Wed, 1 May 2024 16:01:20 -0700 Message-Id: <20240501230130.1111603-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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