Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp619998rwi; Mon, 10 Oct 2022 05:14:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SiQsxIGAkwKXNuMzb5upxqh2UxsJkW42Jc0ci59ludTu8wwtJ/GFD8rbxyvvlSicKhGO2 X-Received: by 2002:a05:6402:5288:b0:457:22e5:8022 with SMTP id en8-20020a056402528800b0045722e58022mr17428336edb.244.1665404054481; Mon, 10 Oct 2022 05:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665404054; cv=none; d=google.com; s=arc-20160816; b=ue8O7AK9/UkOxK4i3d2NO7gyRz/Cqyzirs0+7wKunUhVTRzqqD+KnGMQ8gVuE4Pkp6 KJidzI9lvlkzOUSWCdWftyoIqu21eRjjkoQQUgy8eGKmIDshsW4ukjEpEBX/w8Ueb8Ow s00GNDbR54GRxjWiJRZfbwJz6mgBlRod+YCu5sWt2MyIXZsVLmYYf1eumYgcMkHJkrA1 oW/Zf/w4fp/Wztmd98neBhXCpnU8uP0ExMsqIoRaXs6gC6ma8rqC2BSX70PotHJc4LfU 5YUcdmdpnEfFSjjbzulDdBT4gSpGX+5H6K2wXTJwRDoUaGSRw4ARv0cgaaEywkT6h1Fa lVZA== 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 :message-id:date:subject:cc:to:from; bh=NQrJh3fWFyCV/c29gOkR1z0YqZMHSo1cWuph0EbrPSQ=; b=eqMmWo7/nybIR81juSLW6wy8w7TgicjIqWtzMbTa8BNHHljA3qqDRuOmqEU/jIXgSW if0BgCcALMUp6l1yADvI0+k88uEul5EihpQ0mM5ekNg+JMj33vYgFPux5LEiFRzvFnpv ggqwrfClXN7PH/lTzssiKfx70+fVSeneMR3ltx1QeLvc/MRJeLyjnd7eCkaQ6Ezx9COA LkUD4DyANhr7VnYRW95CZA/cGuI7CxDIDvW0F1SFw/dK2YgD1usbZ/L6LJvuJyevbw6X Wv/MtXKw9z+QtKl9D4Xx8EC6H7aQygGvtqpQixZSDGczxQ3kkoBsA+Nu6uUZZc3ypOK2 LPGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb11-20020a1709076d8b00b0078c468bd609si1010691ejc.292.2022.10.10.05.13.45; Mon, 10 Oct 2022 05:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbiJJL6V (ORCPT + 99 others); Mon, 10 Oct 2022 07:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbiJJL6K (ORCPT ); Mon, 10 Oct 2022 07:58:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C64185F23E; Mon, 10 Oct 2022 04:58:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 9A80ACE1132; Mon, 10 Oct 2022 11:58:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4706FC433C1; Mon, 10 Oct 2022 11:57:56 +0000 (UTC) From: Huacai Chen To: Arnd Bergmann , Huacai Chen Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, Huacai Chen Subject: [PATCH] LoongArch: Mark __xchg() and __cmpxchg() as __always_inline Date: Mon, 10 Oct 2022 19:56:20 +0800 Message-Id: <20221010115620.779812-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") allows compiler to uninline functions marked as 'inline'. In case of __xchg()/__cmpxchg() this would cause to reference BUILD_BUG(), which is an error case for catching bugs and will not happen for correct code, if __xchg()/__cmpxchg() is inlined. This bug can be produced with CONFIG_DEBUG_SECTION_MISMATCH enabled, and the solution is similar to below commits: 46f1619500d0225 ("MIPS: include: Mark __xchg as __always_inline"), 88356d09904bc60 ("MIPS: include: Mark __cmpxchg as __always_inline"). Signed-off-by: Huacai Chen --- arch/loongarch/include/asm/cmpxchg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/loongarch/include/asm/cmpxchg.h b/arch/loongarch/include/asm/cmpxchg.h index ae19e33c7754..ecfa6cf79806 100644 --- a/arch/loongarch/include/asm/cmpxchg.h +++ b/arch/loongarch/include/asm/cmpxchg.h @@ -61,8 +61,8 @@ static inline unsigned int __xchg_small(volatile void *ptr, unsigned int val, return (old32 & mask) >> shift; } -static inline unsigned long __xchg(volatile void *ptr, unsigned long x, - int size) +static __always_inline unsigned long +__xchg(volatile void *ptr, unsigned long x, int size) { switch (size) { case 1: @@ -159,8 +159,8 @@ static inline unsigned int __cmpxchg_small(volatile void *ptr, unsigned int old, return (old32 & mask) >> shift; } -static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, - unsigned long new, unsigned int size) +static __always_inline unsigned long +__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, unsigned int size) { switch (size) { case 1: -- 2.31.1