From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Pattara Teerapong <pteerapong@google.com>,
David Stevens <stevensd@google.com>,
Yiwei Zhang <zzyiwei@google.com>, Paul Hsia <paulhsia@google.com>
Subject: Re: [PATCH 2/3] KVM: x86/mmu: Take "shared" instead of "as_id" TDP MMU's yield-safe iterator
Date: Thu, 21 Sep 2023 14:32:41 +0000 [thread overview]
Message-ID: <ZQxUCc3BEHA91FgY@google.com> (raw)
In-Reply-To: <adebc422-2937-48d7-20c1-aef2dc1ac436@redhat.com>
On Thu, Sep 21, 2023, Paolo Bonzini wrote:
> On 9/16/23 02:39, Sean Christopherson wrote:
> > Replace the address space ID in for_each_tdp_mmu_root_yield_safe() with a
> > shared (vs. exclusive) param, and have the walker iterate over all address
> > spaces as all callers want to process all address spaces. Drop the @as_id
> > param as well as the manual address space iteration in callers.
> >
> > Add the @shared param even though the two current callers pass "false"
> > unconditionally, as the main reason for refactoring the walker is to
> > simplify using it to zap invalid TDP MMU roots, which is done with
> > mmu_lock held for read.
> >
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Sean Christopherson <seanjc@google.com>
>
> You konw what, I don't really like the "bool shared" arguments anymore.
Yeah, I don't like the "shared" arguments either. Never did, but they are necessary
for some paths, and I don't see an obviously better solution. :-/
> For example, neither tdp_mmu_next_root nor kvm_tdp_mmu_put_root need to know
> if the lock is taken for read or write; protection is achieved via RCU and
> tdp_mmu_pages_lock. It's more self-documenting to remove the argument and
> assert that the lock is taken.
>
> Likewise, the argument is more or less unnecessary in the
> for_each_*_tdp_mmu_root_yield_safe() macros. Many users check for the lock
> before calling it; and all of them either call small functions that do the
> check, or end up calling tdp_mmu_set_spte_atomic() and
> tdp_mmu_iter_set_spte(), so the per-iteration checks are also overkill.
Agreed.
> It may be useful to a few assertions to make up for the lost check before
> the first execution of the body of for_each_*_tdp_mmu_root_yield_safe(), but
> even this is more for documentation reasons than to catch actual bugs.
I think it's more than sufficient, arguably even better, to document which paths
*require* mmu_lock be held for read vs. write, and which paths work with either.
> I'll send a v2.
Can we do a cleanup of the @shared arguments on top? I would like to keep the
diff reasonably small to minimize the v6.1 backport.
next prev parent reply other threads:[~2023-09-21 20:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-16 0:39 [PATCH 0/3] KVM: x86/mmu: Drop async zapping of TDP MMU roots Sean Christopherson
2023-09-16 0:39 ` [PATCH 1/3] KVM: x86/mmu: Open code walking TDP MMU roots for mmu_notifier's zap SPTEs Sean Christopherson
2023-09-21 10:05 ` Paolo Bonzini
2023-09-16 0:39 ` [PATCH 2/3] KVM: x86/mmu: Take "shared" instead of "as_id" TDP MMU's yield-safe iterator Sean Christopherson
2023-09-21 10:52 ` Paolo Bonzini
2023-09-21 14:32 ` Sean Christopherson [this message]
2023-09-16 0:39 ` [PATCH 3/3] KVM: x86/mmu: Stop zapping invalidated TDP MMU roots asynchronously Sean Christopherson
2023-09-21 10:02 ` Paolo Bonzini
2023-09-22 20:40 ` [PATCH 0/3] KVM: x86/mmu: Drop async zapping of TDP MMU roots Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQxUCc3BEHA91FgY@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulhsia@google.com \
--cc=pbonzini@redhat.com \
--cc=pteerapong@google.com \
--cc=stevensd@google.com \
--cc=zzyiwei@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox