Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1110444lqo; Sat, 11 May 2024 07:50:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1P95TKxj6LTTIEpSUnSmO4yox632S3xZ/UGJmolL/A64Hf99coKPmszlldEich6LxstS2WD0NcbR1qJaPxxMj5zANIhij2sbOHAgtKA== X-Google-Smtp-Source: AGHT+IEu14A559fnEtgErOPQCsTyITAnfWTvI3FDpE0gQQ6dxUCWal8rb1ETeBR8jNFfDi7+QGeq X-Received: by 2002:a05:6e02:1a6f:b0:36b:3bc7:f338 with SMTP id e9e14a558f8ab-36cc1474ac3mr68616315ab.3.1715439005503; Sat, 11 May 2024 07:50:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715439005; cv=pass; d=google.com; s=arc-20160816; b=eiY7JgY+pMUDwtk5t+86h4w27jCkIlFmrjYkj7Tnv1LY2AjeGqDucuTy3AKDDflTGO M530fImAqE8nUcZ10CzKVtk7yCc2LGXQwf3wpaDDt8KmrRcAIwLWC3jxeDGVhycBfb6U 72yRBzpMEbxmNnWPkO4RxkbEL+KmzprkWfPhy4KRcUAo/LfiX6p1yQdPptFA+hX2iYdW pAorFTFQ/eblb6ZjXqso25sCBpzntnDL4rvKzSyHyghGUelmxVts53J31oW1OnbdFbFt evu8FtZ4nH99R0ybwZ2tjIw4YptjZo8E7SEPX+84ahcUg379+0YAbpt187zSY8eSUdGv wTfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=tac4GNEx2viCqg/duoHp3XjRBKJy0HEJBStlnhlbiIk=; fh=JmEjInMmYL3JEHWoRxYQ/7M3bvhCdCUNMfFjnGc4nEw=; b=FenZ6G4bdj3Jl9zTrW0HFL10Cg/YAkknVgh86aELkFKfMrvIZGh8HXj4UlxMX+e+96 7UDytoEHAwZisKu/9uw9z/HjRvmZre5p3f73h5v9T+tTey4EL9u1s0Tc6NAv8zwFfQEr z538Q/Vf2BD2tlBCI6qAD1sy7h9fY4Z1ZjXp9idDiIeZ7IN29KM30AI0zYuUr8dyzE8L Yt43aCT1fAE8GSpnxW62CJL+gowa6MaXVqI9Ja8CzS3FfK09rmRAtWAzWC5iMebBj2h8 DgLzbYWKISQf1OMdzEpFt2YWX+ARVy89dW3FRjzHZ95r3qjkV+PNG5RxJi3Jew859La4 KpTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="G/lQUeb4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176584-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176584-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63409e82441si5873968a12.96.2024.05.11.07.50.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 07:50:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176584-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="G/lQUeb4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176584-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176584-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 21F28281D41 for ; Sat, 11 May 2024 14:50:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E933255E73; Sat, 11 May 2024 14:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G/lQUeb4" 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 0B8D651034; Sat, 11 May 2024 14:49:57 +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=1715438998; cv=none; b=b64zNpQWSYZ9l0f+2R/aq24A2tDMpBoxIuvZP7llBRNChn71vsuUpuFXO8da2eJrzhnW0+3E4xRMfE22QMwLlBxXCkFEnWiBMztJnI1RNaDRfck/MGabD4tL20QKvKqADZnpOG1bNKxuxcXVegfI1mXLaH4tTkTTM0+qNlFeiVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715438998; c=relaxed/simple; bh=QbbdrQveR5xbMbt67/DpPuiLYhLi955nnL7HY0R44nE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aGRxFnPVpE3LiKevZlw76k0NQK7hSBk6Dmb0cyZu8ZlaM2AhmbrVf1d6piY3O9gXSmRKp5cgs9oJ/WOHQUsLOHhmHgC741V3KCGzYjYywXrns22D0OKCnc8VjXROVoBPqF6SDFMnPlOxQ4AMIFGKoN0m1/3kllIHszgUu89ReaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G/lQUeb4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71EE8C2BBFC; Sat, 11 May 2024 14:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715438997; bh=QbbdrQveR5xbMbt67/DpPuiLYhLi955nnL7HY0R44nE=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=G/lQUeb48/utL53AUg3ouEfD29EcUaDkgrTde+SsHUCbtSirckCkGGSRqUqHbPyVs ca23txNLpT0+LvuQRtKlGYzne7+NWVFr/FYbIl7yUkli72wWparmtnSSrg9WjnzcKr 2NcbFWd7mg5rY+gE0jGJiWvqvITCQgnsEXzk1YC6k+Xam42tGBzqdeFjxKjduCNDqi BnpA/dBi/6jrRnxuD400ApXRQQqlygZip5qmyccRRe4xo+XHfPkq21tLI7PT2PR4fQ TJV3UDwMUtokAjJ7Q13uWmINJevbdSAwfngcY7r7bEfdGNAu/B6rFa1/zegJQQHP/I locwagLJkcd/g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1A564CE0F8E; Sat, 11 May 2024 07:49:57 -0700 (PDT) Date: Sat, 11 May 2024 07:49:57 -0700 From: "Paul E. McKenney" To: Guo Ren Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, 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, Yujie Liu , linux-csky@vger.kernel.org Subject: Re: [PATCH v2 cmpxchg 11/13] csky: Emulate one-byte cmpxchg Message-ID: Reply-To: paulmck@kernel.org References: <20240501230130.1111603-11-paulmck@kernel.org> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Sat, May 11, 2024 at 02:42:17PM +0800, Guo Ren wrote: > On Thu, May 2, 2024 at 7:01 AM Paul E. McKenney wrote: > > > > Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on csky. > > > > [ paulmck: Apply kernel test robot feedback. ] > > [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] > > > > Co-developed-by: Yujie Liu > > Signed-off-by: Yujie Liu > > Signed-off-by: Paul E. McKenney > > Tested-by: Yujie Liu > > Cc: Guo Ren > > Cc: Arnd Bergmann > > Cc: > > --- > > arch/csky/Kconfig | 1 + > > arch/csky/include/asm/cmpxchg.h | 10 ++++++++++ > > 2 files changed, 11 insertions(+) > > > > diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig > > index d3ac36751ad1f..5479707eb5d10 100644 > > --- a/arch/csky/Kconfig > > +++ b/arch/csky/Kconfig > > @@ -37,6 +37,7 @@ config CSKY > > select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION > > select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION > > select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION > > + select ARCH_NEED_CMPXCHG_1_EMU > > select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace) > > select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT > > select COMMON_CLK > > diff --git a/arch/csky/include/asm/cmpxchg.h b/arch/csky/include/asm/cmpxchg.h > > index 916043b845f14..db6dda47184e4 100644 > > --- a/arch/csky/include/asm/cmpxchg.h > > +++ b/arch/csky/include/asm/cmpxchg.h > > @@ -6,6 +6,7 @@ > > #ifdef CONFIG_SMP > > #include > > #include > > +#include > > > > #define __xchg_relaxed(new, ptr, size) \ > > ({ \ > > @@ -61,6 +62,9 @@ > > __typeof__(old) __old = (old); \ > > __typeof__(*(ptr)) __ret; \ > > switch (size) { \ > > + case 1: \ > > + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ > > + break; \ > > case 4: \ > > asm volatile ( \ > > "1: ldex.w %0, (%3) \n" \ > > @@ -91,6 +95,9 @@ > > __typeof__(old) __old = (old); \ > > __typeof__(*(ptr)) __ret; \ > > switch (size) { \ > > + case 1: \ > > + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ > > + break; \ > > case 4: \ > > asm volatile ( \ > > "1: ldex.w %0, (%3) \n" \ > > @@ -122,6 +129,9 @@ > > __typeof__(old) __old = (old); \ > > __typeof__(*(ptr)) __ret; \ > > switch (size) { \ > > + case 1: \ > > + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ > > + break; \ > > case 4: \ > > asm volatile ( \ > > RELEASE_FENCE \ > > -- > > 2.40.1 > > > Reviewed-by: Guo Ren > > I will optimize it after ARCH_NEED_CMPXCHG_1_EMU is merged. Thank you very much! I have applied this and added it to my pull request for the upcoming merge window. Thanx, Paul