Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1508211lqe; Mon, 8 Apr 2024 10:48:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVzKi0kY3DOxbYqmHqYmzXubLqkzoTpp3sGlcAOvHixsgCI35XrkIZ0t2Kgehxk5YFAo/WLhIOCES7jIQu8zzpDOa8E+n1GqzbFy0jnkw== X-Google-Smtp-Source: AGHT+IHe8m8W+c+PY7Y0ym7SX5Mb+axVIVQNWqh85QP5Eveq8UijuDmCXWTsS+lLUYfuWltGfgCB X-Received: by 2002:a05:622a:1820:b0:434:bc21:bf7a with SMTP id t32-20020a05622a182000b00434bc21bf7amr544790qtc.1.1712598487601; Mon, 08 Apr 2024 10:48:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712598487; cv=pass; d=google.com; s=arc-20160816; b=iBFpLl0Oq8XZTudY53h+tmID7gSi/a+qqY4q/kl7U0sipaceW9OZ5ZpTeRAHZTXtnc eAgtswKK5Nq0LCw2Xq4AsNsaSxsDaRtI7S92ICHir/dMiGzIfKhoUefqxjIgY2fOp9ke Hj1c73usS4Ru55qeht7AgsR72xusT+v9pwKP67jHkJm2uxREJ8XRK4B/gOfiiFPc5lTJ GSZWsZ0Qc0l9AoMOiw2f++B+X2ZZR0r9iwb0p/0dR1dEEmJoQwO+2L6TWW0vyUp4KsVV NdDwfL8WORZnSAuj8swL0TEWsv6h8hP9BAXLzwZ3vv0msZSstyyo99VLmUQS96ZEXP1d t0bw== 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=iTmf8svXZEzKzzI/bFkMSADaILh+vSCebQwK6wODuo8=; fh=B1y0SOLKXJYfZrU/A7t/2xxmDgxg+7GbMOW67EnEt90=; b=s7rvdOvWStkDDAoXXOiTA8xxzlqMDL5BNbJZmuWPGqPLALvgOMcG6Rgx8UV7vA9nJK XfGzvAw6eRFajS6nL4CRvh2879iXgbBxBwcw6f0OI4OQzHQi1VID/aLXSM685H4JyzDM elCN5sB5bpCLVe/xbvUG7FIHyq+aR2BrUXmUDmDQ0CRbAjJDRsLWRyJ07RaojGlThmQB FziAD8couBJXu4nRVbBkpX9Rf+LHrGBuoO8acqueiKmV1O4j00BbJ4UADruruxThTvho e8CeAi0hlKFR4nF7l20WgUL2zSpTYfMbtyLqUa/+ddmGz7RrmatWzTthmtzmBHb+ZmxB TnNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WGNktws4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h6-20020ac87d46000000b004314898c23dsi9149165qtb.501.2024.04.08.10.48.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WGNktws4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135769-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 568581C22419 for ; Mon, 8 Apr 2024 17:48:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A4551448C3; Mon, 8 Apr 2024 17:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WGNktws4" 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 592AF143C64; Mon, 8 Apr 2024 17:47:48 +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=1712598468; cv=none; b=iBM1y1t7EdVyimrjehWNJrXj8bRYGOHvZq9wI3XD3cQeUq8VW5EwkrL5uy9ZDK/SCTni65E+0py8MEL10Otk58woydMxtYsa3qf80Qd4abSvT6p6ygREKECsXJkj25pXqReCQR0+jjGBKIYfdBxmfGVNZWFsbaVBs8oQkOhjkPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712598468; c=relaxed/simple; bh=hthrMF23hrV7RDKnYkCQipSHR0wxEktgjaf796DaoDs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LjxJOZZogjV0hzSRKXby9V9oYw6LukF8V1Cra7UN8DcbR/RUqwJw7nUlEQFSxfpAUbIAzs+v3xypf+ya5PGiDwy6JeyY1xRZpE13Ewmz+3miaPUZzsQ9tzl15/XDByfPSCM49ZBZCsriH6eGCHWdsQn/vVOAzVGfLNNOB6pexUg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WGNktws4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE569C433F1; Mon, 8 Apr 2024 17:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712598467; bh=hthrMF23hrV7RDKnYkCQipSHR0wxEktgjaf796DaoDs=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=WGNktws4jrKrfs0hp9jzy2Rg5s6G+ayHXXoAJFBujBxETGjf8N+UUSKjr03tlm+C3 63k6v3IxOvf8o4z4eS3djGlgP8Iyo2ulyVQ2890TFXS14M5zm52QWY5hoMl8BBxniz sTHOzbwiZPBP09ZFgQ+cDxcHZEPmONohpNmtaJMY/qImG/AcT9QfY2e0L0w8oT6sDB QMzTi6K2KY7kpurfxHGFKOfRJLHmgcOMZJxfeiFIF3WDczzEonk+yUorBgj+iRGVBJ zbMV0z9/+t/HJdkNMcf04aXWaSZbewcNOMQGRdod/ydnMmv05NSvvv/fIGM+uiadrh O251MTKUs79NA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 6A1E4CE126C; Mon, 8 Apr 2024 10:47:46 -0700 (PDT) Date: Mon, 8 Apr 2024 10:47:46 -0700 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 Subject: Re: [PATCH RFC cmpxchg 0/8] Provide emulation for one- and two-byte cmpxchg() Message-ID: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> Reply-To: paulmck@kernel.org References: <31c82dcc-e203-48a9-aadd-f2fcd57d94c1@paulmck-laptop> 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: <31c82dcc-e203-48a9-aadd-f2fcd57d94c1@paulmck-laptop> Hello! This series provides emulation functions for one-byte cmpxchg, and uses it for those architectures not supporting this in hardware. The emulation is in terms of the fully ordered four-byte cmpxchg() that is supplied by all of these architectures. This was tested by making x86 forget that it can do one-byte cmpxchg() natively: 88a9b3f7a924 ("EXP arch/x86: Test one-byte cmpxchg emulation") This commit is local to -rcu and is of course not intended for mainline. If accepted, RCU Tasks will use this capability in place of the current rcu_trc_cmpxchg_need_qs() open-coding of this emulation. 1. sparc32: make __cmpxchg_u32() return u32, courtesy of Al Viro. 2. sparc32: make the first argument of __cmpxchg_u64() volatile u64 *, courtesy of Al Viro. 3. sparc32: unify __cmpxchg_u{32,64}, courtesy of Al Viro. 4. sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes, courtesy of Al Viro. 5. parisc: __cmpxchg_u32(): lift conversion into the callers, courtesy of Al Viro. 6. parisc: unify implementations of __cmpxchg_u{8,32,64}, courtesy of Al Viro. 7. parisc: add missing export of __cmpxchg_u8(), courtesy of Al Viro. 8. parisc: add u16 support to cmpxchg(), courtesy of Al Viro. 9. lib: Add one-byte emulation function. 10. ARC: Emulate one-byte cmpxchg. 11. csky: Emulate one-byte cmpxchg. 12. sh: Emulate one-byte cmpxchg. 13. xtensa: Emulate one-byte cmpxchg. 14. riscv: Emulate one-byte cmpxchg. Changes since v1: o Add native support for sparc32 and parisc, courtesy of Al Viro. o Remove two-byte emulation due to architectures that still do not support two-byte load and store instructions, per Arnd Bergmann feedback. (Yes, there are a few systems out there that do not even support one-byte load instructions, but these are slated for removal anyway.) o Fix numerous casting bugs spotted by kernel test robot. o Fix SPDX header. "//" for .c files and "/*" for .h files. I am sure that there is a good reason for this. ;-) Thanx, Paul ------------------------------------------------------------------------ arch/parisc/include/asm/cmpxchg.h | 19 +++++------- arch/parisc/kernel/parisc_ksyms.c | 1 arch/parisc/lib/bitops.c | 52 +++++++++++----------------------- arch/sparc/include/asm/cmpxchg_32.h | 18 +++++------ arch/sparc/lib/atomic32.c | 47 +++++++++++++----------------- b/arch/Kconfig | 3 + b/arch/arc/Kconfig | 1 b/arch/arc/include/asm/cmpxchg.h | 32 +++++++++++++++----- b/arch/csky/Kconfig | 1 b/arch/csky/include/asm/cmpxchg.h | 10 ++++++ b/arch/parisc/include/asm/cmpxchg.h | 3 - b/arch/parisc/kernel/parisc_ksyms.c | 1 b/arch/parisc/lib/bitops.c | 6 +-- b/arch/riscv/Kconfig | 1 b/arch/riscv/include/asm/cmpxchg.h | 13 ++++++++ b/arch/sh/Kconfig | 1 b/arch/sh/include/asm/cmpxchg.h | 2 + b/arch/sparc/include/asm/cmpxchg_32.h | 4 +- b/arch/sparc/lib/atomic32.c | 4 +- b/arch/xtensa/Kconfig | 1 b/arch/xtensa/include/asm/cmpxchg.h | 2 + b/include/linux/cmpxchg-emu.h | 15 +++++++++ b/lib/Makefile | 1 b/lib/cmpxchg-emu.c | 45 +++++++++++++++++++++++++++++ 24 files changed, 184 insertions(+), 99 deletions(-)