Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6664880iob; Wed, 11 May 2022 02:38:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTNzH8MUUeLilsc9E0kpBgqOyn2Ty8ajwDXAE/04hgfAcqDvFMJoEdB/mnAmiOq2E0NJ2S X-Received: by 2002:a17:90b:4a4a:b0:1dc:4731:31a4 with SMTP id lb10-20020a17090b4a4a00b001dc473131a4mr4424656pjb.19.1652261919488; Wed, 11 May 2022 02:38:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652261919; cv=none; d=google.com; s=arc-20160816; b=AnRJHvMLMqdzhxQdu4UkoCBQmc4zKkVxQG0fyGoIlZg8CgOTbKEdyEkr4v2u8CV+gj f82LJelAHOhUZVL1qKK9MwemKJus02LTYdMnjiHz/gqX2b4XnVcndy+gbep5LX12VQiy 2dUPZUpFxdcs5pe5VRslG8IMwHWpqCuv5Yx5UZ3wC4wKyspqWIDM/i6Venh85pzQ/++n 13Na+7HnNyHDD2CqcxFUDFRjoGnTEDDhM9yr72AyNYlpq9Tt2KmYb3mnInjJq/cWf0es PJvF2jg06iKjHrKdWuRpqdxpOiILU+7q1Trb9C/PSArychY8+q5MzzQwqj+usHKqFHmn 7/wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NRzg9BMGZ8Y+RRvXMPsod+kdMY39tgO1LAjDB+4Koho=; b=yJHDJEPg20lxiaxCpK3DtnDvKPGpMtaSv2OpcNoV2GIYgU0dXfZu80Oj2gXUUFqAxE PL4a1govgq2LDahFEZG3nRkhsVQ/x65S2/IjJvBLvOG5U383OYB8815feMk3lV7oCEIN tgvJENThyKcl3rwoYor88hL2dm+YQxDZbRhKjcn+Ru930zO93+xYjPEMVssHnFD+g8HO zFpyyiosP/QTrLmEefvwCmdMEFRkFAmn4THsyawdOKSTpasOAQbuebot1AJkYqpLTMyI UOf4m/qmKzZMwcjsTPrEWwCADb3VX9wjhZSY7pDriXz/YJP6/jZFZ8lFFnuf1btWQkfJ p7xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=W5uCK5iU; 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 pi4-20020a17090b1e4400b001d92f594d3bsi2410549pjb.86.2022.05.11.02.38.24; Wed, 11 May 2022 02:38:39 -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; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=W5uCK5iU; 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 S235735AbiEKHyk (ORCPT + 99 others); Wed, 11 May 2022 03:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239799AbiEKHyi (ORCPT ); Wed, 11 May 2022 03:54:38 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02BEB590A4; Wed, 11 May 2022 00:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NRzg9BMGZ8Y+RRvXMPsod+kdMY39tgO1LAjDB+4Koho=; b=W5uCK5iUANqz0n4NnO/prBk8/D 6MdMrRP8VEA+HE2DeJI842gi9L/YVcwPw4cIlXBXMwgGb4l+YEXBpayM5aANi+05OUSfO9bHyuQio 7hapr+FvMnWi1NExGYf6xuRyrIe7R426HnuTx4gpZImZ4XL4w42lbG+XorJexICtkq0EZP5YmDHNq 2P75nD6+JoddYL59d4WCzYrrHrWY3AotkXEr0ED1FlxElQfwBmct1mdG+YaPh/46EsI8C/L95c+kC mAnWc1PcYQVXifThtahz9fozV+wDAOBAipLe99xOxG903cvW8wCyf40CU/YmKFhfCwWAsPO7ta3gq o3qEhWPw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nohAh-00D6D6-PM; Wed, 11 May 2022 07:54:12 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 57FBD980E3A; Wed, 11 May 2022 09:54:09 +0200 (CEST) Date: Wed, 11 May 2022 09:54:09 +0200 From: Peter Zijlstra To: Uros Bizjak Cc: X86 ML , LKML , kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Will Deacon , Boqun Feng , Mark Rutland , "Paul E. McKenney" , Marco Elver Subject: Re: [PATCH] locking/atomic/x86: Introduce try_cmpxchg64 Message-ID: <20220511075409.GX76023@worktop.programming.kicks-ass.net> References: <20220510154217.5216-1-ubizjak@gmail.com> <20220510165506.GP76023@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, May 10, 2022 at 07:07:25PM +0200, Uros Bizjak wrote: > On Tue, May 10, 2022 at 6:55 PM Peter Zijlstra wrote: > > > > On Tue, May 10, 2022 at 05:42:17PM +0200, Uros Bizjak wrote: > > > This patch adds try_cmpxchg64 to improve code around cmpxchg8b. While > > > the resulting code improvements on x86_64 are minor (a compare and a move saved), > > > the improvements on x86_32 are quite noticeable. The code improves from: > > > > What user of cmpxchg64 is this? > > This is cmpxchg64 in pi_try_set_control from > arch/x86/kvm/vmx/posted_intr.c, as shown in a RFC patch [1]. I can't read that code, my brain is hard wired to read pi as priority inheritance/inversion. Still, does 32bit actually support that stuff? > There are some more opportunities for try_cmpxchg64 in KVM, namely > fast_pf_fix_direct_spte in arch/x86/kvm/mmu/mmu.c and > tdp_mmu_set_spte_atomic in arch/x86/kvm/mmu/tdp_mmu.c tdp_mmu is definitely 64bit only and as such shouldn't need to use cmpxchg64. Anyway, your patch looks about right, but I find it *really* hard to care about 32bit code these days.