From: Matt Mullins Subject: Live migration locks up 3.2 guests in do_timer(ticks ~ 500000) Date: Sun, 7 Sep 2014 22:54:18 -0700 Message-ID: <20140908055416.GE23305@hydra.tuxags.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: kvm@vger.kernel.org Return-path: Received: from hydra.tuxags.com ([64.13.172.54]:35800 "EHLO mail.tuxags.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751430AbaIHF7d (ORCPT ); Mon, 8 Sep 2014 01:59:33 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Somewhere between kernel 3.2 and 3.11 on my VM hosts (yes, I know that narrows it down a /whole lot/ ...), live migration started killing my Ubuntu precise (kernel 3.2.x) guests, causing all of their vcpus to go into a busy loop. Once (and only once) I've observed the guest eventually becoming responsive again, with a clock nearly 600 years in the future and a negative uptime. I haven't been able to dig up any previous threads about this problem, so my gut instinct is that I've configured something wonky. Any pointers toward /what/ I may have done wrong are appreciated. It only seems to happen if I've given the guests Nehalem-class CPU features. My longest-running VMs, from before I started passing-through the CPU capabilities into the guest, seem to migrate without issue. It also seems to happen reliably when the guest has been running for a while; it's easily reproducible with guests that have been up ~1 day, and I've reproduced it in VMs with an uptime of ~20 hours. I haven't yet figured out a lower-bound, which makes the testing cycle a little longer for me. The guests that I reliably reproduce this on are Ubuntu 12.04 guests running the current 3.2 kernel that Canonical distributes. Recent Fedora kernels (3.14+, IIRC) don't seem to busy-spin this way, though I haven't tested this case exhaustively, and I haven't written down very good notes for the tests I have done with Fedora. The hosts are dual-socket Nehalem Xeons (L5520), currently running Ubuntu 14.04 and the associated 3.13 kernel. I had previously reproduced this with 12.04 running a raring-backport 3.11 kernel as well, but I (seemingly erroneously) assumed it may have been a qemu userspace discrepancy. I have been poring through a debugger attached to the guest via qemu's gdbserver after it gets sent in a busy-spin, and the stack trace is: (gdb) bt #0 second_overflow (secs=) at /build/buildd/linux-3.2.0/kernel/time/ntp.c:407 #1 0xffffffff81095c75 in logarithmic_accumulation (offset=3831765322649889943, shift=9) at /build/buildd/linux-3.2.0/kernel/time/timekeeping.c:987 #2 0xffffffff81096042 in update_wall_time () at /build/buildd/linux-3.2.0/kernel/time/timekeeping.c:1056 #3 0xffffffff81096e8d in do_timer (ticks=549606) at /build/buildd/linux-3.2.0/kernel/time/timekeeping.c:1246 #4 0xffffffff8109d825 in tick_do_update_jiffies64 (now=...) at /build/buildd/linux-3.2.0/kernel/time/tick-sched.c:77 #5 0xffffffff8109dda6 in tick_nohz_update_jiffies (now=...) at /build/buildd/linux-3.2.0/kernel/time/tick-sched.c:145 #6 0xffffffff8109e378 in tick_check_nohz (cpu=0) at /build/buildd/linux-3.2.0/kernel/time/tick-sched.c:713 #7 tick_check_idle (cpu=0) at /build/buildd/linux-3.2.0/kernel/time/tick-sched.c:731 #8 0xffffffff8106ff91 in irq_enter () at /build/buildd/linux-3.2.0/kernel/softirq.c:306 #9 0xffffffff8166cef3 in smp_apic_timer_interrupt (regs=) at /build/buildd/linux-3.2.0/arch/x86/kernel/apic/apic.c:880 #10 #11 0xffffffffffffff10 in ?? () (gdb) thread 2 [Switching to thread 2 (Thread 2)] #0 read_seqbegin (sl=) at /build/buildd/linux-3.2.0/include/linux/seqlock.h:89 89 /build/buildd/linux-3.2.0/include/linux/seqlock.h: No such file or directory. (gdb) bt #0 read_seqbegin (sl=) at /build/buildd/linux-3.2.0/include/linux/seqlock.h:89 #1 ktime_get () at /build/buildd/linux-3.2.0/kernel/time/timekeeping.c:268 #2 0xffffffff8109e355 in tick_check_nohz (cpu=1) at /build/buildd/linux-3.2.0/kernel/time/tick-sched.c:709 #3 tick_check_idle (cpu=1) at /build/buildd/linux-3.2.0/kernel/time/tick-sched.c:731 #4 0xffffffff8106ff91 in irq_enter () at /build/buildd/linux-3.2.0/kernel/softirq.c:306 #5 0xffffffff8166cef3 in smp_apic_timer_interrupt (regs=) at /build/buildd/linux-3.2.0/arch/x86/kernel/apic/apic.c:880 #6 #7 0xffffffffffffff10 in ?? () If I continue, then re-stop the guest, logarithmic_accumulation() is still in the stacktrace, with the same offset and shift; the line numbers indicate it's stuck in the following loop: while (timekeeper.xtime_nsec >= nsecps) { int leap; timekeeper.xtime_nsec -= nsecps; xtime.tv_sec++; leap = second_overflow(xtime.tv_sec); xtime.tv_sec += leap; wall_to_monotonic.tv_sec -= leap; if (leap) clock_was_set_delayed(); } Live migration is initiated through libvirt by virDomainMigrate with flags=VIR_MIGRATE_LIVE, uri="tcp://$recv_hostname". The guest is spawned by libvirtd with: qemu-system-x86_64 -enable-kvm -name dog -S -machine pc-i440fx-trusty,accel=kvm,usb=off -cpu Nehalem,+dca,+xtpr,+tm2,+est,+vmx,+ds_cpl,+monitor,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -m 512 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 55fd4c19-2477-40a5-988f-aaccd60b20dc -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/dog.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot menu=on,strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1 -drive file=rbd:rbd/dog:id=libvirt:key=________________________________________:auth_supported=cephx\;none,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 -netdev tap,ifname=vm9_0,script=no,id=hostnet0,vhost=on,vhostfd=26 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:16:3e:62:7a:9d,bus=pci.0,addr=0x3 -vnc 0.0.0.0:9,password -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -incoming tcp:[::]:49152 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 The libvirt domain XML is: dog 55fd4c19-2477-40a5-988f-aaccd60b20dc 524288 524288 2 /machine hvm Nehalem destroy restart destroy /usr/bin/kvm-spice