Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp622612pxb; Fri, 13 Aug 2021 02:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt21gBiGDnifU7hU0Y1778WpLiVfndLU5fy1R45IISTqCTkZ0lRc/ncbIJDZn0/P+hK9Q8 X-Received: by 2002:a05:6638:148f:: with SMTP id j15mr1434468jak.61.1628847648972; Fri, 13 Aug 2021 02:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628847648; cv=none; d=google.com; s=arc-20160816; b=yHGCNvPIWb2xZmWecZebVV8Da//Q/FBedjXh4HNGhjIEZPC64OP2WwPEcMkxDyhBMP 7zIYv83n1wqQs5hjK030igowlbjG9JOgo/et4taXIM4IkkmuewxCk0Y/ZR7n76H7FYYT mQRcotLbOOv2ejyx1tNC7RLqmbCkHdC9u/lQomqlWN+lOq34g7Jj0eCK3YfLXFR92/6m 3sHiwrkOqznHLQ2iwudbKjHCtYqsnGI9JsdXfWRSUvlNq1JjjT33vNad1DL/Havi0VZe 81X/YTRW7Ft+25fCxFpAZsEWfqOo5VPaaFKc/ReoqmaM3ZwzOIUXZeybsMt9P2rYQGko 2F7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=+56+meTQ51PDKaVBuCzizjlRCe9SqN27YTBVgW4/XKA=; b=yEP7DxkYssfgKeFdnCCOmmcfE1CqaoQsjBbEPvIxZwwUTUpsIubwh5tS4nL7tx4GEg QfcGaybsWn7teTAU8GadKCeHOLdx5Dy/szt5+R9bScM7iVYBzD88F8kVsm3eMvqblNbO NOns4Orvj5lrlQsfTRIo7UoqBFcsegTtm4W9q4ps3pXN5h2rGnL66C/QBUsovoapwdHf w204zGImq0SeJSVv/NXH96zFUh/hoJALxMg8R+zQ0r7w13HFh93WVaUZiAFnYSa0VS48 pxezjg+Z+8Q3qJSKssa+IZS/jA9CF7E2VlwVGVOqfC3eBE9VAu9aJlBh0LQOUH/fvOPs rSmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="DaFl2m/O"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si1017053jar.87.2021.08.13.02.40.37; Fri, 13 Aug 2021 02:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="DaFl2m/O"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S239405AbhHMH2I (ORCPT + 99 others); Fri, 13 Aug 2021 03:28:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54465 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239402AbhHMH2I (ORCPT ); Fri, 13 Aug 2021 03:28:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628839661; 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=+56+meTQ51PDKaVBuCzizjlRCe9SqN27YTBVgW4/XKA=; b=DaFl2m/Occ/jaUxwdY4WRGHgSNCoga2vwm0ze+HF3PVgblI0LZL1reD3mJMFMuqLcmSJTs gK+TQwGZB06DZQIhLSMHQRnmUb4BuiBeHcRLPWT3LgCp6XuQwA4DjsfjTWCXAMY20tOju/ ht00pa43bKBG70QGlqnEOMls4vg3pmc= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-5EEhx_9OPzCvrFdMnsUoGw-1; Fri, 13 Aug 2021 03:27:39 -0400 X-MC-Unique: 5EEhx_9OPzCvrFdMnsUoGw-1 Received: by mail-ed1-f72.google.com with SMTP id e18-20020a0564020892b02903be9702d63eso3228023edy.17 for ; Fri, 13 Aug 2021 00:27:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+56+meTQ51PDKaVBuCzizjlRCe9SqN27YTBVgW4/XKA=; b=mDd/UaMNbQfNInkOF9R8eriDCm0YVnvpg38XvhEcAXfztxyrMo5f9LNoluXBPThYE3 lF6KO21ZrIYHcGcchk3qWxyFgpB330RgkWYldcuWm9woUhGC25QBCFL9J+5EPB5w04jr /dEqnXCfLIKvqcFIxBudsyFRuZK8jFuh2f/fUCZf1crpmQ1X/mHIqXS860GFqASTjkwV kSNma4tj4fafjt/9IHPYUQ6YoNUqQH576hHXNlIELG1X3+3ZxU3qU7Dsh6sKfvYvOOBI NFw79CXLtHppUU6YTyV80GplpPiEqz5JT5DVXgHQZAVsUYIi4BvXBG4m/I2BBwJajEzl isZw== X-Gm-Message-State: AOAM532DYtaCMDR1mgMH3Rmz8oR13VgnrU1NWhGtJagIm5c5d2U8/0Vt cOkQmd0BUC99m05B2fOIFiz3AK1xS9gLwCovO62OBqvDjXuqSCVmtihZ6beOwsHkFTPPIiHXU6r eyup+isVW9p07WIyqeOSNyRvUMgR8dUhlJ3bK85Ji3dTgLvVfwJOnvwGQk0gxkf8Q30Op5kIa7g GA X-Received: by 2002:a17:906:2844:: with SMTP id s4mr1112734ejc.263.1628839657754; Fri, 13 Aug 2021 00:27:37 -0700 (PDT) X-Received: by 2002:a17:906:2844:: with SMTP id s4mr1112717ejc.263.1628839657499; Fri, 13 Aug 2021 00:27:37 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id ay20sm428084edb.91.2021.08.13.00.27.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Aug 2021 00:27:36 -0700 (PDT) Subject: Re: [PATCH 2/2] KVM: x86/mmu: Don't step down in the TDP iterator when zapping all SPTEs To: Sean Christopherson Cc: Ben Gardon , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm , LKML References: <20210812050717.3176478-1-seanjc@google.com> <20210812050717.3176478-3-seanjc@google.com> <928be04d-e60e-924c-1f3a-cb5fef8b0042@redhat.com> <7a95b2f6-a7ad-5101-baa5-6a19194695a3@redhat.com> From: Paolo Bonzini Message-ID: Date: Fri, 13 Aug 2021 09:27:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/08/21 19:46, Sean Christopherson wrote: >>> if (iter->level == iter->min_level) >>> return false; >>> >>> /* >>> * Reread the SPTE before stepping down to avoid traversing into page >>> * tables that are no longer linked from this entry. >>> */ >>> iter->old_spte = READ_ONCE(*rcu_dereference(iter->sptep)); \ >>> ---> this is the code that is avoided >>> child_pt = spte_to_child_pt(iter->old_spte, iter->level); / >>> if (!child_pt) >>> return false; >> Ah, right - so I agree with Ben that it's not too important. > Ya. There is a measurable performance improvement, but it's really only > meaningful when there aren't many SPTEs to zap, otherwise the cost of zapping > completely dominates the time. I don't understand. When try_step_down is called by tdp_iter_next, all it does is really just the READ_ONCE, because spte_to_child_pt will see a non-present PTE and return immediately. Why do two, presumably cache hot, reads cause a measurable performance improvement? Paolo