Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp619921pxu; Wed, 7 Oct 2020 11:16:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyke/nTUlYlMt3FBRCkwE3stU7xCL4gxzqmULj/w8TIk8KAYmUIUyPvRQq0ZV7Hwsher/0A X-Received: by 2002:a05:6402:c84:: with SMTP id cm4mr4920395edb.270.1602094619347; Wed, 07 Oct 2020 11:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602094619; cv=none; d=google.com; s=arc-20160816; b=i/Ufl3wDu61eLTMrdcctWnWInFGK/08eGLcAPhSOldbiMQeFDNakqwXe1Qnk3wK5iA m6vq/ULaEa4125l2SvvRtMh3qFqBrvP7PFmPvDLkyJRDofXuItZ2D7r/4d4saV9DyW4m Xgn2l6h2v641hwd4fBgSx8vUc2G60cpFzixOLLZYfL6Wv4Qb4HzUYe+oL9orRXdQkuNk /j8duDTUJUzgwrK5choPrvniHEMEsdcu79yPEGFJOZWGEmXjtJHGBiDMLmRaKVo6eOfl 9hmdXq6wFcpYdasgW8iqhsdEpMLSErQzD8t12u6F9DnZo/4DcEEz4UoSFBgykKiyyPeO IFSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Gzog+3s7evIu2Oc1rtwTUl+9x6mD7V8+jB/FerDJf6g=; b=GXlRIn855WasshYmzBnWShXEHt47WIDKBhsElsaA/JZJy2QFT68nSIpj6mD/D1/nT+ TeiPHimv4i0LYwNtvvZIIbkJI9plVCIwyQISMlQNEwAxy5MN4rZdqE96+982gmJLmzlx dfEyDGaCn6CABSCJB7oAaSrJUL2S6RJ4ygpW+RzE6MMH76nO6ptrmmRmsIDBqOV39hfe hkKEY3klZNyMB98tgiq4zhQF5UDW1+A4zsM+Vib36TvQErAC9pTcMVJlrbebGx9Hcgef alqg8E4RVxwvXxhA50EPlG+Ld4JGMHuzU7IsdkJlwkDm/xA8tsqtbNW0OymJEL+R+lFq 0rKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="nX/4Q/YG"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f27si2438834ejf.129.2020.10.07.11.16.36; Wed, 07 Oct 2020 11:16:59 -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=@google.com header.s=20161025 header.b="nX/4Q/YG"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726434AbgJGR2l (ORCPT + 99 others); Wed, 7 Oct 2020 13:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbgJGR2l (ORCPT ); Wed, 7 Oct 2020 13:28:41 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33B61C0613D2 for ; Wed, 7 Oct 2020 10:28:41 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id u6so3191115iow.9 for ; Wed, 07 Oct 2020 10:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gzog+3s7evIu2Oc1rtwTUl+9x6mD7V8+jB/FerDJf6g=; b=nX/4Q/YGjmebBLp4gLg8J2yprcJQilHAS6qA1FHs5eLbDhe6iwzEYvpmsJs/PP94Kp GCzwHPrwqADg8+WqzbUbeFeB4eX4KHZvo0buxluUokPbtybLhx8dhFMWlcQAd4CKe10t 26nG5444aSaobp5nO22ausRmcHQy//aglJ0fRKo9ARJvEW1Yrw8Ky7WccdZpsJuYm3e/ xQS3dc0ny8dD/YDLaIBmKmsuC02TSE/s94jTazNbKJ4VAxjuvrFEJSzCQ/Eg9TGtG3ES 0m7EI+PaTupmbB5L+0UtEw9R9srPbyfyOmGMXNBfZhOTPadOU/ZYwAIGwrkLzEgvL1mu hmWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gzog+3s7evIu2Oc1rtwTUl+9x6mD7V8+jB/FerDJf6g=; b=t9jdUsffsm/5WO/sEk77k69KUNKe2K2iLminz84a2xb78t8HuRydICtrsO2Ok316QG EyhWe1q6amK60nKM8LGVeoh4EnljN9CKk6Li43EGV3/esI27jteiwVYj/f1FNHE7i1W5 Bi+CxZYHe12xo0O8rN7vOr66zuA3CPHabzH+bTI5lT6k81OhB1isud2TUZQuolRHRobY VwcioN9YxGlSi8ZYWxOclkH5g3iXtu8d1xWvucuBzOnLYcSjZtZvuHbl0kef/NPh7v2G sLL1TRuv9iwZFZI8QAKPc4WQx2idhUcuXqjvLXgGINJEGT1Uh5kRlxe6jJrtBIQq1nju /OAw== X-Gm-Message-State: AOAM533SMILGQ61mIZrD+H6BbPOThmXlOiUbZ7QnacWp7cm0ALSVLrKT GvNwTNnd3cYLhfliJ16f/asmefXgZrOSKATxJZkPZQ== X-Received: by 2002:a02:2ac1:: with SMTP id w184mr3827019jaw.44.1602091720153; Wed, 07 Oct 2020 10:28:40 -0700 (PDT) MIME-Version: 1.0 References: <20200925212302.3979661-1-bgardon@google.com> <20200925212302.3979661-19-bgardon@google.com> <44822999-f5dc-6116-db12-a41f5bd80dd8@redhat.com> <5dc72eec-a4bd-f31a-f439-cdf8c5b48c05@redhat.com> In-Reply-To: <5dc72eec-a4bd-f31a-f439-cdf8c5b48c05@redhat.com> From: Ben Gardon Date: Wed, 7 Oct 2020 10:28:29 -0700 Message-ID: Subject: Re: [PATCH 18/22] kvm: mmu: Support disabling dirty logging for the tdp MMU To: Paolo Bonzini Cc: LKML , kvm , Cannon Matthews , Peter Xu , Sean Christopherson , Peter Shier , Peter Feiner , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 7, 2020 at 10:21 AM Paolo Bonzini wrote: > > On 07/10/20 18:30, Ben Gardon wrote: > >> I'm starting to wonder if another iterator like > >> for_each_tdp_leaf_pte_root would be clearer, since this idiom repeats > >> itself quite often. The tdp_iter_next_leaf function would be easily > >> implemented as > >> > >> while (likely(iter->valid) && > >> (!is_shadow_present_pte(iter.old_spte) || > >> is_last_spte(iter.old_spte, iter.level)) > >> tdp_iter_next(iter); > > Do you see a substantial efficiency difference between adding a > > tdp_iter_next_leaf and building on for_each_tdp_pte_using_root with > > something like: > > > > #define for_each_tdp_leaf_pte_using_root(_iter, _root, _start, _end) \ > > for_each_tdp_pte_using_root(_iter, _root, _start, _end) \ > > if (!is_shadow_present_pte(_iter.old_spte) || \ > > !is_last_spte(_iter.old_spte, _iter.level)) \ > > continue; \ > > else > > > > I agree that putting those checks in a wrapper makes the code more concise. > > > > No, that would be just another way to write the same thing. That said, > making the iteration API more complicated also has disadvantages because > if get a Cartesian explosion of changes. I wouldn't be too worried about that. The only things I ever found worth making an iterator case for were: Every SPTE Every present SPTE Every present leaf SPTE And really there aren't many cases that use the middle one. > > Regarding the naming, I'm leaning towards > > tdp_root_for_each_pte > tdp_vcpu_for_each_pte > > which is shorter than the version with "using" and still clarifies that > "root" and "vcpu" are the thing that the iteration works on. That sounds good to me. I agree it's similarly clear. > > Paolo >