From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF4983DAAD8 for ; Fri, 11 Sep 2026 22:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789164622; cv=none; b=q8qddJTmziJLQZVkbfwHqsgO6xRb9y3PeIrbloetNa39MkTQPa6pRLa3hiV8yCnIuMcYG37RGiWRKs/Wuf/zi0tPyTFXu+URNTqfqclklZP0FnLUeox/mYZkdDE/5/bNjJSAYahSelR2MMbNl/wWguzrTtuMmgmHWqNbtd0BZZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789164622; c=relaxed/simple; bh=wzOAT8P+HfggfOuW+tbV1rDr39BIeDu1f097JVhjors=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WGZtXYVL96nc++Sl99C0vUDxZ5xhxUinetYDI55j0ZPCCYOt0VHH0CZVnskcotsv3D68WZl6R3nUGekG4qpI2LoiGQpzN3uOjGja6RhWMorh1rj7XrF1bkPnkdTdyvYpiTb0DPFYbCE7+aHSMRk/Q7t0vG+JJHdOm6QJBy2V+pQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V8kPqdVL; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V8kPqdVL" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-49ccfae359fso11143515e9.3 for ; Fri, 11 Sep 2026 15:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789164619; x=1789769419; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=1CitEInQG9IH8hFfkxw+Dy1+TcxOBHzYjUh6RK88Fgs=; b=V8kPqdVLxhbxYq/ndSOhh59EWr8wuK81XRGpgyG1cXj+UuOWKJMFJ2T2a2dgpFrdLa WkuVwWjHua6E0jDuliU9Xfih3FGXadW6+THWVrO6iOtCVXUCSCtYS+LVNXHxOpwM1s/Y /bOxgg+4FBx1y8MXDR1zhT3bH3ZKtN6CF8wJX8J7oMW/zGMtXic0VCWyi99/rWWjnfd/ uuXLEKmMOpD1pjjTO6VRI6T6CUOYwvNYIghCxNP5Ys0xeNLSImT2vW7SH3c25q936lXU qUoUKrw/pjuOxzetQVpQHrvTyuVJAj49eK1mHFx/vB/wgw7+zJMHO9eiGbAO23VErWjb 30HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789164619; x=1789769419; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1CitEInQG9IH8hFfkxw+Dy1+TcxOBHzYjUh6RK88Fgs=; b=Bh03jj/MymqDKFNQtK6/D03od/DWFaUrN9AZsa/CDE8JxNINAtuKzL0JKSObWj8rk3 8MMtD2XgK++R4yXI2wjqYobDjlAt3bOX1/YxRrONqZxE20aBzeWQdwsIMzIB8wPz6TZ0 7vVt9MMSMX3LN7eOau0Izzp1zPsHY6bj6ucXNJciYnxuElN75QbXMbuXBTR9PgbcKPRV azd9+91EZTvvNjhXlESzB7tjV/OidckZVKUGptTkNaNOrpp7ZuJYu8RfYcuIU0kmAYGk l2+NIcA9uergNVT0axh59JBZPTF1/iDKohVVFdgVLIKT35xQj1Q3ki76/QbotdoxTkgQ YFVQ== X-Forwarded-Encrypted: i=1; AKwUvByNxRWRRVl2HAzc2MYPGbktarOjsHRtUzMk/StRMJAMzxubtO6JmMSzeCFwADuaVYFSDWk=@vger.kernel.org X-Gm-Message-State: AFuF++nvGUgu1eRsrTo1v/nSjVmZjaBnrAGyy3XvvpMC6qKfwcwwVxOa 5zy/VsX0LAw6FxItxpb3f5xXPoBpmPxjTDZy771rxhFHGaw4ezKcEXkO X-Gm-Gg: AYBFou0Wtvfa/+8g30K6uMEtcWfKzSaqwAH7wbpGgY7furQp3Dry1gLx84S8vrrrvae 43145AZeVjjJhYa/z1/1bhltEF5pnGmbCoG7LIZX3HEyHre+aA1uHHf0oHQ2mBFIxKv8YAAxx4y o0fa3NkG1uKa7vVcdQlHbc43d7MBmT39r8M9fdqTU9JZ6yK02LYzHYPNE2NunA4kCi+WfswCpWp b+YNsNbl1JZPeFmV1y52s+NNJ9krUWrHXbalArHSYmRlyAQxN8naok3s8+GHaouGaLlFAimtmf2 BfYYJPo5mewVxB8nzMRpF7GsUB1cmNEvz+Riakt0o/Kd0rR8qXH+k3p7c5tAZxMbcfQsa3BTUmp bzt/MIZpvd1ZgCvV3bnBve7lNGPk7HjF1ViT/9vR7kQ8RTWYLsWBKPtmNblR00nzhHhzdj9KdtM zea0sgTuZlSaI7h2asgN1Cpx0U6ynd+4U6lhlu9Uwbq5rtkyml2CPtA7QtDdgDhYipobPxeEdF/ sS7Pmngu7aFLPKT1zjf2hMHxHLxUEE21tqr X-Received: by 2002:a05:600c:8b41:b0:49b:d45:703e with SMTP id 5b1f17b1804b1-49e6198865dmr87033975e9.8.1789164618893; Fri, 11 Sep 2026 15:10:18 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a81943sm69553525e9.1.2026.09.11.15.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 15:10:18 -0700 (PDT) Date: Fri, 11 Sep 2026 23:10:17 +0100 From: David Laight To: Bradley Morgan Cc: "Paul E. McKenney" , frederic@kernel.org, neeraj.upadhyay@kernel.org, boqun@kernel.org, joelagnelf@nvidia.com, rcu@vger.kernel.org, "Andrew Morton" , "Arnd Bergmann" , linux-arch@vger.kernel.org, "Vineet Gupta" , linux-snps-arc@lists.infradead.org, "Russell King" , linux-arm-kernel@lists.infradead.org, "Guo Ren" , linux-csky@vger.kernel.org, "Yoshinori Sato" , "Rich Felker" , "John Paul Adrian Glaubitz" , linux-sh@vger.kernel.org, "Chris Zankel" , "Max Filippov" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] lib: Add two-byte cmpxchg emulation function Message-ID: <20260911231017.550f8cd1@pumpkin> In-Reply-To: <20260911192540.20983-2-brads@mainlining.org> References: <20260911192540.20983-1-brads@mainlining.org> <20260911192540.20983-2-brads@mainlining.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 11 Sep 2026 19:25:34 +0000 Bradley Morgan wrote: > cmpxchg_emu_u8() emulates one-byte cmpxchg() in terms of four-byte > cmpxchg() for the architectures lacking native one-byte atomics. > The same architectures also lack native two-byte cmpxchg(), where > such an operation is not supported and either fails to compile via > BUILD_BUG() or fails to link, because the bad pointer sentinels > these architectures declare are never defined. > > Add cmpxchg_emu_u16(), the two-byte sibling. It reads the enclosing > word with READ_ONCE(), splices the two target bytes through a union > and loops on cmpxchg() of the full word until the compare succeeds. > Like cmpxchg_emu_u8() it is fully ordered. > > The Kconfig symbol gating this file is renamed from > ARCH_NEED_CMPXCHG_1_EMU to ARCH_NEED_CMPXCHG_1_2_EMU, as it now > selects both the one-byte and the two-byte emulation. > > Suggested-by: Paul E. McKenney > Signed-off-by: Bradley Morgan > --- > arch/Kconfig | 2 +- > arch/arc/Kconfig | 2 +- > arch/arm/Kconfig | 2 +- > arch/csky/Kconfig | 2 +- > arch/sh/Kconfig | 2 +- > arch/xtensa/Kconfig | 2 +- > include/linux/cmpxchg-emu.h | 1 + > lib/Makefile | 2 +- > lib/cmpxchg-emu.c | 35 ++++++++++++++++++++++++++++++++--- > 9 files changed, 40 insertions(+), 10 deletions(-) > ... > diff --git a/include/linux/cmpxchg-emu.h b/include/linux/cmpxchg-emu.h > index 998deec67740..fee8171fa05e 100644 > --- a/include/linux/cmpxchg-emu.h > +++ b/include/linux/cmpxchg-emu.h > @@ -11,5 +11,6 @@ > #define __LINUX_CMPXCHG_EMU_H > > uintptr_t cmpxchg_emu_u8(volatile u8 *p, uintptr_t old, uintptr_t new); > +uintptr_t cmpxchg_emu_u16(volatile u16 *p, uintptr_t old, uintptr_t new); Why uintptr_t? Shouldn't it just be u16? (Which probably means the code would better if it was just 'unsigned int') David