From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D55BCC433F5 for ; Wed, 2 Mar 2022 19:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240983AbiCBTer (ORCPT ); Wed, 2 Mar 2022 14:34:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239026AbiCBTeo (ORCPT ); Wed, 2 Mar 2022 14:34:44 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 481874FC76 for ; Wed, 2 Mar 2022 11:33:58 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id w37so2486618pga.7 for ; Wed, 02 Mar 2022 11:33:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2/7TR1czOlrni5ve6cjMiYf0huddF9ZUrXfqRqxvxSU=; b=pNibpYwhsyhSu1HqTGYjGU8JzPqNoU7cHvFkSUbu2sCsHp/EphxSSJEocYDVhiRdM+ sKAwbSV5PWyHRpki7EvohvnWo+tEJuU3QZG+Yz0rjwShV+zWoIb8tajePwQ3VpDJPXrb fD5MEZ46OSpAXyy7oxCWEzYKtEJ/4OViaC5xr7Zd5LD/OrekyQKFTJNVjdUPNfise/mh iyHXCgYoE58om7RG7g9nQvvwRDDF9eDk6pHoesWyu9rUPY95PlSf/k3wKea2uCz6R8Nt 1d8fhx9zcbJkcBrcxpf0sOfLVAmBus/9UPtMl+KdSTn0bCiPuZEn5CiywtLeKb/15KrI l2UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2/7TR1czOlrni5ve6cjMiYf0huddF9ZUrXfqRqxvxSU=; b=5+x2TrR4o1V/xJWWIslmt2/Dnhrxg8TP4rNpO/dI92iP61f0I16x1ZDS3TzEolExns XxCiix38HVSpTgZeMkoCBV1xOQXw+J+9r/UyywwfqCxImAb9gTIfgkMzGLIrhNDe4Cxa x6zzUVYyW4nEQnLd/G3ohVaIgICihRj1qQNxusLyL0y1fAZgoqsRjw+z2TwQmKJdiBpO 2qKXsYm9YZXFvDuTQC3Ddo+mKPWxA5RSMGMlRfv9h1ztyylPt+DEtP0B+hI0F0l2MMNG 458Hz+chYe9qJm8nXx7ZH51OrVlv3isfQ2Onggxs4k+TDsDoOEV2izbGYC1oc4vyELti OnZg== X-Gm-Message-State: AOAM5337tZfZJNRQHzoaCPyJsVRhNkKtnNBids3xJssVKdxiUPPRZXBs du9tyOhmb9gRWppSClh56839QQ== X-Google-Smtp-Source: ABdhPJxMm2HhuXip/+Ypn78NGQSL9LpS8YyhU3LOl2tsaeVF9uBhm+MuFsRaTN46IJajehuRwXWqhA== X-Received: by 2002:a63:6b07:0:b0:37c:52b4:60fb with SMTP id g7-20020a636b07000000b0037c52b460fbmr276254pgc.381.1646249637296; Wed, 02 Mar 2022 11:33:57 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id k7-20020a63ff07000000b00372dc67e854sm16352520pgi.14.2022.03.02.11.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:33:56 -0800 (PST) Date: Wed, 2 Mar 2022 19:33:53 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Ben Gardon , Mingwei Zhang Subject: Re: [PATCH v3 22/28] KVM: x86/mmu: Zap defunct roots via asynchronous worker Message-ID: References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-23-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 02, 2022, Paolo Bonzini wrote: > On 3/2/22 19:01, Sean Christopherson wrote: > > > It passes a smoke test, and also resolves the debate on the fate of patch 1. > > +1000, I love this approach. Do you want me to work on a v3, or shall I let you > > have the honors? > > I'm already running the usual battery of tests, so I should be able to post > it either tomorrow (early in my evening) or Friday morning. Gah, now I remember why I didn't use an async worker. kvm_mmu_zap_all_fast() must ensure all SPTEs are zapped and their dirty/accessed data written back to the primary MMU prior to returning. Once the memslot update completes, the old deleted/moved memslot is no longer reachable by the mmu_notifier. If an mmu_notifier zaps pfns reachable via the root, KVM will do nothing because there's no relevant memslot. So we can use workers, but kvm_mmu_zap_all_fast() would need to flush all workers before returning, which ends up being no different than putting the invalid roots on a different list. What about that idea? Put roots invalidated by "fast zap" on _another_ list? My very original idea of moving the roots to a separate list didn't work because the roots needed to be reachable by the mmu_notifier. But we could just add another list_head (inside the unsync_child_bitmap union) and add the roots to _that_ list. Let me go resurrect that patch from v1 and tweak it to keep the roots on the old list, but add them to a new list as well. That would get rid of the invalid root iterator stuff.