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 F1611C433EF for ; Thu, 26 May 2022 15:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347781AbiEZPwx (ORCPT ); Thu, 26 May 2022 11:52:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239905AbiEZPww (ORCPT ); Thu, 26 May 2022 11:52:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9970232075 for ; Thu, 26 May 2022 08:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653580369; 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=rSb/31fWao51fuvQhRU5QL5Gj3VrxjiuEBRl0z2YmX0=; b=eIlusbQIg1HGC9D9g6VZseoQcITCYvlXtpYnRGKjJNR5hGum10QkdT0s5A+0xd0cjdqvqu uaNC5x/d9pgPDGuKpRNOLJWz2pzzK5qxEGOaawmtixLVCgIb7y63sIdh//8rAUPOAs7YDD Ptvg7PO7x6Csu9YE54X2deGej18SGzI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-ahkW7HgKOnm9MQGoWtDGHA-1; Thu, 26 May 2022 11:52:48 -0400 X-MC-Unique: ahkW7HgKOnm9MQGoWtDGHA-1 Received: by mail-ed1-f72.google.com with SMTP id e3-20020a056402330300b0042b903637bbso1327931eda.3 for ; Thu, 26 May 2022 08:52:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=rSb/31fWao51fuvQhRU5QL5Gj3VrxjiuEBRl0z2YmX0=; b=S6S0nA/34ZqCy8CwaiB0Er//qHtBUU4HtbXHtwmJqENqow5DPWYsuRc5XZQI9LNGKy 0beKFk17+4L5NP0fZRxII82Ekel8MKXC6ykYQB4F8TFqNk2YayLyW3lo04Yb9I9CMOso CAKUQjw7slhiS+bibIYw15wQmWcd5fBe5WmPlC2t7Z0eCTDL8Zg8xaUDRj3evSK1Yc7Y R4/Z6heMSTOlyAg1CFY38r93noT0xUvV1h9t1pOH62S+9BW/PTk0k6BPEGhlCmcsrsSa nsmQzg9MkkZa7fvLB9kaXr5HnInYpG74hKLqUdhjbMmBKp1pGdfI1mJdGI0hACXmLDSt fmeg== X-Gm-Message-State: AOAM530C3bMVSjs2JpmWUNA4qEcwF32PKbue3GA9GKyNnoBjknQ8sNBn WeCfs7nidLwLDqyM1kDPqflSifUEOj5Hrzxhtyz21HZ7RCaMDwXW4ISiZrg3MFObeXLHihK8XBE EBOVycxDcBjae5eWmEeup/gKf X-Received: by 2002:a17:907:7b8f:b0:6fe:fcae:615a with SMTP id ne15-20020a1709077b8f00b006fefcae615amr15729289ejc.658.1653580367257; Thu, 26 May 2022 08:52:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYhN/upHIsj/j2UEamiuyv1JioyxHM/yRSgGRL8HEX8U32cH0n4xTzIeNkrc6lCiN/uK/20w== X-Received: by 2002:a17:907:7b8f:b0:6fe:fcae:615a with SMTP id ne15-20020a1709077b8f00b006fefcae615amr15729271ejc.658.1653580367005; Thu, 26 May 2022 08:52:47 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id w15-20020a17090652cf00b006fed8dfcf78sm619667ejn.225.2022.05.26.08.52.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 May 2022 08:52:46 -0700 (PDT) Message-ID: Date: Thu, 26 May 2022 17:52:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] KVM: x86/MMU: Zap non-leaf SPTEs when disabling dirty logging Content-Language: en-US To: Peter Xu Cc: Ben Gardon , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , David Matlack , Jim Mattson , David Dunn , Jing Zhang , Junaid Shahid References: <20220525230904.1584480-1-bgardon@google.com> From: Paolo Bonzini In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/26/22 16:30, Peter Xu wrote: > On Thu, May 26, 2022 at 02:01:43PM +0200, Paolo Bonzini wrote: >> On 5/26/22 01:09, Ben Gardon wrote: >>> + WARN_ON(max_mapping_level < iter.level); >>> + >>> + /* >>> + * If this page is already mapped at the highest >>> + * viable level, there's nothing more to do. >>> + */ >>> + if (max_mapping_level == iter.level) >>> + continue; >>> + >>> + /* >>> + * The page can be remapped at a higher level, so step >>> + * up to zap the parent SPTE. >>> + */ >>> + while (max_mapping_level > iter.level) >>> + tdp_iter_step_up(&iter); >>> + >>> /* Note, a successful atomic zap also does a remote TLB flush. */ >>> - if (tdp_mmu_zap_spte_atomic(kvm, &iter)) >>> - goto retry; >>> + tdp_mmu_zap_spte_atomic(kvm, &iter); >>> + >> >> Can you make this a sparate function (for example >> tdp_mmu_zap_collapsible_spte_atomic)? Otherwise looks great! > > There could be a tiny downside of using a helper in that it'll hide the > step-up of the iterator, which might not be as obvious as keeping it in the > loop? That's true, my reasoning is that zapping at a higher level can only be done by first moving the iterator up. Maybe tdp_mmu_zap_at_level_atomic() is a better Though, I can very well apply this patch as is. Paolo