From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr2-f12.google.com (mail-wr2-f12.google.com [74.125.225.76]) (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 CC592488D86 for ; Wed, 23 Sep 2026 10:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790160211; cv=none; b=vFjfMnwe3pIDCa/mbnz+7ukzEQKUjyI7ABEf/2zuU/HHMV/Wf1+8BlyZYfrUr8TGF12SXOYgJ6qFAXJ2GD+ci/skkpNRGeG38wwXy4HrIZClj+Wh8IHEOd62tHBY4H4IhGvBzWgPq6JuhBeRvra8sZADkZ4Q/MVDxDQKDQLA9JQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790160211; c=relaxed/simple; bh=/hAmY6yG2+OCPMJTvRs5ChswnMAkCdLCUN+/9Q9fZh4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZMkHuIH9XCTfwBmNwlLDhG+LhXY7oKEiaBkLVTLFWWTkZOMkbiGxFKwALOeLc9p3GsGpT1ExdFjeGLFGyf7wzXT3kyo+sIoHoI7n7NZimWg2aVfIMocXI29BTrDMj9vH3ciz6o3ssfUBqchv7xggvm60XBGFm9i79ROk9qBWJ/k= 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=CPn+PcDu; arc=none smtp.client-ip=74.125.225.76 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="CPn+PcDu" Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-48583cc7ab1so429634f8f.2 for ; Wed, 23 Sep 2026 03:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790160195; x=1790764995; 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=t1Z4i78iFUVYmXdwkSYq7EkiOAX8N+OcOOj8F5FsldA=; b=CPn+PcDupM2GLmmXqlMvdfReA/3wAJMMUSYOaS0cjHThc+wAddPU6ProYKR6TX3Op8 s5yp4NHCPEyjnz7+u4HLA0GZuhA0Oj8otUoWv8l47UgGGRHC7RB+QKgleMtdEGjeacfa cwEabG/Wu8LWuc8bIYyGd5xPBPTKhj+h6H/S0tmTY0FALjfJyBWvjhnn/7VulmBeSwdo kCPPPwzI8RbocchihueTj+H9IkBO631KrCldStcev3UFlDv2I9e43Sa0IglFTP0ilagV IGoXnifX2h3lYXLiIng8I1BlirUsIfWEbUsc2wBKREgeXUo6mN+LqTu5n8+SmdxH3DVi 7McQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790160195; x=1790764995; 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=t1Z4i78iFUVYmXdwkSYq7EkiOAX8N+OcOOj8F5FsldA=; b=ojW2M9AYSjp7WJaUFvlmCMHYVoMHUQFKYSoIgcuKlePfcjdTilqkFTURqLDByruCrE pXzeDjMSxmzeMdeR5q1/W95Ve2NJeG+gYFzw7KeyrZnp0KH10t+TG24cNT9ytCD6ptWU Idhc1Ll0TNZbzsdAc31oXOFJmdR9sE1nAt1+ObrCoOey86J9kXdt1pnReKYJX/CYnaKp a5teS3ODl1F5xvTmuW/Z2In3qPbj6eI8vGgvwLVp0inX2g2BMsCLiaA0PhPyo+waIfty bog24TSM3oknEO2Y60IVSDa5YPS9GVhOgkHLnvmsaplPdN00i1uc0RH/njKogYoBz81V 2y0A== X-Forwarded-Encrypted: i=1; AKwUvBwlVvWG/ELOQMCu8QQsmKRepx+EgSEHfewvKkEyPR05sjVkkvGTf7tt7h60sCTe6HNXHsRXMe2+8GGxdi8=@vger.kernel.org X-Gm-Message-State: AFuF++lfvHbvI1OwTQjRrAs4fFZ6L7ai8ujDtrA8VaJHl6222kMV/pDs jcHUCHf1dHc0B4kEuoqQH+FSZAwXtmkD1AzXNHIQTVF9MS8zUcBg+GLe X-Gm-Gg: AYBFou19tnFK5ergPu+iif7MZrwXCToLoTU6G/TIax47MxtURXRN3d89037z19q/Wfn eb+irC/Zdlaeane3nHQoJu7X3jELDoDQJA0FjQJkd4bR4/RzH9uPwu0aEj8GodB2OyDlURTZ2Ue Y9rFLuDyxZ5iPpAJbtBE73robzreGB12uCLV2zM2JYa9nN3TmVPbV9Y+Aj+1exBsxYrSBOaGfjX h3RtdS2tl+hV3jBXoaqHG73J1dpvof2IsXrz4ukFPK4K+nur5vuhxvGFhKSmSkMWBDIxHROqDUs jORwlmiu7B25LKoeqm6xOqV7FnwIcFaYX6HPkAvfEpv5h4mNf0ZWh3pa+UHhSjZKeQqA0N3IkEL nMWoTE9xCGJbJ7EjEtt4mq6YcR7l4WWJ+KoMLMoBkyX2GE4DXDtGvDyhne7tG+tjvYnRZBHdAVo TJNFvZEs7VL0A5hR5d8HBCzcWpYS6YHkJghBV1aB+dbAdLo1anF5IURwr38yyjBRjS/VfDXPpEN mYSODnwCrjwZ9JYpyIUo0u3jKbxLOCtSCgt3/PbNjLnvQ== X-Received: by 2002:a5d:64cc:0:b0:487:81c:6de with SMTP id ffacd0b85a97d-48867093ce7mr3896298f8f.34.1790160194918; Wed, 23 Sep 2026 03:43:14 -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 ffacd0b85a97d-488687791cdsm5534038f8f.22.2026.09.23.03.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 03:43:14 -0700 (PDT) Date: Wed, 23 Sep 2026 11:43:13 +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: <20260923114313.75494970@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: linux-kernel@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/arch/Kconfig b/arch/Kconfig > index 3bb2e568f5b1..d56064797e09 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -1817,7 +1817,7 @@ config CC_HAS_SANE_FUNCTION_ALIGNMENT > # strict alignment always, even with -falign-functions. > def_bool CC_HAS_MIN_FUNCTION_ALIGNMENT || CC_IS_CLANG > > -config ARCH_NEED_CMPXCHG_1_EMU > +config ARCH_NEED_CMPXCHG_1_2_EMU Is it actually worth the churn of changing the name? Maybe just a comment that say it adds both 1 and 2 byte emulation? David > bool > ...