Re: [PATCH] kvm: Fix perf timer mode IP reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2017-07-26 16:25+0200, Paolo Bonzini:
> On 26/07/2017 16:07, Andi Kleen wrote:
> > On Wed, Jul 26, 2017 at 11:26:07AM +0200, Paolo Bonzini wrote:
> >> On 26/07/2017 02:20, Andi Kleen wrote:
> >>> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> >>>
> >>> KVM and perf have a special backdoor mechanism to report the IP for interrupts
> >>> re-executed after vm exit. This works for the NMIs that perf normally uses.
> >>>
> >>> However when perf is in timer mode it doesn't work because the timer interrupt
> >>> doesn't get this special treatment. This is common when KVM is running
> >>> nested in another hypervisor which may not implement the PMU, so only
> >>> timer mode is available.
> >>>
> >>> Call the functions to set up the backdoor IP also for non NMI interrupts.
> >>>
> >>> I renamed the functions to set up the backdoor IP reporting to be more
> >>> appropiate for their new use.  The SVM change is only compile tested.
> >>>
> >>> v2: Moved the functions inline.
> >>> For the normal interrupt case the before/after functions are now
> >>> called from x86.c, not arch specific code.
> >>
> >> You haven't removed the code from vmx_handle_external_intr and 
> >> svm_handle_external_intr.
> > 
> > Ok.
> > 
> >>
> >>> For the NMI case we still need to call it in the architecture
> >>> specific code, because it's already needed in the low level *_run
> >>> functions.
> >>
> >> I must have been unclear; what I was asking is, can the calls cover
> >> a much wider range of vcpu_enter_guest?
> > 
> > Handling the external interrupt case from x86 without exporting
> > is no problem (like my patch did)
> > 
> > But to handle the NMI case it needs to be exported because
> > the NMI case is directly handled in the lowlevel vcpu_runs*.
> > 
> > And I'm not sure it's safe to set over the actual low level
> > guest runs. e.g. the AMD code already seems to change interrupts
> > there.
> 
> AMD only enables interrupts while GIF is 0, so it would be safe.  (The
> processor switches GIF atomically to 1 with VMRUN and to 0 with #VMEXIT,
> so "clgi;sti" means "enable interrupts while the guest runs" and is
> paired with "cli;stgi" after VMRUN returns).
> 
> The main difference would be for an NMI happening before the
> VMRUN/VMRESUME instruction; it would be accounted to the guest rather
> than the host.
> 
> I guess it would be better done as a separate change anyway.  I'll
> commit your v2 with fixed vmx.c and svm.c.

I just removed the extra code from arch handle_external_intr and queued,
thanks.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux