From patchwork Sat Nov 4 09:16:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 161555 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1546541vqu; Sat, 4 Nov 2023 02:17:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOilGsbreOuwhSpNyJWAr70J2j86nCJBAJ87ojDhc6NB4QVyJxOVFxq/HJu7E/ja/HgaK8 X-Received: by 2002:a0d:ebcf:0:b0:5a8:78b0:a9fd with SMTP id u198-20020a0debcf000000b005a878b0a9fdmr5736590ywe.29.1699089445216; Sat, 04 Nov 2023 02:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699089445; cv=none; d=google.com; s=arc-20160816; b=nbOI4FzlrGkM7jeR3tgDiu18kaPNxlMCnpSVU+z/aZU2N6UEryjY/AtrPQ7ba1iRQZ akjrkGvxzqM1UO2r2ikS327XtvfCiyRbotR+DJQ+1fF3smPHiS/QDloLC6aUXbxjb8BI zB9EAfUVVhpoaEogpJaMaIvl1V/+JnNQyhSYnzVuWqg+98Lo8yY0N4KzkTmJ4z1gDsCB J4+RXrkNm8SnXSOaCltLBVyPedk64zKorrsLk0oMZMz0fyiDjDMc3eAg+J7Rx2aS97tr iM8GF68VFCuMzMAGfVV92F4vhv5r8QkIMwR4/SHAEvCIUpK7zFICiq7oqqlI5C8AxjyP umuQ== 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=TZsOGiaArG1gPfWJWYyqQWKmeMDqaJOsSKH43M0pjNo=; fh=5cdAk/4eKFcH/8WtTZO0ubPFYqkVoBxeWOjASEhKlHQ=; b=PBWunIOlcFLd/x52GC/dEswpiKKmMezOPs5/Qi2Kv68fwVZmjgvOl9KO6ZaMvzq52S bvpJSteN1K3ztfoSS56H6Jh0UL+FFGrfYL+uprJwBjxWOctO2upf6EP2RWlF8mQVGgcB t4RzbSVSpom3BEaR2er94z/nA6hW5YfXNu1V6T9hGhwwKwQzpr5mdZdcl7q4CD9eug+g ZBzXYenaSBvIkEO0FmnUladvOioeKQ/myMFYB9Kez28FsSakL1HYnxkdI6UkT8SgVhNN RjzuISa3igdpPCsYzXTY4BEntlg49sosGKf3XcHOkJprp90aK8ZauZ7c6Ev35/+bx724 shcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Q/U+dBHC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l6-20020a656806000000b005bd03d2fda6si3105061pgt.350.2023.11.04.02.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Q/U+dBHC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id F28D880EA94D; Sat, 4 Nov 2023 02:17:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231734AbjKDJRF (ORCPT + 35 others); Sat, 4 Nov 2023 05:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbjKDJQ7 (ORCPT ); Sat, 4 Nov 2023 05:16:59 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91A2FD49 for ; Sat, 4 Nov 2023 02:16:35 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-7781bc3783fso186448385a.1 for ; Sat, 04 Nov 2023 02:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1699089394; x=1699694194; 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=TZsOGiaArG1gPfWJWYyqQWKmeMDqaJOsSKH43M0pjNo=; b=Q/U+dBHCPN+0cYxnzGDmOICtLzHegbWb2rExRSc9m0SSrRRG/7baJ4tiI/SuE1VeqH qa04UYbzXRvAmHv4GrOQeX3yscLfaLpWQ2YJE1PGNR1RhnTWdLz2K5FtdR6LygDxgSKa OCO/cQoCIsErOX7ebeTijU44VG1x7Xm8FEgn4okcW0i1cy/TJNSFy+k4mIcprYXnUg8E DVIgD2k46XlA4PGlthjXDyoL0LcjTC0J0I5BEkmgDVLFUP0Whel+xniIuj6s7kLFQiPu 634TCks3uHSlEuW9w10j0rQ0kAkET7ZG3SO+JMLnafVcaH8zIzbmxo3KhPE3x/eGpOVS wwfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699089394; x=1699694194; 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=TZsOGiaArG1gPfWJWYyqQWKmeMDqaJOsSKH43M0pjNo=; b=J9xOeLs/o/eq+YrdLZc/cgGzK18a2vL296XoJ+pUo04uymFb4PY3jr9fqS9BToF/sX zcapgu3PA1IkFsL1XvfC9gIbxUU9N/UPfpJGQ7tsgB7+dJODcnbCj9KQrm3MnernhEKk WoaFToea2R8QeZW4At2It+19KyRPda57shbcXWEI1Dje3wU59UKsiScdb+6YVc7UB7wB Z2Cacv99wOgcGNzGEs2GjjdVvw5kBflxRvEwA2nuPUPGHddQ2gX4LM0jnXMuHOfuZ5nJ 5Po/U/hfmrnrqItI/aUIlPP7wrt2aD+usfGb1I1RDRGubhBygYDP5oBCkdSsqd/8Q9us H0Dw== X-Gm-Message-State: AOJu0YzT9Ub1LfNz5tJWYtU23HW7BKwqRzuaSH02uQRhUsWxNQk8l0pl t/O7NA5mcHJtArFaUC7WsW505Q== X-Received: by 2002:a05:620a:2588:b0:777:2767:6465 with SMTP id x8-20020a05620a258800b0077727676465mr27504451qko.40.1699089394700; Sat, 04 Nov 2023 02:16:34 -0700 (PDT) Received: from devz1.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d4-20020a170903230400b001cc54202429sm2585127plh.288.2023.11.04.02.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:16:34 -0700 (PDT) From: "wuqiang.matt" To: vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@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.orgm, mhiramat@kernel.org Cc: 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.ne, "wuqiang.matt" Subject: [PATCH v2 1/4] locking/atomic: arc: data size checking in arch_cmpxchg Date: Sat, 4 Nov 2023 17:16:12 +0800 Message-Id: <20231104091615.4884-2-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231104091615.4884-1-wuqiang.matt@bytedance.com> References: <20231104091615.4884-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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 04 Nov 2023 02:17:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781624414071314360 X-GMAIL-MSGID: 1781624414071314360 Macro __cmpxchg() renamed to __cmpxchg_32() to emphasize it's explicit support of 32bit data size, 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. 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 Sat Nov 4 09:16:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 161553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1546452vqu; Sat, 4 Nov 2023 02:17:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgzoMvF6E3o8zGujbShmzY4o6O5DiuBnbaxqOv6HlF9xmuufuiNBksR/F82GJSI6m/yCdi X-Received: by 2002:a05:6358:5928:b0:168:e158:465 with SMTP id g40-20020a056358592800b00168e1580465mr20592545rwf.3.1699089429487; Sat, 04 Nov 2023 02:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699089429; cv=none; d=google.com; s=arc-20160816; b=M/4ISy48PJfjlZcqTxuLKDRrtJnoi2d9kVuwN0xBi1LSr9f7jUZKUVOz2g4Exzt2iQ uTM2nqUAqw4n1KVmFvr+wCTZ160cWLtBXO2FQqhS3vNT84FAW1zU83DJBLrAxYHf7+N/ XS+Cxrzy2eLf3hpCihKQkrIri3JtgSbUgFH9Vqt73LDKN5S4ZcmlKrqBg08AsGjJzBKa DmaKT4/HNB+iqVmSCELW2+a/rCuL3LmiFRCyOC4YMLazTyYAhBha7fbvGuEtNSyHRT4B Ofcy1WSPEeWRXUGMRNwNrubqgWvqsUjSBx1RTB2XHz7fjonYtuZDGJZaH1DRJtorV+L4 KTJg== 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=NnHn4ZqYSv6UF9nJWzupxlkq5TCbHngLtT+ZAjUP9Mk=; fh=5cdAk/4eKFcH/8WtTZO0ubPFYqkVoBxeWOjASEhKlHQ=; b=FTLJqczsDnrqkF2l9qau1vhU2jb91+cdL/NXZ6T/1ouWHFpifOJzp3+TiKKbaGgcRm bD/ReP0g6HEaICGIux2Uip3k4gNF3sdqGZhtMI2RcVQoY1/OcTSC0xg2n5JNzSywdsc/ SlqVbVKhIXJaQwKzSYGQLDKNqwQTrcPNx5oXaVPuY+jMMdHvLgQfivifDk+ObCjNrcEh W2F5UdSBXUWij1e8DE9IcsUzegmjrXFMWFwEATXPc2OTyW4v3oFi62Ffc+51hL0aDwqh 4Ypbc5Vzjo+lirpWpSPEBlLlnJ9kxOiN0Q46FsycqCM55G4zYQsomDsHnIR/+NO8mqX2 fMCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Q4/bGFeK"; 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 n9-20020a170902d2c900b001c1e4f9c63esi3591941plc.491.2023.11.04.02.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:17:09 -0700 (PDT) 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="Q4/bGFeK"; 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 10E26809C1A0; Sat, 4 Nov 2023 02:17:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbjKDJQr (ORCPT + 35 others); Sat, 4 Nov 2023 05:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjKDJQp (ORCPT ); Sat, 4 Nov 2023 05:16:45 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2394D48 for ; Sat, 4 Nov 2023 02:16:41 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cc3c51f830so22539795ad.1 for ; Sat, 04 Nov 2023 02:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1699089401; x=1699694201; 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=NnHn4ZqYSv6UF9nJWzupxlkq5TCbHngLtT+ZAjUP9Mk=; b=Q4/bGFeK6PryaX6xz0Umt5F6pdSwliT8DB/64Q2tnWd5rLp/QxHziczqlKUTgKcNUm UuZzoLV/vDvCqARluWIpE57H6YOeqa6Q4t/+qsZLkNVRvAJlsgRRyPcfGlb1XMAkp137 qmXvPz2ns/+rII8VjusLg+cWGUj8FFrsaro1up07ivlfBofsQoxghAO4thhX3qRayPco HQz1REuIfvw8PJRPsUqPxRP5XUt7OMt9SmEOOnFF6DIVEG8KdDexIKQ1mKPsUSISF2lc 3cPprdt7Kxv0B/NPAzMjvy9wqu8wtI3ZThTTW+1fMRMytDpvxj9a3Vh0ppFvPTgsYb14 kaZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699089401; x=1699694201; 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=NnHn4ZqYSv6UF9nJWzupxlkq5TCbHngLtT+ZAjUP9Mk=; b=Mbh3IQTNBCHrw1LGNn0KRTnhkHZwjn3Wguvkc0FKuZN/1af4ShL+N3Y6B3XHMzcRQv nHNGeqmoKHgkZU8cH3ojq/McnlZkXXykFB/sESgNWyLpVailpQHvkljjHWLJFV+Qcx0A 5tfK4V1N/M6kNatQzbxwUIkRTKWQVaxZufa1nP0cF3NgddaL1jqOQa2aAl9hJT0uLW+P WiDA4QDD/I8z0mT+6HTfwT1A8xx027bHB1hpqI9LZ+3gyxhfgv1dv1c2RcUsGDkMeiBW wEyMbCss1xFMMYoiQKgzKUf/zexT/hpGsUGPJAzg1NRkf1858J3MuT72U61kmrvmdv8F fffg== X-Gm-Message-State: AOJu0Yw4ePaEZWMprajh5gtRwROaMMrdNkL/y95uIM4pi4zWmlR0r7L0 oUxd72PDvDIW96t78VasNMUnQA== X-Received: by 2002:a17:902:d28b:b0:1cc:13d0:d515 with SMTP id t11-20020a170902d28b00b001cc13d0d515mr17598501plc.20.1699089401491; Sat, 04 Nov 2023 02:16:41 -0700 (PDT) Received: from devz1.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d4-20020a170903230400b001cc54202429sm2585127plh.288.2023.11.04.02.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:16:41 -0700 (PDT) From: "wuqiang.matt" To: vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@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.orgm, mhiramat@kernel.org Cc: 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.ne, "wuqiang.matt" Subject: [PATCH v2 2/4] locking/atomic: arc: arch_cmpxchg[64]_local undefined Date: Sat, 4 Nov 2023 17:16:13 +0800 Message-Id: <20231104091615.4884-3-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231104091615.4884-1-wuqiang.matt@bytedance.com> References: <20231104091615.4884-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,URIBL_BLOCKED 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]); Sat, 04 Nov 2023 02:17:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781624397125761886 X-GMAIL-MSGID: 1781624397125761886 For architectures that support native cmpxchg, we'd like to implement arch_cmpxchg[64]_local with the native variants of supported data size. If not, the generci_cmpxchg[64]_local will be used. 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 Sat Nov 4 09:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 161554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1546471vqu; Sat, 4 Nov 2023 02:17:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfoxvld6sjwuQ7USbLIHVISA0aRXjDQ6eNrao2MkxhTuqaJ/jG0Z2XxvpJ8/378aiKkHCY X-Received: by 2002:a05:6a20:1383:b0:17a:fa76:805f with SMTP id hn3-20020a056a20138300b0017afa76805fmr20372355pzc.23.1699089432852; Sat, 04 Nov 2023 02:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699089432; cv=none; d=google.com; s=arc-20160816; b=lLD6eBJ+zMC9Uwp6rpNDr7lld7XTWo+15ezMG5JrVcfvkljSb5mRlG46OPTArWnlcw doP4m96zy4OLC18tM+3+Z4s7HSoYeW1rZxztKqqRpWEalVHGtSWzOc0G8thOVNLt4VT+ ngQp7WkjLjgg59Td9ZYP41MP+/IZzx57NWIFBAwtm1vPNqJ00ftd/xd+I7BQC7ddTAog G2zoCXJLz3TJkr+7tlyqDwKDPQZdNE4C6ng42MYkCyEuxzFkwnnPB4tcpQZFc+IsCgkT rgC/gYP+WQngMkuxQtRhlqaIr0/9DRQYshVfFCJEx65XyRaIy9NTGhIcDS95Pp7SK9bb Lg4g== 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=u81VqdenU6rFeGWkxk+k7NmV751uBEWgkJJ/j9Mn6BA=; fh=5cdAk/4eKFcH/8WtTZO0ubPFYqkVoBxeWOjASEhKlHQ=; b=qDQV9gHGrdmtnOHh66Vm1DBeNywofip3UP1889tSrs2QLsW/EmGWoMazW/umG2EUQZ QI7MySd+tTeVYHnWc75fxxN/NYH7+t+OUMGXn3j5Bd22OqT/WspHhGPZu+UKR5K+9Y3n MO5RO3gl5wSagSEEL52tOO2eKLRniFKHXUZ1VF7G5dlw74ODkW/uOK/iJNV+GmNai50e ayFPQ1RVCaT1xYk8bf54prxUcv3vyA6jrSG/TZ1czNVB2qv15wYcHOD5+SuL4wjncqyJ mVqJDobJJBZhydvHJ82aYCmrst4xR3ueAjieI36gAztkWwAycx1HjKT2AY7EBzrTFLla Kheg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iXZFWWqp; 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 d6-20020a17090ad3c600b0027cd01b6cb0si3255309pjw.125.2023.11.04.02.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:17:12 -0700 (PDT) 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=iXZFWWqp; 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 4AE01817890C; Sat, 4 Nov 2023 02:17:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjKDJQ5 (ORCPT + 35 others); Sat, 4 Nov 2023 05:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjKDJQv (ORCPT ); Sat, 4 Nov 2023 05:16:51 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06E8D48 for ; Sat, 4 Nov 2023 02:16:48 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cc3bb32b5dso25593865ad.3 for ; Sat, 04 Nov 2023 02:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1699089408; x=1699694208; 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=u81VqdenU6rFeGWkxk+k7NmV751uBEWgkJJ/j9Mn6BA=; b=iXZFWWqpaH4lrEjLLgW4xKnBoKhtVmWVQ6o192cCZsu/A2WluT+/ABCn+FH76UY9wb mFug182r1PZt5hqvYxYgHaDoWHWl+nZODIOs1iUxm4mFRK5Yw2fQlVPpesAool2Pb9oO cHYSJnr1t8t05HRzYt5Z6Y6rHJ8L+clIozV5ooPGIvnqOUzCcwDMFR9iurKTHioFouyi Hb2HDSwecBtNY705+VUJWX4n5NU3AvBuoZbHslPdjyJTs93/nMSwwvwjEAhPD2ldY2oE gMrElQcY49bYFh8CoVy0aot1xFBZlMXzDoRAP5K0kLIwy5ryavHTJq6LmA2Fl2CW8NoT nVPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699089408; x=1699694208; 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=u81VqdenU6rFeGWkxk+k7NmV751uBEWgkJJ/j9Mn6BA=; b=mpY5mk8cEiOSDq5P+QOa5ebb5gqml4ggydqW8DFJjLcWRHIMJdpjSt0j04PgLcDlFo fij/lNzCB0jcOm3J7+FnFSqplafB6fiJUNrSdR1RZwUua+Oov8a+OpCQdVjXdvMxbXYf WsiVEJjf3ydFt3tYgc+GPeytEyOCTonM9vSV4Za7UM8x+YJ9QQaM0Hsg4rNMKGFUINjL Em1lfQ5jEl2D0THeNNs4G5WtdR3op44109yzbBWmhPCfxR3g4YSpoaCjphm97SW9aOtw eXfJfEslwZ6TLK8Yb8BRxxtto39DOES0+zThqi+f5HWUP0oN/Wy/B8OgSsRAwd/5Kh8f gRDA== X-Gm-Message-State: AOJu0Yw/fhTME8BrvgZi7nvqzo6qKSHBVTqcV1cJPT6kZAqFVFaP2fxH WWEHdxR6I+DxGOVrI+y3ZY8IZA== X-Received: by 2002:a17:902:ea0d:b0:1cc:4f55:db72 with SMTP id s13-20020a170902ea0d00b001cc4f55db72mr20756805plg.0.1699089408468; Sat, 04 Nov 2023 02:16:48 -0700 (PDT) Received: from devz1.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d4-20020a170903230400b001cc54202429sm2585127plh.288.2023.11.04.02.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:16:48 -0700 (PDT) From: "wuqiang.matt" To: vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@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.orgm, mhiramat@kernel.org Cc: 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.ne, "wuqiang.matt" Subject: [PATCH v2 3/4] locking/atomic: openrisc: arch_cmpxchg[64]_local undefined Date: Sat, 4 Nov 2023 17:16:14 +0800 Message-Id: <20231104091615.4884-4-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231104091615.4884-1-wuqiang.matt@bytedance.com> References: <20231104091615.4884-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,URIBL_BLOCKED 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]); Sat, 04 Nov 2023 02:17:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781624400978774755 X-GMAIL-MSGID: 1781624400978774755 For architectures that support native cmpxchg, we'd like to implement arch_cmpxchg[64]_local with the native variants of supported data size. If not, the generci_cmpxchg[64]_local will be used. 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 Sat Nov 4 09:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 161556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1546815vqu; Sat, 4 Nov 2023 02:18:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGq4h3sMg2GNSqbA6k8N7lKRTp1nDfkb1q+9BRIrodeXW8dk/By6OGZNqW8hfHnY9IYvRXZ X-Received: by 2002:a05:6a20:7d84:b0:158:17e6:7a6 with SMTP id v4-20020a056a207d8400b0015817e607a6mr34432703pzj.42.1699089490605; Sat, 04 Nov 2023 02:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699089490; cv=none; d=google.com; s=arc-20160816; b=ERQ1saRg6biq2XuYj0eMhu6TPKQjjutQr8+hkca93/k9r4yNupYlbq7W4RNE942pZp bKGTY0zrGM6NamEG1QVZ0kUc5zSFSUPtU6aDIaktSUU91Ch7lGPb+vSocNOmU0VUbhFh K2v9qJv3fYwjLTVRWs8UZ0pYzLSM70MZF+40UzA4u+mx47FHZjqOM64SK85UzLwhF5pe o2ysvfQ857DgPKasbHTHTQCsPUX2hw+9dRl2oYQEsWtA5GG+zROayz3kPJT0TCCnhs7e DNsLk85kzqwql3YaxbMHmrKwyVK1+DBrQMitOrLBM3PU5Em8BSuKbFGn8F59Lwu3TaO3 jPJw== 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=ca5+RMX27tK8Pble5rnmjXYY/wcc9M5C/f3DXh2ZNs0=; fh=FcU+1wdDt4YWyhgmjWq3tn/F3zetKosmuXEJ+KRSu7U=; b=O/8eUj7k/FBzj/XUO+VGP57q/jAFMsttBxB/JXLNKTHYDekPGoaIazDEPzCHAAN99L 3pcQyAkImv4bTB/vefN1ET7OAgx/mTbICNjdGLUVDTd4405tiEsv5cZaiY0uoEhfTeYf K71t9SMdTQfOv8u4xAtr0UKPKkmvHkDFRzFEeiDU5gzQjVub8dMY4YNCjbXK63Mlai27 4uYXL+1ny54+rCT6C5TeFlbqYq0UhrpkieNcKCD0ELTGSw/KP1vXViBIj/BJuzld+j5K VtgBJ5+BHVmpBY1IMDNw4fHvEmIYPtwZThycZcmE0+4Wu8OGfLaX+6Ucq0xXv9rgQieh AUmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=XEwU0yu5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id i9-20020a17090332c900b001c6183af4d3si3682824plr.332.2023.11.04.02.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=XEwU0yu5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 1B84A80A9905; Sat, 4 Nov 2023 02:17:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbjKDJRZ (ORCPT + 35 others); Sat, 4 Nov 2023 05:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231638AbjKDJRR (ORCPT ); Sat, 4 Nov 2023 05:17:17 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0D1D65 for ; Sat, 4 Nov 2023 02:16:56 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cc5b7057d5so25782075ad.2 for ; Sat, 04 Nov 2023 02:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1699089416; x=1699694216; 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=ca5+RMX27tK8Pble5rnmjXYY/wcc9M5C/f3DXh2ZNs0=; b=XEwU0yu5PEk36RFN4IAPUKC7D5muKDZt9aSmIw33le1DnG64+iz3t5usxWi1efoKOA 26SGpYkdFBBPdcM3OaHTY7Jng53GPhUKc9CDNeH1XqFIoPiYQ6cpEwREPQFVU/j5CUYW pKyGSH4dVFgbBfE7lixRc/rzwXUS3aqrcmL2sSrq3GOW+57krMt8YgmlfujE/cTnc6lt OO01FDkQ8eVsFo683ZrEBdTIttGiR65MYlGZNkinORhLYrFICrdtN2vhf+RdVOYpx0hZ 1E1YIICudioGNVEe3v01VTlQCkWX6n0Z+SMofZkx70OMfn1fFmJFwbJtcijrIxG6UdZj FfYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699089416; x=1699694216; 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=ca5+RMX27tK8Pble5rnmjXYY/wcc9M5C/f3DXh2ZNs0=; b=Fuk8gGGZ1OIoyaS/c74wcPHOKEo8eGHO1vD+Spn8zpg35MrXfN5TTcSwtSuysal9N1 Sqb1F7bWDAVGOsA3TG0ksUfucmGCp+jZvcdl+72KW6ZDwp1sT3mHHj0hGXXyIjsVYZP2 +0L1Y0V15s1aphy/YRVLQUA2ANPjk1MYyeZnFmFg2WstlGSy7ZUKA/ZggXX/MVBkx9Bk tnzcwhTpiDjxLz4kEuz2cJnJ0AtxlOXDcMuZ0QZpxmd+FMUb+czWSYkKbjB7zXSW58GE JYsUFoIwYsm6PXMPAAnBjt23RMi8K4iApJDWRdZ34U4sn+VVcLasW0qI8JqfKOYrI4i+ hD7g== X-Gm-Message-State: AOJu0Yx0BNIPRPa7MBABoW99ZTANIAYvnWyoLddgH+JuCFEc4pCkW1/Z zxcK+ArE6CicNvVaNIiKvLEG6Q== X-Received: by 2002:a17:902:e88f:b0:1cc:5b5a:62a5 with SMTP id w15-20020a170902e88f00b001cc5b5a62a5mr18228857plg.9.1699089415812; Sat, 04 Nov 2023 02:16:55 -0700 (PDT) Received: from devz1.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d4-20020a170903230400b001cc54202429sm2585127plh.288.2023.11.04.02.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:16:55 -0700 (PDT) From: "wuqiang.matt" To: vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@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.orgm, mhiramat@kernel.org Cc: 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.ne, "wuqiang.matt" , kernel test robot Subject: [PATCH v2 4/4] locking/atomic: hexagon: arch_cmpxchg[64]_local undefined Date: Sat, 4 Nov 2023 17:16:15 +0800 Message-Id: <20231104091615.4884-5-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231104091615.4884-1-wuqiang.matt@bytedance.com> References: <20231104091615.4884-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_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Sat, 04 Nov 2023 02:17:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781624461559380570 X-GMAIL-MSGID: 1781624461559380570 For architectures that support native cmpxchg, we'd like to implement arch_cmpxchg[64]_local with the native variants of supported data size. If not, the generci_cmpxchg[64]_local will 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..2b5e5bbaf807 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 */