Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp205253pxm; Wed, 2 Mar 2022 13:30:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEgakyAKuJqEaE/r2oZusuDNZuBW0gY4KXW/L9Gw8BMj5ysY/i+pUJpyDwTcLoDjBgwLEX X-Received: by 2002:a17:90b:1648:b0:1bd:28ac:859d with SMTP id il8-20020a17090b164800b001bd28ac859dmr1814698pjb.59.1646256657392; Wed, 02 Mar 2022 13:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646256657; cv=none; d=google.com; s=arc-20160816; b=x8v+FyMRvGeujzAYVQa8MG/8a6gAVJUqjiBE6OUwelZ57yVq3RZR6NUFR7K+jfxfIj GhbRQe06LJr4SpN7+i76RVLq+4YGnyvy5VW5b8lYNZfBNzTLFVDDphvCH/qij0Ombk/A XJHHleLzaWGwMOBobyO0/sUEU637gi1T5t0cxMV4kqfGRFMOhVZQ+gt6IWg6RlmOQils gu3zRYgnhSf0yJf0ykbp5yzIdit+MF2gghnpxE6XKzoG1pW2L3G1z3sa3fHofbak41nQ iyyuqpLPxqNtl1lYW35NrhMjUEmO5Rd9oo1LBikuThWtM4aMTaAyIXbA0NN8LjbdOSZ3 2sng== 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=2/7TR1czOlrni5ve6cjMiYf0huddF9ZUrXfqRqxvxSU=; b=Sr76URp8W1Fy8vWOsVqBU/q1R4syLZ7W7QoLkbfswQRubiSJcXp37cbFt8oZzzETmh 1NTin44TeGXzoW6W/t94U4rReAAwzJoOE2Bn5EaCKXQ09A6nV/tjfnLejRrNBC2g//Wd dKzGbTLVvDqD0KCmN9zNxLJ8DUhBVMT7qOASyD6HS9XX5JqfKVlaEH9RM4xGPYcZthF6 tm7iOiCSpL/9kZe8nq+E455T8TsUMEIPUiCsiYGVzHTVr6QHYTXr2MA1nOzIn9qZ7WWi fUf1Ef1SbLXh5p9b31IAm30ExOLPNyK1Ps9/6bda7Sh6+FHtOUiWV5bMcIEB9ERIxXbe EOiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pNibpYwh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a056a00216a00b004e1baee50dasi225501pff.36.2022.03.02.13.30.39; Wed, 02 Mar 2022 13:30:57 -0800 (PST) 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=@google.com header.s=20210112 header.b=pNibpYwh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240945AbiCBTeq (ORCPT + 99 others); Wed, 2 Mar 2022 14:34:46 -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-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: X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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.