From patchwork Mon Sep 18 20:27:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 141563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2933641vqi; Mon, 18 Sep 2023 13:28:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6H4269a+nBRTVQL4NaCDMoEG8PbC5/kWRZD9Ss5aodkmQ1xgxLUXb92TrM26pL741AgzH X-Received: by 2002:a17:902:d342:b0:1c5:64aa:b97a with SMTP id l2-20020a170902d34200b001c564aab97amr3785755plk.38.1695068911017; Mon, 18 Sep 2023 13:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695068911; cv=none; d=google.com; s=arc-20160816; b=QJmELaIJ/6aMQ6fG9Lyy9mtnsfG+43AEGIqzhL4hevPlhPlGKYnAMI6cqJ/pqMdrp/ 2+j700wP/tH99LWAMvyxw9OjmkM6r8WDcvRv9DGtK2PJoqbh8IDKa2TdEVsBnZmeOVJk 0Bh1qUL3zPUmOrarxucu6jj+P5axHFZT6hprhNfrz+omh1g1/GKC+3LvCWRYDH+3WVbr nIflB586ENuSK3NEiHahbWQ60cqac/zxXg0+QfoBXMs4N/OaaB7jTDxyjicMVIQyH0yf ACeZ/+FncujZerQrffs9o49Cfwx30wcl4d8xhfZgsgeCwpLcgsCB19MnFWDdItWG1sNF CBHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=KXarTd7h80pS9CevpZMD+Q39jLm42otwbryQ+NFoxm8=; fh=aMuEctUrpEjcm7+Z6FW9dcyBzbyQClfa+XesJRjdIVw=; b=oRCJSX6IoQ7jwD+sD002lFbeyqIXoE+Mu2yBoUMTuiZE+QpZDtMa7FsWrMd9nbp3c/ /GRfMC/RfuLeeuMEd//1Ce1Z+Jc7B06Eu/caRVta7cd8h9jTA085ydvJnkwR7sNd237s 6btNEXx0O9/T1BoGOB3qQwzaTQvIVqROn09ZZW0+TRLk/A85pkaigaD1g1eEplUtkXQk 6cn5zg7OE0fa4OhnTSF7yo0pTkbyU/UcfPTiqDh8q5UalRmNmYYJNFF3xN1S6vK8sSJ1 yy0Ko0W06TLA6o1glOqd8iH6ATsn/Xh+UnyiqHQgb3nYn1s2WnlBEdVBx/hdpVSJ6N3N tmvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LwQJy4qk; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j6-20020a170903024600b001c3be32bc4dsi9009672plh.23.2023.09.18.13.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:28:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LwQJy4qk; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 79518811B06C; Mon, 18 Sep 2023 13:28:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbjIRU2A (ORCPT + 25 others); Mon, 18 Sep 2023 16:28:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbjIRU15 (ORCPT ); Mon, 18 Sep 2023 16:27:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A62F119; Mon, 18 Sep 2023 13:27:51 -0700 (PDT) Date: Mon, 18 Sep 2023 20:27:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695068868; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXarTd7h80pS9CevpZMD+Q39jLm42otwbryQ+NFoxm8=; b=LwQJy4qkqEKR6+ZPWu5lebiuYZMwKZLUhomkqmaBvg67XvOlaRgItuPUbyZQGTP/fhx3oQ PgoRLZcvdqEjmr39jF+IsS0HzZZUOTL4ES3vVSG5oq8gHDCHxV7/kuxRK8NuQ4Zsu9OyjN 0paVD3ykH41sb7iOwLRFCq1+Sw0HGv6hok/9R6LV54Jht/Ob+zfzRgERfDp4w/lih7hrPc mBDp9viMV8Sxmf44wpf2r6CrZBTxMJNhbb24ZfQBkIckdk+xX4tj3K0s4GUnfrWdmnb1pR LQgCwb2WK3MUDurx7qrfO1wb10/L3JneZuDAIoKI7gife3gLCMZWdk94GnDELw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695068868; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXarTd7h80pS9CevpZMD+Q39jLm42otwbryQ+NFoxm8=; b=knPUmm2d/PvPmZoNd/aBVmRTglWkwa5v5eMbqgsLfq1lfRceV0pSWgN8OZHHL/V7PkQzGE 6Xsu2J3ncqBU5rDA== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/lockref/x86: Enable ARCH_USE_CMPXCHG_LOCKREF for X86_CMPXCHG64 Cc: Uros Bizjak , Ingo Molnar , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230918184050.9180-1-ubizjak@gmail.com> References: <20230918184050.9180-1-ubizjak@gmail.com> MIME-Version: 1.0 Message-ID: <169506886746.27769.14933126685918343806.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 13:28:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777408578430241527 X-GMAIL-MSGID: 1777408578430241527 The following commit has been merged into the locking/core branch of tip: Commit-ID: a432b7c0cf420dbf2448c6bda6a6697afbb153d5 Gitweb: https://git.kernel.org/tip/a432b7c0cf420dbf2448c6bda6a6697afbb153d5 Author: Uros Bizjak AuthorDate: Mon, 18 Sep 2023 20:40:27 +02:00 Committer: Ingo Molnar CommitterDate: Mon, 18 Sep 2023 22:18:32 +02:00 locking/lockref/x86: Enable ARCH_USE_CMPXCHG_LOCKREF for X86_CMPXCHG64 The following commit: bc08b449ee14 ("lockref: implement lockless reference count updates using cmpxchg()") enabled lockless reference count updates using cmpxchg() only for x86_64, and left x86_32 behind due to inability to detect support for cmpxchg8b instruction. Nowadays, we can use CONFIG_X86_CMPXCHG64 for this purpose. Also, by using try_cmpxchg64() instead of cmpxchg64() in the CMPXCHG_LOOP macro, the compiler actually produces sane code, improving the lockref_get_not_zero() main loop from: eb: 8d 48 01 lea 0x1(%eax),%ecx ee: 85 c0 test %eax,%eax f0: 7e 2f jle 121 f2: 8b 44 24 10 mov 0x10(%esp),%eax f6: 8b 54 24 14 mov 0x14(%esp),%edx fa: 8b 74 24 08 mov 0x8(%esp),%esi fe: f0 0f c7 0e lock cmpxchg8b (%esi) 102: 8b 7c 24 14 mov 0x14(%esp),%edi 106: 89 c1 mov %eax,%ecx 108: 89 c3 mov %eax,%ebx 10a: 8b 74 24 10 mov 0x10(%esp),%esi 10e: 89 d0 mov %edx,%eax 110: 31 fa xor %edi,%edx 112: 31 ce xor %ecx,%esi 114: 09 f2 or %esi,%edx 116: 75 58 jne 170 to: 350: 8d 4f 01 lea 0x1(%edi),%ecx 353: 85 ff test %edi,%edi 355: 7e 79 jle 3d0 357: f0 0f c7 0e lock cmpxchg8b (%esi) 35b: 75 53 jne 3b0 Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Acked-by: Linus Torvalds Link: https://lore.kernel.org/r/20230918184050.9180-1-ubizjak@gmail.com --- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 66bfaba..1379603 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -28,7 +28,6 @@ config X86_64 select ARCH_HAS_GIGANTIC_PAGE select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 select ARCH_SUPPORTS_PER_VMA_LOCK - select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_SOFT_DIRTY select MODULES_USE_ELF_RELA select NEED_DMA_MAP_STATE @@ -118,6 +117,7 @@ config X86 select ARCH_SUPPORTS_LTO_CLANG select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_USE_BUILTIN_BSWAP + select ARCH_USE_CMPXCHG_LOCKREF if X86_CMPXCHG64 select ARCH_USE_MEMTEST select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS