From patchwork Tue Nov 21 14:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 167778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp658278vqb; Tue, 21 Nov 2023 06:25:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYVgHehOPNKBgPSToJBQdflvXkLAIYr25mfk49OXrgCs4NsyT0A9tFoSjxAvqIOHV952SA X-Received: by 2002:a05:6a21:33a0:b0:188:973c:ef7a with SMTP id yy32-20020a056a2133a000b00188973cef7amr15087649pzb.34.1700576728790; Tue, 21 Nov 2023 06:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700576728; cv=none; d=google.com; s=arc-20160816; b=qrPIBmUiUAV+2uJISG7cUcmhDx8MpZlhqJrtobQ+4wmHqxnQAI4AulCC//W9QS1r/1 MNPrBka1pBbP3udLCoY91Bnxy9B+ZLk9P25pOIKFkH9dJlr0VfiTte6FpAURcxHEMx98 SQLAtpTb1xDCGmlsPx7Tkp1JiQjhqSasMMtpJ9xwcMsit90qIzG3GXpuH9v5dmXwoiJP uk+5Pif6z5JLXGxw1VbKKEvuIe0CQN6y9bnxX7UVJd+uTTrHUh5Y1EtW/0AnUfyw7SuC 6a684vV163e6TQ5Y1Zw9Ai0d3kB1wMpBLfUl08Re7p7IbZw9NubziReVVhhuKtPbqvjE QQLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BQYwJQjKhySUG7SsmpVBnxUpf+Jrz1ajgA6palaWrFM=; fh=/PQTB+v0uxo1ThukQGs6Nkma0iUCHGc/8bBIfUJgAMA=; b=RS2yTR5CEjaUCtYmzIyxhMJ+oA8T6ugSJ7LJigZuBeMIrAnFCFkKGVdaeUahwTG3TW d6BoHDC5SPWm4ZQakeKU8yWQgzXrH8VKVlr5OPPXTU6bkPd4rhFYXlXWmXDUZN5Lvx0n nhmqIvG6rGE4UsaWxuwxQ6aOIiZci5zJUgPs5YT3GWqBVpQF8KkoiT0xIH7akN1ycbfY wlAax9U/KIXE1X6y3jHGrwd6PKnbqWq+HAVk7fHUsp52VFSO3DbfmeNKshmKqqpcQHAS GfMCRPEO0xuL7dgYEqT4MoviVSQ2bsfy4TfJOCCIB40tv7Ee1yy6zjCyDvDSVoes+fp6 I28g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=REfrDuQx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fc11-20020a056a002e0b00b006be04b8c3basi10623602pfb.178.2023.11.21.06.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:25:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=REfrDuQx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D898E804755A; Tue, 21 Nov 2023 06:25:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234288AbjKUOZT (ORCPT + 99 others); Tue, 21 Nov 2023 09:25:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbjKUOZR (ORCPT ); Tue, 21 Nov 2023 09:25:17 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16081D51 for ; Tue, 21 Nov 2023 06:24:46 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b1d1099a84so5310854b3a.1 for ; Tue, 21 Nov 2023 06:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700576685; x=1701181485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BQYwJQjKhySUG7SsmpVBnxUpf+Jrz1ajgA6palaWrFM=; b=REfrDuQxXQ+HzwB7FgCwmor5rAI71g2RCGGb46LBPw4XtSe8F78WA6gTNWd8Qh/0yh 5dIM3+q89dTSMA5EKwHdA9LTELAIXr1bmNuKewoK7vNWoV7oPtTj90ZMVt4QJ0cg8BKs UrBha3hyPjeD+a6f3/p3n8HWV4lzc/c+Qk7LeJ97JMdC3nd0grAmX7cRgrWX6erZ+J7k pgyWoVdF0S47lNBGdTU5tnr5vhIUhj9JXAyS+W5CCmFeZIZEvQT+yecS7QVbo4PwLwtY qRoh7keGmiHRfLl1N55RnRoVTJiv31N2Rn/piXit5TvGZZIPAGpmY8Elq3Q2xJaMr2kR 3WSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700576685; x=1701181485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BQYwJQjKhySUG7SsmpVBnxUpf+Jrz1ajgA6palaWrFM=; b=h5xwh8fkwLuqS7uuQvdbM5HfqV1R7DDFy5xlWVsfsaHvIH2RiRk4yzK3o3pKkcL6PD z2rEMfTRrue/nPxNRcUvtA+z1zLrSlYHGFBRvHdv1fpdf9YHyPV2GQlEBBAgSOsEm85C h4QkdkfUojpVI8NlxHONLv9SiAu/gsBeoBZYnK4n3RtKUxy128Kd/NwJAWjWmb0ozTzH tqGaNApD4z4Zl7XpMLO1mBlnH+2iSzZ0K0AOK5vN32oYMQ7pPQNQ9INisY5W/txtFf8f dPbYixFVvXO0bCm9gS3Bydppz4wHXhnDxKIB4eAFYjPd3aKxAAXDJcPywtb0P6zFf3j5 ytFw== X-Gm-Message-State: AOJu0Yy0gfL7kNhu5cqKiwKkm75PsfnauNEf/LnUM45Xp8de6AX3CpYZ vtJvCqJozzw3Ae9ts4BgOZS2Sw== X-Received: by 2002:a05:6a00:80a:b0:6cb:a18b:2182 with SMTP id m10-20020a056a00080a00b006cba18b2182mr8114491pfk.1.1700576685502; Tue, 21 Nov 2023 06:24:45 -0800 (PST) Received: from devz1.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d13-20020a056a00244d00b0068842ebfd10sm7923193pfj.160.2023.11.21.06.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:24:45 -0800 (PST) From: "wuqiang.matt" To: ubizjak@gmail.com, mark.rutland@arm.com, vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, geert@linux-m68k.org, andi.shyti@linux.intel.com, mingo@kernel.org, palmer@rivosinc.com, andrzej.hajda@intel.com, arnd@arndb.de, peterz@infradead.org, mhiramat@kernel.org Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mattwu@163.com, linux@roeck-us.net, "wuqiang.matt" Subject: [PATCH v3 1/5] arch,locking/atomic: arc: arch_cmpxchg should check data size Date: Tue, 21 Nov 2023 22:23:43 +0800 Message-Id: <20231121142347.241356-2-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121142347.241356-1-wuqiang.matt@bytedance.com> References: <20231121142347.241356-1-wuqiang.matt@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 06:25:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783183944129142214 X-GMAIL-MSGID: 1783183944129142214 arch_cmpxchg() should check data size rather than pointer size in case CONFIG_ARC_HAS_LLSC is defined. So rename __cmpxchg to __cmpxchg_32 to emphasize it's explicit support of 32bit data size with BUILD_BUG_ON() added to avoid any possible misuses with unsupported data types. In case CONFIG_ARC_HAS_LLSC is undefined, arch_cmpxchg() uses spinlock to accomplish SMP-safety, so the BUILD_BUG_ON checking is uncecessary. v2 -> v3: - Patches regrouped and has the improvement for xtensa included - Comments refined to address why these changes are needed v1 -> v2: - Try using native cmpxchg variants if avaialble, as Arnd advised Signed-off-by: wuqiang.matt Reviewed-by: Masami Hiramatsu (Google) --- arch/arc/include/asm/cmpxchg.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h index e138fde067de..bf46514f6f12 100644 --- a/arch/arc/include/asm/cmpxchg.h +++ b/arch/arc/include/asm/cmpxchg.h @@ -18,14 +18,16 @@ * if (*ptr == @old) * *ptr = @new */ -#define __cmpxchg(ptr, old, new) \ +#define __cmpxchg_32(ptr, old, new) \ ({ \ __typeof__(*(ptr)) _prev; \ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ + \ __asm__ __volatile__( \ - "1: llock %0, [%1] \n" \ + "1: llock %0, [%1] \n" \ " brne %0, %2, 2f \n" \ - " scond %3, [%1] \n" \ + " scond %3, [%1] \n" \ " bnz 1b \n" \ "2: \n" \ : "=&r"(_prev) /* Early clobber prevent reg reuse */ \ @@ -47,7 +49,7 @@ \ switch(sizeof((_p_))) { \ case 4: \ - _prev_ = __cmpxchg(_p_, _o_, _n_); \ + _prev_ = __cmpxchg_32(_p_, _o_, _n_); \ break; \ default: \ BUILD_BUG(); \ @@ -65,8 +67,6 @@ __typeof__(*(ptr)) _prev_; \ unsigned long __flags; \ \ - BUILD_BUG_ON(sizeof(_p_) != 4); \ - \ /* \ * spin lock/unlock provide the needed smp_mb() before/after \ */ \ From patchwork Tue Nov 21 14:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 167779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp658347vqb; Tue, 21 Nov 2023 06:25:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFr3OgTfcPI4u3ITcGCZdk3wqETNBbtZu7NB3I5atl25ZZwyj0wVsrvsCDXySQ/gTv8fJTX X-Received: by 2002:a17:90b:48ce:b0:277:68c3:64b9 with SMTP id li14-20020a17090b48ce00b0027768c364b9mr4412981pjb.5.1700576735259; Tue, 21 Nov 2023 06:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700576735; cv=none; d=google.com; s=arc-20160816; b=QV3EkhzzGmXHxVV+nf8C1DrjvbWiuKqOaf6pDJC04fBcPXcH6orLf2ttuqKqJuQAtk Fi8q0Eq+bnXAg5wCRRJu6D6/4+7yjm4CUvXNwqjdLn3d5YUxGg9dY2Y1fpGeyTQL2/01 T5xoe74yqetaXubbMvmrRyz7EBdjx96JEbqUX4/kvfkjhpmmQ/7JBOBK1md/qoOOsgUV aHAMIIZk4Hz2jji+CJilieVMlRiBkp5GiuwqnPOe51qe2eRRUUp0wKbwyiy1n77Qc47n xPOEBoLi4BS+JCYofSYL2Wa7HyFESplyILroGhtFwIvGsrGzDsHWYK3fwuZqsQfK70uz eYAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KQzQ3hctuM1DrYXT+jmSwlcI1w3CAnf53zL9eOZco7c=; fh=aeJBY0iha+whY92MIh+0V6Q+vnbHe442MEUJUcrwDvU=; b=b+7kHsTUIeIWKrGJX50Q03d2lia+AKhGGrJQEwZdTyNt1FhpDuA4xKUAaMWXHcXbPM dsZsN8JDqssoIyo4V6fsJvmFrPGVLwfA7uHiA8vrmBsfpPY4WYU8sdDI00WM2ioNaIgT R6vS2Gwk4yypc0G6VIyX2OdoWJX3AKTT6Yl8GvOMEGe/HxGeY8SoRFC+mN5zhWKvI5V/ J18o9yFxRLb/nuWpbV2P7WWe1ODl9hBuTfLM8qC9epr4jpGO7elnFOWuhbEeqxzjCQRZ gCIytQEg5toGgE9fOIQbNeNSgGlIPW3wxLA129cqREUaDd4MzMfkP+sS2HrbcOm7gQZD 5pZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=lK8s4WR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t23-20020a17090aba9700b0027d088ae385si10137399pjr.96.2023.11.21.06.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:25:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=lK8s4WR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BF8A6812D227; Tue, 21 Nov 2023 06:25:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234274AbjKUOZ1 (ORCPT + 99 others); Tue, 21 Nov 2023 09:25:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234316AbjKUOZV (ORCPT ); Tue, 21 Nov 2023 09:25:21 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A99BD5D for ; Tue, 21 Nov 2023 06:24:54 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6cb66fbc63dso1968476b3a.0 for ; Tue, 21 Nov 2023 06:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700576694; x=1701181494; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KQzQ3hctuM1DrYXT+jmSwlcI1w3CAnf53zL9eOZco7c=; b=lK8s4WR4D8qSeSl/wIndq3Y/ygX+TN/NIiGvIInZYS4yLgqoazrLYb8VAsi94YZzBI Ewym/spIimpGTmNWO7w2DqPAQtRk0t8uGS52aH9pk/e/RSSPg1qPA0gv2iH456fXHf2N ZXK1lnI6HFlp3OWOdl3g6XN8WYUSY3bAAdc0YJ4gN/FM4U+/ThowxrCYqtt3tszLtix3 WN7go69/Fj1hDOdBr+s/K9yYhCiYll4EMUahkrElleQ9rr0BwlPgUhSNNWEGXydRVBUK Bu0F/GyJBqfWo6ozXYgA4xusqzgvnUHsanLlnxodjTMBnIVRIWOqkjX22HUiu1BXvR6Q Anpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700576694; x=1701181494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KQzQ3hctuM1DrYXT+jmSwlcI1w3CAnf53zL9eOZco7c=; b=uJOCKiEZnLtEsiCUN2AZNYL32SirUG31g5NLP5UooDNKwM3dY6fb6DAaWdhvKSBnQT q527tG7l1UH2NKbZP33pIFQsLfwUrn2D9cRRZLOnYJflhpijiZxIhrgrkNUkdwD9g2re mzzdDvo0023Iazil5DBNzeUXvxrP8hapeQTX/GFg8b2zurRL2iobJTUtGwB6AbbcWdfj M2duBi8amAZXTCw4VEB89ooSDrpADYCxbLYdLs8gKO6g0Bah5Q1cUVdikQp87T95lTS5 p4LVV0PD70bkS9oiu1YCsXKHEd4cWIc9C7uUNWkukcXfViZkk9UklrcI7Uc9/GrA5A+P hZ3A== X-Gm-Message-State: AOJu0YyRl8R2HQRnzQ5AbvlZT9Pfc4UMdqu/JODQM7z8HuLGn9zqkBFe x0Gb45atCZP2WdbmpsgI03ogPA== X-Received: by 2002:a05:6a00:228f:b0:6cb:8abd:39b5 with SMTP id f15-20020a056a00228f00b006cb8abd39b5mr4000172pfe.1.1700576693727; Tue, 21 Nov 2023 06:24:53 -0800 (PST) Received: from devz1.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d13-20020a056a00244d00b0068842ebfd10sm7923193pfj.160.2023.11.21.06.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:24:53 -0800 (PST) From: "wuqiang.matt" To: ubizjak@gmail.com, mark.rutland@arm.com, vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, geert@linux-m68k.org, andi.shyti@linux.intel.com, mingo@kernel.org, palmer@rivosinc.com, andrzej.hajda@intel.com, arnd@arndb.de, peterz@infradead.org, mhiramat@kernel.org Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mattwu@163.com, linux@roeck-us.net, "wuqiang.matt" , kernel test robot Subject: [PATCH v3 2/5] arch,locking/atomic: arc: add arch_cmpxchg[64]_local Date: Tue, 21 Nov 2023 22:23:44 +0800 Message-Id: <20231121142347.241356-3-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121142347.241356-1-wuqiang.matt@bytedance.com> References: <20231121142347.241356-1-wuqiang.matt@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 06:25:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783183950752902456 X-GMAIL-MSGID: 1783183950752902456 arc doesn't have arch_cmpxhg_local implemented, which causes building failures for any references of try_cmpxchg_local, reported by the kernel test robot. This patch implements arch_cmpxchg[64]_local with the native cmpxchg variant if the corresponding data size is supported, otherwise generci_cmpxchg[64]_local is to be used. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310272207.tLPflya4-lkp@intel.com/ Signed-off-by: wuqiang.matt Reviewed-by: Masami Hiramatsu (Google) --- arch/arc/include/asm/cmpxchg.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h index bf46514f6f12..91429f2350df 100644 --- a/arch/arc/include/asm/cmpxchg.h +++ b/arch/arc/include/asm/cmpxchg.h @@ -80,6 +80,34 @@ #endif +/* + * always make arch_cmpxchg[64]_local available, native cmpxchg + * will be used if available, then generic_cmpxchg[64]_local + */ +#include +static inline unsigned long __cmpxchg_local(volatile void *ptr, + unsigned long old, + unsigned long new, int size) +{ + switch (size) { +#ifdef CONFIG_ARC_HAS_LLSC + case 4: + return __cmpxchg_32((int32_t *)ptr, old, new); +#endif + default: + return __generic_cmpxchg_local(ptr, old, new, size); + } + + return old; +} +#define arch_cmpxchg_local(ptr, o, n) ({ \ + (__typeof__(*ptr))__cmpxchg_local((ptr), \ + (unsigned long)(o), \ + (unsigned long)(n), \ + sizeof(*(ptr))); \ +}) +#define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n)) + /* * xchg */ From patchwork Tue Nov 21 14:23:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 167781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp659705vqb; Tue, 21 Nov 2023 06:27:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmeqwrgHV1p4G80h6xpLgNfCcNqTaaNMrv5lfFTKYPYwCBNu6bDxCQtx/18EVeJj+oCUNe X-Received: by 2002:a05:6a21:340a:b0:186:1663:53f3 with SMTP id yn10-20020a056a21340a00b00186166353f3mr9608146pzb.33.1700576857028; Tue, 21 Nov 2023 06:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700576857; cv=none; d=google.com; s=arc-20160816; b=MfK52CGatFFUtONhzyymNhBr6sv8SjQdYupyZ2aMRy9jHv2FDRH+IcnYK182ErwX5w vRNLLoUyGg+QZjUyNuvb/LON1R5wCh+0HTQVedcyXLbQhu7Kpc107q4dgFcSDGle53vF s//v0oVDH5Ia2AN4A6CvxXncWqMrvsFdmEP652WsHgU+VeHWRDUtch4QmIp/T7X9wyHi UcdYf+4lwXI5eyJ6l7pRkUZOLrmrf+h9R9+oaHSCeyfE+FatPKwikbKiNiUXw66bLXi4 p0qpyzm9gGRJt6WNVpqhQ3eabMjiJhBErAYUEEc8EaK3hWVSa60IBpGcBUeLsettoaUu vpRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ma7hrIwqvDM4lCpBvbnn1WZG4yWufWgrZRtOwNFwz5Q=; fh=aeJBY0iha+whY92MIh+0V6Q+vnbHe442MEUJUcrwDvU=; b=DWwlnF4adfmx3Ld7W4U540BmT7TuCo70OJyBz+IbshpzKu6f8QdCg5nwB+SfS9KVig CJ6NGYzWKREsRWpsyXceoLjuhQXNbLzFgMrhmiQbwYsZ/j3mPuKjqimiBZY8xI8U/lch NGv1Q58pF/Qnc9jl0q5Y0xfjOz9RLyTqbm+9z6AKuIhiaMG3vjH4un1N8BHAO1oCk9GF s2R4ESFtQ3jNUEsrF3J8fRJKyTQDZXki5QIjNunoBii5/+hbpkpA7e5+6d6XYs98HRYU b43fVquyh17lEnz7ceDLPXaIq6RCl/Zn5hCMkfB+DeflQDgYwe2wD29ntVMia8wNT6JF XOag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UW9ckZHW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l4-20020a63ba44000000b005be1d610e02si10895885pgu.18.2023.11.21.06.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:27:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UW9ckZHW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 942E6807C873; Tue, 21 Nov 2023 06:25:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234088AbjKUOZI (ORCPT + 99 others); Tue, 21 Nov 2023 09:25:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233912AbjKUOZF (ORCPT ); Tue, 21 Nov 2023 09:25:05 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E9E197 for ; Tue, 21 Nov 2023 06:25:02 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6c33ab26dddso4866118b3a.0 for ; Tue, 21 Nov 2023 06:25:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700576702; x=1701181502; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ma7hrIwqvDM4lCpBvbnn1WZG4yWufWgrZRtOwNFwz5Q=; b=UW9ckZHW8W7pnYJbKIM/+E86k6AjyG3KWPYF7p1lDxUKXH63MHhA+pEmmILOd5OseX /GuTXcmZE8r8mR6P9gc2dPF7z0271cbf+xlqjssqQZTX3MhZEQnHdSxlAvR9DbOwfu4j orhpbXhuMorz+HTFrvwBu3WxCW1tZGC67GrwQVfNo3/qnYDzeYiSIm6f+P3vIZ30GvIQ OrqlGqNXbOVV4CAI9o0q2jQrLPGIBRMDL6DeHVKUCKIlynjGqWuRE5HKG/5+I5ic/JTm //TyEvFIbWPy8/+FpftXIq1N8VGOe8WYSGH4Zye8m8xwomMy1WN2/k9SX+asjr1tnnfr OYVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700576702; x=1701181502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ma7hrIwqvDM4lCpBvbnn1WZG4yWufWgrZRtOwNFwz5Q=; b=mHAgr3BluGl6BeUK449FxQojGGrzNBXeTRmnFAWh06f71uqLxfWm4DlxHrX5Y6UJ/7 hPjYzjOWLIukB4GTNKmM+ENb9B9MKFZ75/GjlV8KE8MaPBLlvO0m6KIcvJlz3YpV15Oa ZSfbf2jzYRKu/uKWk0q4IA5PI9LKg0m1g1NeFL8qI/80R7gIg33QiYQi7Sxs1Ot4WO3d z0PnY9ZZ4/xA341a0z4PzjZHzf/Lkux1nvTIRJuE/eN6m2wVE/gTHjIZQdOiSplUkwmv eh6nY6nuCbMbPaRTUfxAgTVcGHDAQZKMJhgbdL5/NEd60Dv9vV2Czpka7Q0NvPIy1i3z kVkg== X-Gm-Message-State: AOJu0YzTeINiBx00iPWKCNfp0CR/ctuLb9MhIGvEthPn1OE5PZmq3jE2 ve4Q8dG5WEYV1SywfFFCQ0RKmQ== X-Received: by 2002:a05:6a00:3923:b0:68e:3eab:9e18 with SMTP id fh35-20020a056a00392300b0068e3eab9e18mr9207536pfb.12.1700576701929; Tue, 21 Nov 2023 06:25:01 -0800 (PST) Received: from devz1.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d13-20020a056a00244d00b0068842ebfd10sm7923193pfj.160.2023.11.21.06.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:25:01 -0800 (PST) From: "wuqiang.matt" To: ubizjak@gmail.com, mark.rutland@arm.com, vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, geert@linux-m68k.org, andi.shyti@linux.intel.com, mingo@kernel.org, palmer@rivosinc.com, andrzej.hajda@intel.com, arnd@arndb.de, peterz@infradead.org, mhiramat@kernel.org Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mattwu@163.com, linux@roeck-us.net, "wuqiang.matt" , kernel test robot Subject: [PATCH v3 3/5] arch,locking/atomic: openrisc: add arch_cmpxchg[64]_local Date: Tue, 21 Nov 2023 22:23:45 +0800 Message-Id: <20231121142347.241356-4-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121142347.241356-1-wuqiang.matt@bytedance.com> References: <20231121142347.241356-1-wuqiang.matt@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 06:25:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783184078169336371 X-GMAIL-MSGID: 1783184078169336371 openrisc hasn't arch_cmpxhg_local implemented, which causes building failures for any references of try_cmpxchg_local, reported by the kernel test robot. This patch implements arch_cmpxchg[64]_local with the native cmpxchg variant if the corresponding data size is supported, otherwise generci_cmpxchg[64]_local is to be used. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310272207.tLPflya4-lkp@intel.com/ Signed-off-by: wuqiang.matt Reviewed-by: Masami Hiramatsu (Google) --- arch/openrisc/include/asm/cmpxchg.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/openrisc/include/asm/cmpxchg.h b/arch/openrisc/include/asm/cmpxchg.h index 8ee151c072e4..f1ffe8b6f5ef 100644 --- a/arch/openrisc/include/asm/cmpxchg.h +++ b/arch/openrisc/include/asm/cmpxchg.h @@ -139,6 +139,12 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, (unsigned long)(n), \ sizeof(*(ptr))); \ }) +#define arch_cmpxchg_local arch_cmpxchg + +/* always make arch_cmpxchg64_local available for openrisc */ +#include + +#define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n)) /* * This function doesn't exist, so you'll get a linker error if From patchwork Tue Nov 21 14:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 167782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp659835vqb; Tue, 21 Nov 2023 06:27:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoHtbct0blw9FtC3zZtmlwXclGR4W8efsAHbHR2DUBdBGMxZWGhCIXvkNRhVliF9tQYuGo X-Received: by 2002:a62:e40b:0:b0:6c4:d615:2169 with SMTP id r11-20020a62e40b000000b006c4d6152169mr3449740pfh.10.1700576872935; Tue, 21 Nov 2023 06:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700576872; cv=none; d=google.com; s=arc-20160816; b=RzAnneb9Im3vUmwp2V5+vFHYinZha9Fu/tuokK/WF4YL1Yvqm51qXxRXXlLwPz4qRZ EP0eELMdNXlh/EfYs1VlswtjszypFU8H3OMCsSxR2kT09YtT7hZDghYmfLD204WYwPJB 04HGu/Pnrkw7UBeT3nO4atNKY4dYi13ysmH0jLGdA2EeNAtBEbGvJlNW1wWBusZU54wB SOk78WVZ9mgSlFv0xhY+IekqlJWb/BtgdH2afU98ELrNsle6lvJKv7Rzp2HA0uysUO1E NL/DslYI41UV93APXyZ32LxkXERvRrLPlMR5XHHJMauvCKSw+mfRmmvNo78R+nnnBque As7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LtVyhAGSgxoCUXjWEvR6JSaSck3SbghSEmVuA82Ner4=; fh=aeJBY0iha+whY92MIh+0V6Q+vnbHe442MEUJUcrwDvU=; b=IOLv8qPtkJJdAp+gFb1D/y1J1qgGLfgnm7daLqopKk5lRwPNcKVktzUm5p6xNlkhJ3 J0qUm6PJAcoV9JE38XOIWPMHbxU+ddhQuCncw+R39rK7fbRfQmGQXs9whN//pLqmHEEl TRkpzQqczu12l+Z1FMxeST6LwXTuzTPeKTqMZxqPAIXWAGAIs401E9+zMWEBGIIIrf4D rEGvYGlUgT8m0o/KRrHHaF2102MZ7jfHKTCIQkzUC1iol/bZ88xu3YQMHreVhxAMFzIy dNtAx31D1YoXXbqD2sRQoJH/dLYpQlEnGuTWsFDlrt9wulZWC1VSH3SX3ochHFQOK7bo weBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=OqeuVnWB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u137-20020a62798f000000b006cbac4c84bbsi3833159pfc.388.2023.11.21.06.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:27:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=OqeuVnWB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CD79B80465C2; Tue, 21 Nov 2023 06:25:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234278AbjKUOZR (ORCPT + 99 others); Tue, 21 Nov 2023 09:25:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234274AbjKUOZP (ORCPT ); Tue, 21 Nov 2023 09:25:15 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31B11A3 for ; Tue, 21 Nov 2023 06:25:10 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6cb66fbc63dso1968702b3a.0 for ; Tue, 21 Nov 2023 06:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700576710; x=1701181510; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LtVyhAGSgxoCUXjWEvR6JSaSck3SbghSEmVuA82Ner4=; b=OqeuVnWBhBVwL4BhDqUp1/T5IIQOZIrg6ODry6HbSHtpxzIojyg4/QYSSZxgvdy2v8 /TkbUokutA6fPZgyBCt+z1x3KIW3jxN5DfbuYN/aB0mUCI5etmuwDE49I+wWrgwNFxPB DqEJZKdO+4qseHxz1bz45qjMOk279EwOAphliF8WUPkBSbC9R/CvfRlws5aUSI2gnuOn /bT27Vbg9XpoWtFcRvziuPOpC6IiqsiiRxegRESK9M2qdI6Dn87/m8HztxMNYno8xFGY qdguKu+ESam6MVkbVmmTkUEI5SJjTIM1RmTrNN62r3Qn2OHy3XpaIkfbkeHM2vnkUrJ2 5kzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700576710; x=1701181510; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LtVyhAGSgxoCUXjWEvR6JSaSck3SbghSEmVuA82Ner4=; b=UxSXYtyievy65Nz+gO9Ah7kjXk3GEPd1ei1W0AjEi4qGJshAhcqFAbId2SFqr3AYmw UokrK+HQeyUU9XniB4lcnvzk8woazKyv+z6aHAmdycd6dyGdJSKtcSYdv6IoHeBmC1jY foBgf/+qYk1GpQhB34ZRVYY5VWOGaxwfaQjnn/4ooprkgq6I19RcQMJjbwjbDIoFZ4fp h7Kso1UZNqU1ZlJsiaYDPMIIxNQrjfPAiBSbDciyOoe4NCr2NrRR0a+rhurzyXcZidbA Lv6saEJjKgsVavYpKO5pQsiIZt4KS1qsY39WY9zrC/Uprtol+pT/+PDRfUMyP8SdW6d+ pucw== X-Gm-Message-State: AOJu0Yx7NgsmY3MSpdPjFbuOkE45NYPylBTvtt4EIJpiyw0cMNQD6Ua2 LZVDWBMmqqRkI1WwOtSK4Rs+7w== X-Received: by 2002:a05:6a00:1d8c:b0:6cb:ba8d:96a7 with SMTP id z12-20020a056a001d8c00b006cbba8d96a7mr4393242pfw.14.1700576710440; Tue, 21 Nov 2023 06:25:10 -0800 (PST) Received: from devz1.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d13-20020a056a00244d00b0068842ebfd10sm7923193pfj.160.2023.11.21.06.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:25:10 -0800 (PST) From: "wuqiang.matt" To: ubizjak@gmail.com, mark.rutland@arm.com, vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, geert@linux-m68k.org, andi.shyti@linux.intel.com, mingo@kernel.org, palmer@rivosinc.com, andrzej.hajda@intel.com, arnd@arndb.de, peterz@infradead.org, mhiramat@kernel.org Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mattwu@163.com, linux@roeck-us.net, "wuqiang.matt" , kernel test robot Subject: [PATCH v3 4/5] arch,locking/atomic: hexagon: add arch_cmpxchg[64]_local Date: Tue, 21 Nov 2023 22:23:46 +0800 Message-Id: <20231121142347.241356-5-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121142347.241356-1-wuqiang.matt@bytedance.com> References: <20231121142347.241356-1-wuqiang.matt@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 06:25:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783184094899240638 X-GMAIL-MSGID: 1783184094899240638 hexagonc hasn't arch_cmpxhg_local implemented, which causes building failures for any references of try_cmpxchg_local, reported by the kernel test robot. This patch implements arch_cmpxchg[64]_local with the native cmpxchg variant if the corresponding data size is supported, otherwise generci_cmpxchg[64]_local is to be used. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310272207.tLPflya4-lkp@intel.com/ Signed-off-by: wuqiang.matt Reviewed-by: Masami Hiramatsu (Google) --- arch/hexagon/include/asm/cmpxchg.h | 51 +++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h index bf6cf5579cf4..302fa30f25aa 100644 --- a/arch/hexagon/include/asm/cmpxchg.h +++ b/arch/hexagon/include/asm/cmpxchg.h @@ -8,6 +8,8 @@ #ifndef _ASM_CMPXCHG_H #define _ASM_CMPXCHG_H +#include + /* * __arch_xchg - atomically exchange a register and a memory location * @x: value to swap @@ -51,13 +53,15 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size) * variable casting. */ -#define arch_cmpxchg(ptr, old, new) \ +#define __cmpxchg_32(ptr, old, new) \ ({ \ __typeof__(ptr) __ptr = (ptr); \ __typeof__(*(ptr)) __old = (old); \ __typeof__(*(ptr)) __new = (new); \ __typeof__(*(ptr)) __oldval = 0; \ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ + \ asm volatile( \ "1: %0 = memw_locked(%1);\n" \ " { P0 = cmp.eq(%0,%2);\n" \ @@ -72,4 +76,49 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size) __oldval; \ }) +#define __cmpxchg(ptr, old, val, size) \ +({ \ + __typeof__(*(ptr)) oldval; \ + \ + switch (size) { \ + case 4: \ + oldval = __cmpxchg_32(ptr, old, val); \ + break; \ + default: \ + BUILD_BUG(); \ + oldval = val; \ + break; \ + } \ + \ + oldval; \ +}) + +#define arch_cmpxchg(ptr, o, n) __cmpxchg((ptr), (o), (n), sizeof(*(ptr))) + +/* + * always make arch_cmpxchg[64]_local available, native cmpxchg + * will be used if available, then generic_cmpxchg[64]_local + */ +#include + +#define arch_cmpxchg_local(ptr, old, val) \ +({ \ + __typeof__(*(ptr)) __retval; \ + int __size = sizeof(*(ptr)); \ + \ + switch (__size) { \ + case 4: \ + __retval = __cmpxchg_32(ptr, old, val); \ + break; \ + default: \ + __retval = __generic_cmpxchg_local(ptr, old, \ + val, __size); \ + break; \ + } \ + \ + __retval; \ +}) + +#define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n)) + #endif /* _ASM_CMPXCHG_H */ From patchwork Tue Nov 21 14:23:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 167780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp658989vqb; Tue, 21 Nov 2023 06:26:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuHOYoyebxiIuCglNrz0ikcTDMF6qtCyZVvMwQh9UCOkTh950ivRjcrYyEt0/JCIou9gXJ X-Received: by 2002:a17:902:d2d2:b0:1cc:6acc:8fa4 with SMTP id n18-20020a170902d2d200b001cc6acc8fa4mr9277393plc.32.1700576790833; Tue, 21 Nov 2023 06:26:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700576789; cv=none; d=google.com; s=arc-20160816; b=C1v2J8tVOMMmE8ewmTNDNrYbJGA5uh9gsHXNpnMA/UiOJB5RJ+sRyr6oYY1TLyzuYW 64iSPkWB8Q0X9DB/T+oydCZnjBmqRXeLSSizxEmvB0Ws77u17THCMBhHdbHan7gGiYMa KjHt6eMLBwUd3k/LRmwU90dLWmhcaC/vc9/p3hT5xoAvPx8LWB5JxGVUkAHdgLbNIMX0 9zTmIMSP6Fp4GaQLC0EcNQvMgTdIC7GAiVTm7NcZi+zmcIcIKo9BrrcwjepHK0D6dfiu 4lhxF2oyPmOa//URCu32PBYJYgZhxXvh5lFJV9xl9lUPbnGjhf3ogUYobMGdkPclTVdW ZcLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IeriZn2HB3faAf90rsoEJC630QNkZ7QDKTlPQoSO5Cg=; fh=/PQTB+v0uxo1ThukQGs6Nkma0iUCHGc/8bBIfUJgAMA=; b=gp/ZCC1z7hFopLmCd5qqO2J5yyJwe9OnTc6lpMtzL4kVwGIqDCeOrDg5lzFRyp1hRQ ND41+ThG+v9z9rrU6OxZ0rViNu8wFKui3jclQ4hJV3Scg06a7dlyYAezoUfYg+nqHwJj WZu+eYBeC2AiRBALM9Pzqpjnmc428h4VM2k8wdMFOTYp/3z0Of1ay7bd4mtTRuFqEdlP 7qQgJpCPlExvTM7wFe+M8qtH1giKL1frgfJFZWrM/YYylkexnimxvmHLlAAmpu9svk1A wpqBa/AcSg/5MjYXWXZaZy56M2yPnnLrGCQzd6N1UDWF1DbJ8hSnjXJGuCetovtHZPBS yvmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=XW+v8Rqd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k7-20020a170902c40700b001bc079974dbsi11277453plk.355.2023.11.21.06.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:26:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=XW+v8Rqd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1BA51807C6F9; Tue, 21 Nov 2023 06:26:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234256AbjKUOZa (ORCPT + 99 others); Tue, 21 Nov 2023 09:25:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234326AbjKUOZX (ORCPT ); Tue, 21 Nov 2023 09:25:23 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5BD10DE for ; Tue, 21 Nov 2023 06:25:18 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6c431b91b2aso4860397b3a.1 for ; Tue, 21 Nov 2023 06:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700576718; x=1701181518; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IeriZn2HB3faAf90rsoEJC630QNkZ7QDKTlPQoSO5Cg=; b=XW+v8Rqdj+W5RDTFT73muFM1vxV9PU11P9yOjIYCFxt+FwPJzicvFYIxmHAJVCif3t NGKsMcTx7m5sjP33I8osRZhwxpRyc6lxktDfsjH/5PynaGz5mWaUtRYpPRDf66MSjKgc qF+iSpqX24h0tVxbUURYKpYHmclFNJQvS0/KLtK532uTvCMIfAzm7MmcfNp+s509jDEL dmYelKtKuMD7V7kLbWdno/MQU5xN4RadKdO8zzqFlZTtnSRU/nj01G8fMF16Zwehg7gf RUpWhCb4A+rRZ9ixMPGakEK1JGrRrBuhti/oZz+farpVI/NgKBqxnJoopwCRBDr3ASpI qV5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700576718; x=1701181518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IeriZn2HB3faAf90rsoEJC630QNkZ7QDKTlPQoSO5Cg=; b=JjnoHeebk3mrFQALtUtCIxFTOTXK/E7icksSV9uv7EJllpwysWolobmOUZqsYvfco0 mb8dTs/yyXbc5i0mgkjbc5mHPNa3XIOCJM7RGnBa2IvkGQxPX0bqI04PeHzmUa9mbX1b n4uc457w7YAUT+J2ryEsushWukavOHnIMTHyBIfSAikBUyk0vLJ2w6JdEEsJaA6Ms2qB vth7py2uSTAys3u6flXiGbXTz6DPo29U5Vq+bv0WXi0kZ2qPKr15eN8P4KXN/PXuqHQe QhVNZjS9YG7ynxo0IyCXUBgVP9IGzIOisLZupdQjZ0ISFbAl+HS/DuG5zNtunfKVHGD/ J03A== X-Gm-Message-State: AOJu0YwPTUREmMF1TRVE4VWKmHdqGaJ2B7HxfzTF2HDs3O++MtWQIybx Fa5SSAlYWudxNm9ry7CydPEG/g== X-Received: by 2002:a05:6a00:9a1:b0:6cb:8c70:4790 with SMTP id u33-20020a056a0009a100b006cb8c704790mr6739253pfg.1.1700576718381; Tue, 21 Nov 2023 06:25:18 -0800 (PST) Received: from devz1.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d13-20020a056a00244d00b0068842ebfd10sm7923193pfj.160.2023.11.21.06.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:25:18 -0800 (PST) From: "wuqiang.matt" To: ubizjak@gmail.com, mark.rutland@arm.com, vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, geert@linux-m68k.org, andi.shyti@linux.intel.com, mingo@kernel.org, palmer@rivosinc.com, andrzej.hajda@intel.com, arnd@arndb.de, peterz@infradead.org, mhiramat@kernel.org Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mattwu@163.com, linux@roeck-us.net, "wuqiang.matt" Subject: [PATCH v3 5/5] arch,locking/atomic: xtensa: define arch_cmpxchg_local as __cmpxchg_local Date: Tue, 21 Nov 2023 22:23:47 +0800 Message-Id: <20231121142347.241356-6-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121142347.241356-1-wuqiang.matt@bytedance.com> References: <20231121142347.241356-1-wuqiang.matt@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 06:26:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783184008050342715 X-GMAIL-MSGID: 1783184008050342715 The xtensa architecture already has __cmpxchg_local defined but not used. The purpose of __cmpxchg_local() is solely for arch_cmpxchg_local(), just as the definition of arch_cmpxchg_local() for other architectures like x86, arm and powerpc. Signed-off-by: wuqiang.matt --- arch/xtensa/include/asm/cmpxchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/include/asm/cmpxchg.h b/arch/xtensa/include/asm/cmpxchg.h index 675a11ea8de7..956c9925df1c 100644 --- a/arch/xtensa/include/asm/cmpxchg.h +++ b/arch/xtensa/include/asm/cmpxchg.h @@ -108,7 +108,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr, * them available. */ #define arch_cmpxchg_local(ptr, o, n) \ - ((__typeof__(*(ptr)))__generic_cmpxchg_local((ptr), (unsigned long)(o),\ + ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \ (unsigned long)(n), sizeof(*(ptr)))) #define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n)) #define arch_cmpxchg64(ptr, o, n) arch_cmpxchg64_local((ptr), (o), (n))