All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: bugzilla-daemon@bugzilla.kernel.org, kvm@vger.kernel.org
Cc: Sean Christopherson <seanjc@google.com>
Subject: Re: [Bug 215459] VM freezes starting with kernel 5.15
Date: Thu, 06 Jan 2022 15:43:21 +0200	[thread overview]
Message-ID: <deb5cbc0a5dff445de9d3d5ae7b4d33b9f362c67.camel@redhat.com> (raw)
In-Reply-To: <bug-215459-28872-vsF1SPQyry@https.bugzilla.kernel.org/>

On Thu, 2022-01-06 at 13:12 +0000, bugzilla-daemon@bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=215459
> 
> --- Comment #2 from th3voic3@mailbox.org ---
> (In reply to mlevitsk from comment #1)
> > On Thu, 2022-01-06 at 11:03 +0000, bugzilla-daemon@bugzilla.kernel.org wrote:
> > > https://bugzilla.kernel.org/show_bug.cgi?id=215459
> > > 
> > >             Bug ID: 215459
> > >            Summary: VM freezes starting with kernel 5.15
> > >            Product: Virtualization
> > >            Version: unspecified
> > >     Kernel Version: 5.15.*
> > >           Hardware: Intel
> > >                 OS: Linux
> > >               Tree: Mainline
> > >             Status: NEW
> > >           Severity: normal
> > >           Priority: P1
> > >          Component: kvm
> > >           Assignee: virtualization_kvm@kernel-bugs.osdl.org
> > >           Reporter: th3voic3@mailbox.org
> > >         Regression: No
> > > 
> > > Created attachment 300234 [details]
> > >   --> https://bugzilla.kernel.org/attachment.cgi?id=300234&action=edit
> > > qemu.hook and libvirt xml
> > > 
> > > Hi,
> > > 
> > > starting with kernel 5.15 I'm experiencing freezes in my VFIO Windows 10
> > VM.
> > > Downgrading to 5.14.16 fixes the issue.
> > > 
> > > I can't find any error messages in dmesg when this happens and comparing
> > the
> > > dmesg output between 5.14.16 and 5.15.7 didn't show any differences.
> > > 
> > > 
> > > Additional info:
> > > * 5.15.x
> > > * I'm attaching my libvirt config and my /etc/libvirt/hooks/qemu
> > > * My specs are:
> > > ** i7-10700k
> > > ** ASUS z490-A PRIME Motherboard
> > > ** 64 GB RAM
> > > ** Passthrough Card: NVIDIA 2070 Super
> > > ** Host is using the integrated Graphics chip
> > > 
> > > Steps to reproduce:
> > > Boot any 5.15 kernel and start the VM and after some time (no specific
> > > trigger
> > > as far as I can see) the VM freezes.
> > > 
> > > After some testing the solution seems to be:
> > > 
> > > I read about this:
> > > 20210713142023.106183-9-mlevitsk@redhat.com/#24319635">
> > > 
> > > 
> > https://patchwork.kernel.org/project/kvm/patch/20210713142023.106183-9-mlevitsk@redhat.com/#24319635
> > > And so I checked
> > > cat /sys/module/kvm_intel/parameters/enable_apicv
> > > 
> > > which returns Y to me by default.
> > > 
> > > So I added
> > > options kvm_intel enable_apicv=0
> > > to /etc/modprobe.d/kvm.conf
> > > 
> > > 
> > > cat /sys/module/kvm_intel/parameters/enable_apicv
> > > now returns N
> > > 
> > > So far I haven't encountered any freezes.
> > > 
> > > The confusing part is that APICv shouldn't be available with my CPU
> > 
> > I guess you are lucky and your cpu has it? 
> > Does /sys/module/kvm_intel/parameters/enable_apicv show Y on 5.14.16 as well?
> Yep just checked again.
> 
> > I know that there were few fixes in regard to posted interrupts on intel,
> > which might explain the problem.
> I tried checking with
> for i in $(find /sys/class/iommu/dmar* -type l); do echo -n "$i: "; echo $(( (
> 0x$(cat $i/intel-iommu/cap) >> 59 ) & 1 )); done
> cat: /intel-iommu/cap: No such file or directory
> /sys/class/iommu/dmar0: 0
> /sys/class/iommu/dmar1: 0
> 
> 
> So posted interrupts don't work on my system anyways?

Yes and no.

APICv consists of 4 parts:

1. virtualization of host->guest interrupts.

That allows KVM to deliver interrupts to a vCPU without VMexit,
interrupts that can be sent from say main qemu thread or from iothread,
or from in-kernel timers, etc.
As long as the sender runs on a different core, you get VMexit less interrupt.
If enable_apicv is true, your cpu ought to have this.

2. virtualization of apic registers.
That allows to avoid VM exits on some guest apic acceses like writing EOI
register, and such. Very primitive support for this exits even without APIVc,
called FlexPriority/TPR virtualization.

3. virtualization of IPIs (inter process interrupts)
Intel currenlty only supports self-ipi, where a vCPU sends an interrupt to itself,
and it seems that finally they on track to support ful IPI virtualization.

4. Delivery of interrupts from passed-through devices to VM through virtual apic.
That feature apparently you don't have enabled. Its optional but still very nice to
have.

So you are lucky to have quite working APICv, and once it works for you
it should help with latency overall.

I think that this might be related to
"KVM: VMX: Wake vCPU when delivering posted IRQ even if vCPU == this vCPU"


There was a thread on the mailing list about exact same issue you are facing
APICv enabled but have a pass through device which doesn't use posted interrupts
Can't seem to find the thread now.

This patch actualy fixed the issue, but I haven't fully followed on what
commit introduced the issue.

I also wonder if the same issue can happen on AVIC.

Best reards,
	Maxim Levitsky


> 
> 
> > You might want to try 5.16 kernel when it released.
> I will definitely check again thanks.
> 
> Assuming I really do have APICv: is there anything I need to change in my XML
> to really make use of this feature or does it work "out of the box"?
> 



  reply	other threads:[~2022-01-06 13:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 11:03 [Bug 215459] New: VM freezes starting with kernel 5.15 bugzilla-daemon
2022-01-06 11:18 ` Maxim Levitsky
2022-01-06 11:18 ` [Bug 215459] " bugzilla-daemon
2022-01-06 13:12 ` bugzilla-daemon
2022-01-06 13:43   ` Maxim Levitsky [this message]
2022-01-06 13:43 ` bugzilla-daemon
2022-01-06 18:52 ` bugzilla-daemon
2022-01-06 20:42   ` Maxim Levitsky
2022-01-06 20:42 ` bugzilla-daemon
2022-01-06 21:12 ` bugzilla-daemon
2022-01-07  8:52 ` bugzilla-daemon
2022-01-07 10:08 ` bugzilla-daemon
2022-01-10  9:30 ` bugzilla-daemon
2022-01-10 22:29   ` Maxim Levitsky
2022-01-10 22:29 ` bugzilla-daemon
2022-01-11  8:29 ` bugzilla-daemon
2023-01-27 13:11 ` bugzilla-daemon

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=deb5cbc0a5dff445de9d3d5ae7b4d33b9f362c67.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=seanjc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.