Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp777673lqm; Wed, 1 May 2024 15:58:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlpdzxcEBBStm1P9inU43PUUnIw+walraGzeIdGUn9xO/+zvIXX4QqhDGOx9V9+g33t+wYCFVFcVa0YwkirNfd/0P8D2JQElk6cUfLkg== X-Google-Smtp-Source: AGHT+IGk6HcXhfZA0H5cFKimwSK03kzWro6GCAR4a8UpgdU1cILWfXkJV8DGR1senCRuXij/r+Zf X-Received: by 2002:a05:620a:3bc8:b0:78f:1480:3690 with SMTP id yf8-20020a05620a3bc800b0078f14803690mr4305274qkn.54.1714604303031; Wed, 01 May 2024 15:58:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714604303; cv=pass; d=google.com; s=arc-20160816; b=AN2qI6UHERdww19pDLaYg+Of/LQVNaOE5MH0O0CZU5BkK72T3i83a3M3VP/u844Ed+ 7545ubGkWlIQM0TqTcL1p2Qcu4A9V+zEIRqu1Viw75AjvqEDvqL5/p8M5netMoVCOV8i bz9oU0YmQ6akR0p4odKJiWtZC2CFtXYudBXq7XEce+YARoc44LSiiPVIHP6sl3vd/wxA cDPYFo+PAiZxOHzF7Tv+5cwE4pavZaoIIIWF4PdaQTo09x5kwByHvYFlnHycnislnG7b MLIBH3cpZbOWWI86fFRzcfiLrU2KptTlnAxcZGYbFbiiPxdLzCQxOSbqBfneiSrwWbM1 vOPA== 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=ejwvlTs/vQA5RpuQ021U/IMuTXed5a7W4/LoMsf16pY=; fh=B1y0SOLKXJYfZrU/A7t/2xxmDgxg+7GbMOW67EnEt90=; b=eysQm1hCOG6IbedvLaq3e8NvBU6zJDQ665vTAEuJV0NyDGMQEmB6XHy/lqY981qB9G 5+Tl/y/OucPFPm+Q6vjqaTgoTNFS/K/m/6+0VVnFCLDSouCCIJkh3H0eeRg+ina7db4M OwTuImjodySRIR1Iu4RAEakLbqQaqxULdL7tLUdybSfOUuDj5WpkENhONhctBprzxxsR vFhKi4MvAiEUoV1hHvPaXQbeuEX8pN+z3fzAAkXp0JpumnNZDWcrE6oQ9ezjK0hGznfd ZCcnuR+iQjYCm/4FzWZML69juZKEtZdZbcyFhGt4X+lk0Fl3ldeG6G8FOh7lMaqSeQ9E Damg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZJLyLwH6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165797-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165797-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. [147.75.199.223]) by mx.google.com with ESMTPS id pj38-20020a05620a1da600b0078eeba4fd95si31583982qkn.220.2024.05.01.15.58.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 15:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165797-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZJLyLwH6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165797-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165797-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 BAB181C21539 for ; Wed, 1 May 2024 22:58:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 143F01635CD; Wed, 1 May 2024 22:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZJLyLwH6" 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 3C34F1C68D; Wed, 1 May 2024 22:58:14 +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=1714604295; cv=none; b=JphfbnJRAihijelHeD5F/040PMPfFZ/iQ6g8Xqw4ynPJbvkCKLoLyPGD9lNUGK/7JeiVQtBpB3wQMN87/E2dcKWIpCALZIwbP0Zt4GOVhk7PgLkznQY0dR9DCcliGAYYeMnM8Qc2J1cdtz8xrlAUC8RGbQzj8V9W3THgLo7jw9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714604295; c=relaxed/simple; bh=ZWvjsFb5VqBM8uFd+mM9iEyIUARqHxE23HizvDxq/fs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=B+gJLi9Nj5YlseD9NHX90m5vStw/2giYu4fIbwh/dzs5IdSH4iHd/xpAG0C3bnl6rng5TNtxJmhSktnmTDLEdVKWRiZVhsFWb+D2xwKXyPAjntEOlu4YhKzJZvBubxXGO42UcEMj6fdONEVLVDTOEPUwO2H7eqQwCQkES+3v4Qk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZJLyLwH6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C72F6C072AA; Wed, 1 May 2024 22:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714604294; bh=ZWvjsFb5VqBM8uFd+mM9iEyIUARqHxE23HizvDxq/fs=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=ZJLyLwH6f0paQVmgaGR/4UiHVduIBks9p5SIT4YGCPKZ0W+uMGicxK0wMpTc4StMt +cHxdkJL4wdv76z2lq+JBdLPVPfZGTtZGZIP9nbojB57JtbdttYrYK0kY6s8nZt0uW m+SqVEfAyap9RTBh+z1qQ5LjMjmdy1+2qGwzq8Ccd88oJSu+r1T4i/D+3KGF0jImqO C7CF+LolVMDbamJM3YcoDRCXCmYgplURSPxWDKKIG2HrKA8vWnqXU9J3dyULrk4kqC Ij7P3kPo3JLUrR262kwYyePqXinBYVMyulYDMgJGbkkxF+4N3Vg+lJn5KdX/aVt9l/ IXUhnmjQbjkiw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 60C63CE1073; Wed, 1 May 2024 15:58:14 -0700 (PDT) Date: Wed, 1 May 2024 15:58:14 -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: [PATCH v2 cmpxchg 0/8] Provide emulation for one--byte cmpxchg() Message-ID: Reply-To: paulmck@kernel.org References: <31c82dcc-e203-48a9-aadd-f2fcd57d94c1@paulmck-laptop> <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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> Hello! This v2 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: f0183ab28489 ("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. The patches are as follows: 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. Changes since v2: o Dropped riscv patch in favor of alternative patch that provides native support. o Fixed yet more casting bugs spotted by kernel test robot and by Geert Uytterhoeven. 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 | 33 +++++++++++++++------ 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/sh/Kconfig | 1 b/arch/sh/include/asm/cmpxchg.h | 3 + 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 +++++++++++++++++++++++++++++ 22 files changed, 172 insertions(+), 99 deletions(-)