From: Paolo Bonzini <pbonzini@redhat.com>
To: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Claudio Fontana <cfontana@suse.de>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
Cameron Esfahani <dirty@apple.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 4/8] i386: hvf: Implement CPU kick
Date: Tue, 30 Jun 2020 12:43:49 +0200 [thread overview]
Message-ID: <0549a18b-aedf-d88f-1765-65e333ee2e00@redhat.com> (raw)
In-Reply-To: <20200630101228.GA39334@SPB-NB-133.local>
Ok, I'll review the patch to see what you've implemented. Thanks!
Paolo
On 30/06/20 12:12, Roman Bolshakov wrote:
> On Mon, Jun 29, 2020 at 04:18:46PM +0200, Paolo Bonzini wrote:
>> On 29/06/20 16:04, Roman Bolshakov wrote:
>>> My approach is based
>>> hv_vcpu_run() and should hopefully work almost anywhere where
>>> Hypervisor.framework is available because Hypervisor framework exposes
>>> timer value
>>> (https://developer.apple.com/documentation/hypervisor/vmcs_guest_vmx_timer_value)
>>> since macOS 10.10.3+.
>>
>> There are a few other constants for which it would be unwise to write
>> from userspace, so that's not a big consolation. :)
>>
>
> Hi Paolo,
>
> So, I've tried Big Sur Beta and it has exactly the same performance
> issue with hv_vcpu_run_until() while hv_vcpu_run() works as good as it
> worked on 10.15.5. I've submitted FB7827341 to Apple wrt the issue.
>
>>> I can also test how hv_vcpu_run_until() performs with HV_DEADLINE_FOREVER
>>> on the Beta. And if the performance issues with VMX-preemption timer and
>>> hv_vcpu_run_until() are fixed there.
>>
>> Thanks! The main thing to test on Big Sur would be: 1) whether the
>> preemption timer bit in the pin controls "sticks" to 0 after setting it
>
> It does not. If it's set, it stays there.
>
>> 2) whether the bit reads back as zero after
>> hv_vcpu_run_until(HV_DEADLINE_FOREVER).
>>
>
> Likewise, it's not cleared if set.
>
> As far as I understand, hv_vcpu_run_until(HV_DEADLINE_FOREVER) works
> like hv_vcpu_run() without VMX-preemption timer. Otherwise
> hv_vcpu_run_until() implicitly sets VMX-preemption timer Pin-based
> control and sets the timer value.
>
> Thanks,
> Roman
>
> Here's the patch over v2 that adds support of hv_vcpu_run_until() on Big Sur:
> diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
> index 317304aa1d..ad202f7358 100644
> --- a/target/i386/hvf/hvf.c
> +++ b/target/i386/hvf/hvf.c
> @@ -72,8 +72,12 @@
> #include "sysemu/accel.h"
> #include "target/i386/cpu.h"
>
> +#if defined(__MAC_10_16) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_16
> +#define HVF_MAX_DEADLINE HV_DEADLINE_FOREVER
> +#else
> /* Maximum value of VMX-preemption timer */
> #define HVF_MAX_DEADLINE UINT32_MAX
> +#endif
>
> HVFState *hvf_state;
>
> @@ -693,6 +697,7 @@ int hvf_vcpu_exec(CPUState *cpu)
> CPUX86State *env = &x86_cpu->env;
> int ret = 0;
> uint64_t rip = 0;
> + hv_return_t r;
>
> if (hvf_process_events(cpu)) {
> return EXCP_HLT;
> @@ -718,10 +723,22 @@ int hvf_vcpu_exec(CPUState *cpu)
> /* Use VMX-preemption timer trick only if available */
> if (rvmcs(cpu->hvf_fd, VMCS_PIN_BASED_CTLS) &
> VMCS_PIN_BASED_CTLS_VMX_PREEMPT_TIMER) {
> +#if defined(__MAC_10_16) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_16
> + r = hv_vcpu_run_until(cpu->hvf_fd,
> + atomic_read(&env->hvf_deadline));
> + } else {
> + /*
> + * Equivalent to behaviour of hv_vcpu_run() with VMX-preemption
> + * timer disabled, prone to kick loss.
> + */
> + r = hv_vcpu_run_until(cpu->hvf_fd, HVF_MAX_DEADLINE);
> + }
> +#else
> wvmcs(cpu->hvf_fd, VMCS_PREEMPTION_TIMER_VALUE,
> atomic_read(&env->hvf_deadline));
> }
> - hv_return_t r = hv_vcpu_run(cpu->hvf_fd);
> + r = hv_vcpu_run(cpu->hvf_fd);
> +#endif
> atomic_set(&env->hvf_deadline, HVF_MAX_DEADLINE);
> assert_hvf_ok(r);
>
>
next prev parent reply other threads:[~2020-06-30 10:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 22:58 [PATCH 0/8] Improve synchronization between QEMU and HVF Roman Bolshakov
2020-06-24 22:58 ` [PATCH 1/8] i386: hvf: Set env->eip in macvm_set_rip() Roman Bolshakov
2020-06-24 22:58 ` [PATCH 2/8] i386: hvf: Move synchronize functions to sysemu Roman Bolshakov
2020-06-25 7:09 ` Claudio Fontana
2020-06-24 22:58 ` [PATCH 3/8] i386: hvf: Add hvf_cpu_synchronize_pre_loadvm() Roman Bolshakov
2020-06-24 22:58 ` [PATCH 4/8] i386: hvf: Implement CPU kick Roman Bolshakov
2020-06-25 7:07 ` Claudio Fontana
2020-06-25 10:51 ` Roman Bolshakov
2020-06-25 10:28 ` Paolo Bonzini
2020-06-25 15:57 ` Roman Bolshakov
2020-06-25 18:34 ` Paolo Bonzini
2020-06-29 11:31 ` Roman Bolshakov
2020-06-29 13:03 ` Paolo Bonzini
2020-06-29 13:29 ` Roman Bolshakov
2020-06-29 13:35 ` Paolo Bonzini
2020-06-29 14:04 ` Roman Bolshakov
2020-06-29 14:18 ` Paolo Bonzini
2020-06-30 10:12 ` Roman Bolshakov
2020-06-30 10:43 ` Paolo Bonzini [this message]
2020-06-24 22:58 ` [PATCH 5/8] i386: hvf: Don't duplicate register reset Roman Bolshakov
2020-06-24 22:58 ` [PATCH 6/8] i386: hvf: Drop hvf_reset_vcpu() Roman Bolshakov
2020-06-25 10:31 ` Paolo Bonzini
2020-06-25 12:36 ` Roman Bolshakov
2020-06-25 13:30 ` Paolo Bonzini
2020-06-25 15:02 ` Roman Bolshakov
2020-06-25 18:26 ` Paolo Bonzini
2020-06-29 12:58 ` Roman Bolshakov
2020-06-24 22:58 ` [PATCH 7/8] i386: hvf: Clean up synchronize functions Roman Bolshakov
2020-06-24 22:58 ` [PATCH 8/8] MAINTAINERS: Add Cameron as HVF co-maintainer Roman Bolshakov
2020-06-25 11:08 ` [PATCH 0/8] Improve synchronization between QEMU and HVF 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=0549a18b-aedf-d88f-1765-65e333ee2e00@redhat.com \
--to=pbonzini@redhat.com \
--cc=cfontana@suse.de \
--cc=dirty@apple.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
--cc=rth@twiddle.net \
/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;
as well as URLs for NNTP newsgroup(s).