Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3345572iob; Mon, 16 May 2022 20:10:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4HotF2EemBZQ3PShqMErPEXC/KKw9BOB5N5wCdMYQoQ0vNEbxNgq9TbQuByxso2mYmLTO X-Received: by 2002:a05:6402:2911:b0:42a:b141:b221 with SMTP id ee17-20020a056402291100b0042ab141b221mr8780307edb.138.1652757017845; Mon, 16 May 2022 20:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652757017; cv=none; d=google.com; s=arc-20160816; b=oKOoWBFPnJnP1BEvolaBOsxgznpYpag2+6z01OJb0vxzFn+Afrm4PGQooN1TUmvJM5 oG9K3KjyEQ9QpzaWjjv6ovk15GggHS3y1gvU87knngP7HkfChCOqlyPrnGLEnHse6bU5 fzrZQnQSVnndL6lw1eHv6HaAj2DsLZnMVj3YAqX4jT1b5nqtPJZONlEPugRrNqI+Rzu0 RCFbUeJuTJmks1un/EfCHeL1QC/s6Yn0JuLVXSSzXe+W5fk/NIcrYCCXqLIJRsIUlKwc BPle/gAit8OYyIRzpC9S2DvDR6QIXDVkMmSRb+6y3M1O7fexypXWxEjscXhVUwObT5j8 +CYg== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=DIRR+/4xP3PcsIIpPjK0T2ZfAKws5p6jyUGEq00/P8o=; b=G1UkEDFtgcib1wk+MEEUKC11B35lWRZVSzKmzfpF8xWTZPwmxbAdT4snrLWRGktHP3 vSIUCgPQZnRw7QYXuSGLC6Vy5a0R3OGf37paGbGsNCN5Y5rB+J3dEUB9ZZRL2sVNl/M0 qoVfLs55V2pDNarzQkk94PwKOUp5Elq26M3/7SLqXILnO4ku9d7xgKSLuaQzEHus/ufv K+cscroQdZNgDvHRRtVKrAuSG2IIOFYtkf+U6Vst/oS14+vCFwMrhx+gAPEXgl/fgtAV ypi43nGmVZXaQAsqU5FTSDIWTr/dPSA4PxCMP+6JEDg9NMzyt1L3N/IA6PcgIMy7RvIn hVRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IXAl6qc7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm14-20020a170907948e00b006f38baab73fsi1243078ejc.530.2022.05.16.20.09.52; Mon, 16 May 2022 20:10:17 -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=@redhat.com header.s=mimecast20190719 header.b=IXAl6qc7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245402AbiEPPhJ (ORCPT + 99 others); Mon, 16 May 2022 11:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244903AbiEPPhH (ORCPT ); Mon, 16 May 2022 11:37:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E04C72458A for ; Mon, 16 May 2022 08:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652715425; h=from:from: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=DIRR+/4xP3PcsIIpPjK0T2ZfAKws5p6jyUGEq00/P8o=; b=IXAl6qc7SwSNaHHtBqvRLdsbEiCysOSgngXi2/Nn+FmP2MLVEbU8WUw3qqLyeIYnafuHRX 01D1Wi65Gmnaw3Sx4cLs4MhUpBWM3xyqyf/q6CpKMdmB5xsHZ7jxxy8AszAVioCYSi55mu uwnpmV++hU3Xgaem/+U1JYSMhr2JrPo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-455-9Rov6n1COPmSVID0SU7tbA-1; Mon, 16 May 2022 11:37:01 -0400 X-MC-Unique: 9Rov6n1COPmSVID0SU7tbA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8F1D395AFE5; Mon, 16 May 2022 15:37:00 +0000 (UTC) Received: from starship (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71B61400E880; Mon, 16 May 2022 15:36:57 +0000 (UTC) Message-ID: <874fad1e8443a88ef962775a960aac219c838b17.camel@redhat.com> Subject: Re: [PATCH] locking/atomic/x86: Introduce try_cmpxchg64 From: Maxim Levitsky To: Sean Christopherson Cc: Uros Bizjak , Peter Zijlstra , 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 Date: Mon, 16 May 2022 18:36:56 +0300 In-Reply-To: References: <20220510154217.5216-1-ubizjak@gmail.com> <20220510165506.GP76023@worktop.programming.kicks-ass.net> <20220511075409.GX76023@worktop.programming.kicks-ass.net> <9ed2fc294bf2c21b41b22605ff8039bb71903712.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Mon, 2022-05-16 at 15:14 +0000, Sean Christopherson wrote: > On Mon, May 16, 2022, Maxim Levitsky wrote: > > On Mon, 2022-05-16 at 14:08 +0000, Sean Christopherson wrote: > > > On Mon, May 16, 2022, Maxim Levitsky wrote: > > > > On Wed, 2022-05-11 at 21:54 +0200, Uros Bizjak wrote: > > > > > On Wed, May 11, 2022 at 6:04 PM Sean Christopherson wrote: > > > > > > On Wed, May 11, 2022, Uros Bizjak wrote: > > > > > > > On Wed, May 11, 2022 at 9:54 AM Peter Zijlstra wrote: > > > > > > > > Still, does 32bit actually support that stuff? > > > > > > > > > > > > > > Unfortunately, it does: > > > > > > > > > > > > > > kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \ > > > > > > > vmx/evmcs.o vmx/nested.o vmx/posted_intr.o > > > > > > > > > > > > > > And when existing cmpxchg64 is substituted with cmpxchg, the > > > > > > > compilation dies for 32bits with: > > > > > > > > > > > > ... > > > > > > > > > > > > > > Anyway, your patch looks about right, but I find it *really* hard to > > > > > > > > care about 32bit code these days. > > > > > > > > > > > > > > Thanks, this is also my sentiment, but I hope the patch will enable > > > > > > > better code and perhaps ease similar situation I have had elsewhere. > > > > > > > > > > > > IMO, if we merge this it should be solely on the benefits to 64-bit code. Yes, > > > > > > KVM still supports 32-bit kernels, but I'm fairly certain the only people that > > > > > > run 32-bit KVM are KVM developers. 32-bit KVM has been completely broken for > > > > > > multiple releases at least once, maybe twice, and no one ever complained. > > > > > > > > > > Yes, the idea was to improve cmpxchg64 with the implementation of > > > > > try_cmpxchg64 for 64bit targets. However, the issue with 32bit targets > > > > > stood in the way, so the effort with 32-bit implementation was mainly > > > > > to unblock progression for 64-bit targets. > > > > > > > > Would that allow tdp mmu to work on 32 bit? > > > > > > From a purely technical perspective, there's nothing that prevents enabling the > > > TDP MMU on 32-bit kernels. The TDP MMU is 64-bit only to simplify the implementation > > > and to reduce the maintenance and validation costs. > > > > I understand exactly that, so the question, will this patch help make the tdp > > mmu work transparently on 32 bit kernels? I heard that 64 bit cmpxchg was > > one of the main reasons that it is 64 bit only. > > I don't think it moves the needled much, e.g. non-atomic 64-bit accesses are still > problematic, and we'd have to update the TDP MMU to deal with PAE paging (thanks > NPT). All those problems are solvable, it's purely a matter of the ongoing costs > to solve them. > > > I am asking because there was some talk to eliminate the direct mode from the > > legacy non tdp mmu, which would simplify its code by a lot, but then it will > > make 32 bit kernel fail back to shadowing mmu. > > Simplify which code? Between the nonpaging code and direct shadow pages in > indirect MMUs, the vast majority of the "direct" support in the legacy MMU needs > to be kept even if TDP support is dropped. And the really nasty stuff, e.g. PAE > roots, would need to be carried over to the TDP MMU. > I guess this makes sense. I haven't researched the code well enough to know the exact answer. I was just curious if this patch makes any difference :) Thanks! Best regards, Maxim Levitsky