From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Naveen N Rao <naveen@kernel.org>
Cc: Maxim Levitsky <mlevitsk@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [PATCH 2/3] KVM: x86: Remove use of apicv_update_lock when toggling guest debug state
Date: Tue, 4 Feb 2025 18:58:38 +0100 [thread overview]
Message-ID: <2d86cce9-88c2-4b2f-a8a6-ee33d0e1c98d@redhat.com> (raw)
In-Reply-To: <Z6JTmvrkrLpaJ1nw@google.com>
On 2/4/25 18:51, Sean Christopherson wrote:
> On Tue, Feb 04, 2025, Naveen N Rao wrote:
>> On Mon, Feb 03, 2025 at 09:00:05PM -0500, Maxim Levitsky wrote:
>>> On Mon, 2025-02-03 at 22:33 +0530, Naveen N Rao (AMD) wrote:
>>>> apicv_update_lock is not required when querying the state of guest
>>>> debug in all the vcpus. Remove usage of the same, and switch to
>>>> kvm_set_or_clear_apicv_inhibit() helper to simplify the code.
>>>
>>> It might be worth to mention that the reason why the lock is not needed,
>>> is because kvm_vcpu_ioctl from which this function is called takes 'vcpu->mutex'
>>> and thus concurrent execution of this function is not really possible.
>>
>> Looking at this again, that looks to be a vcpu-specific lock, so I guess
>> it is possible for multiple vcpus to run this concurrently?
>
> Correct.
And this patch is incorrect. Because there is a store and many loads,
you have the typical race when two vCPUs set blockirq at the same time
vcpu 0 vcpu 1
--------------- --------------
set vcpu0->guest_debug
clear vcpu1->guest_debug
read vcpu0->guest_debug
read vcpu1->guest_debug
set inhibit
read stale vcpu0->guest_debug
read vcpu1->guest_debug
clear inhibit
But since this is really a slow path, why even bother optimizing it?
Paolo
next prev parent reply other threads:[~2025-02-04 17:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 17:03 [PATCH 0/3] KVM: x86: Address performance degradation due to APICv inhibits Naveen N Rao (AMD)
2025-02-03 17:03 ` [PATCH 1/3] KVM: x86: hyper-v: Convert synic_auto_eoi_used to an atomic Naveen N Rao (AMD)
2025-02-04 1:30 ` Maxim Levitsky
2025-02-04 13:09 ` Naveen N Rao
2025-02-04 19:33 ` Sean Christopherson
2025-02-05 11:00 ` Naveen N Rao
2025-02-03 17:03 ` [PATCH 2/3] KVM: x86: Remove use of apicv_update_lock when toggling guest debug state Naveen N Rao (AMD)
2025-02-04 2:00 ` Maxim Levitsky
2025-02-04 13:10 ` Naveen N Rao
2025-02-04 14:25 ` Naveen N Rao
2025-02-04 17:51 ` Sean Christopherson
2025-02-04 17:58 ` Paolo Bonzini [this message]
2025-02-04 19:42 ` Maxim Levitsky
2025-02-05 11:13 ` Naveen N Rao
2025-02-03 17:03 ` [PATCH 3/3] KVM: x86: Decouple APICv activation state from apicv_inhibit_reasons Naveen N Rao (AMD)
2025-02-03 18:45 ` Sean Christopherson
2025-02-03 22:22 ` Paolo Bonzini
2025-02-03 23:46 ` Sean Christopherson
2025-02-04 1:23 ` Maxim Levitsky
2025-02-04 19:18 ` Sean Christopherson
2025-02-04 20:08 ` Maxim Levitsky
2025-02-05 1:41 ` Sean Christopherson
2025-02-05 10:54 ` Naveen N Rao
2025-02-05 11:36 ` Paolo Bonzini
2025-02-11 15:57 ` Naveen N Rao
2025-02-11 16:37 ` Sean Christopherson
2025-02-11 18:13 ` Naveen N Rao
2025-02-04 11:06 ` Naveen N Rao
2025-02-04 14:08 ` Paolo Bonzini
2025-02-11 14:37 ` Naveen N Rao
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=2d86cce9-88c2-4b2f-a8a6-ee33d0e1c98d@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=naveen@kernel.org \
--cc=seanjc@google.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=vkuznets@redhat.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
all inboxes | Powered by JetHome®