From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Kechen Lu <kechenl@nvidia.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: "suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
Somdutta Roy <somduttar@nvidia.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"qemu-discuss@nongnu.org" <qemu-discuss@nongnu.org>
Subject: RE: Optimized clocksource with AMD AVIC enabled for Windows guest
Date: Thu, 04 Feb 2021 13:24:28 +0100 [thread overview]
Message-ID: <87zh0knhqb.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <DM6PR12MB35006123BF3E9D8B67042CC9CAB39@DM6PR12MB3500.namprd12.prod.outlook.com>
Kechen Lu <kechenl@nvidia.com> writes:
> Hi Vitaly and Paolo,
>
> Thanks so much for quick reply. This makes sense to me. From my understanding, basically this can be two part of it to resolve it.
>
> First, we make sure to set and expose 0x40000004.EAX Bit9 to windows guest, like in kvm_vcpu_ioctl_get_hv_cpuid(), having this recommendation bit :
> -----------------------
> case HYPERV_CPUID_ENLIGHTMENT_INFO:
> ...
> + ent->eax |= HV_DEPRECATING_AEOI_RECOMMENDED;
> -----------------------
This also needs to be wired through userspace (e.g. QEMU) as this
doesn't go to the guest directly.
>
> Second, although the above could tell guest to deprecate AutoEOI, older Windows OSes would not acknowledge this (I checked the Hyper-v TLFS, from spec v3.0 (i.e. Windows Server 2012), it starts having bit9 defined in 0x40000004.EAX), we may want to dynamically toggle off APICv/AVIC if we found the SynIC SINT vector has AutoEOI, under synic_update_vector(). E.g. like:
> -----------------------------
> if (synic_has_vector_auto_eoi(synic, vector)) {
> kvm_request_apicv_update(vcpu->kvm, false, APICV_INHIBIT_REASON_HYPERV);
> __set_bit(vector, synic->auto_eoi_bitmap);
> } else {
> kvm_request_apicv_update(vcpu->kvm, true, APICV_INHIBIT_REASON_HYPERV);
> __clear_bit(vector, synic->auto_eoi_bitmap);
> }
> ---------------------------------
APICV_INHIBIT_REASON_HYPERV is per-VM so we need to count how many
AutoEOI SINTs were set in *all* SynICs (an atomic in 'struct kvm_hv'
would do).
> Curious about what current plan/status of upstream is for this. If
> that's doable and not current pending patch covering this, I can make
> a quick draft patch tested and sent out for reviewing.
I checked Linux VMs on genuine Hyper-V and surprisingly
'HV_DEPRECATING_AEOI_RECOMMENDED' is not exposed. I'm going to pass it
to WS2016/2019 and see what happens. If it all works as expected and if
you don't beat me to it I'll be sending a patch.
--
Vitaly
next prev parent reply other threads:[~2021-02-04 12:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 6:40 Optimized clocksource with AMD AVIC enabled for Windows guest Kechen Lu
2021-02-03 7:58 ` Paolo Bonzini
2021-02-03 9:15 ` Vitaly Kuznetsov
2021-02-04 2:05 ` Kechen Lu
2021-02-04 12:24 ` Vitaly Kuznetsov [this message]
2021-02-04 13:35 ` Paolo Bonzini
2021-02-04 15:01 ` Vitaly Kuznetsov
2021-02-04 15:19 ` Vitaly Kuznetsov
2021-02-05 5:38 ` Kechen Lu
2021-02-17 20:41 ` Kechen Lu
2021-02-25 10:25 ` Vitaly Kuznetsov
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=87zh0knhqb.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=kechenl@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-discuss@nongnu.org \
--cc=somduttar@nvidia.com \
--cc=suravee.suthikulpanit@amd.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