CPU hotplug add seems broken

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

 



Hi all,

I've tried CPU hotplug with latest qemu-kvm.git code,
and got segmentation fault.

Call trace of the qemu-system-x86_64 is like this:

(gdb) where
#0  0x0000003cec80c280 in pthread_kill () from /lib64/libpthread.so.0
#1  0x000000000042fd72 in on_vcpu (env=0x2b24080,
    func=0x42ffd7 <kvm_do_load_mpstate>, data=0x2b24080)
    at /home/ozaki-r/git/qemu-kvm/qemu-kvm.c:1529
#2  0x000000000043002e in kvm_load_mpstate (env=0x2b24080)
    at /home/ozaki-r/git/qemu-kvm/qemu-kvm.c:1622
#3  0x000000000059197a in apic_init_reset (env=0x2b24080)
    at /home/ozaki-r/git/qemu-kvm/hw/apic.c:515
#4  0x0000000000592f07 in apic_reset (opaque=0x2a32d00)
    at /home/ozaki-r/git/qemu-kvm/hw/apic.c:1080
#5  0x0000000000593047 in apic_init (env=0x2b24080)
    at /home/ozaki-r/git/qemu-kvm/hw/apic.c:1137
#6  0x000000000056e7a9 in pc_new_cpu (cpu_model=0x6063b3 "qemu64")
    at /home/ozaki-r/git/qemu-kvm/hw/pc.c:984
#7  0x0000000000595d6b in qemu_system_cpu_hot_add (cpu=2, state=1)
    at /home/ozaki-r/git/qemu-kvm/hw/acpi.c:781
#8  0x0000000000414a83 in do_cpu_set_nr (mon=0x2af8b80, qdict=0x2af4920)
    at /home/ozaki-r/git/qemu-kvm/monitor.c:832
#9  0x0000000000419105 in handle_user_command (mon=0x2af8b80,
    cmdline=0x2d6e970 "cpu_set 2 online")
    at /home/ozaki-r/git/qemu-kvm/monitor.c:3671
#10 0x000000000041a400 in monitor_command_cb (mon=0x2af8b80,
    cmdline=0x2d6e970 "cpu_set 2 online", opaque=0x0)
    at /home/ozaki-r/git/qemu-kvm/monitor.c:4179
#11 0x0000000000474577 in readline_handle_byte (rs=0x2d6e970, ch=10)
    at readline.c:369
#12 0x000000000041a367 in monitor_read (opaque=0x2af8b80,
    buf=0x7ffff1c9a3c0 "\n\244\311\361\377\177", size=1)
    at /home/ozaki-r/git/qemu-kvm/monitor.c:4165
#13 0x000000000049856f in qemu_chr_read (s=0x29a6280,
    buf=0x7ffff1c9a3c0 "\n\244\311\361\377\177", len=1) at qemu-char.c:154
#14 0x0000000000476f6a in kbd_send_chars (opaque=0x2a69ec0) at console.c:1130
#15 0x0000000000477184 in kbd_put_keysym (keysym=10) at console.c:1183
#16 0x00000000004b704a in curses_refresh (ds=0x2a4b440) at curses.c:270
#17 0x0000000000408de1 in dpy_refresh (s=0x2a4b440)
    at /home/ozaki-r/git/qemu-kvm/console.h:219
#18 0x000000000040dfd9 in gui_update (opaque=0x2a4b440)
    at /home/ozaki-r/git/qemu-kvm/vl.c:3230
#19 0x000000000040a1ea in qemu_run_timers (ptimer_head=0x89bdc0,
    current_time=5844186) at /home/ozaki-r/git/qemu-kvm/vl.c:1127
#20 0x000000000040ebd6 in main_loop_wait (timeout=1000)
    at /home/ozaki-r/git/qemu-kvm/vl.c:4036
#21 0x0000000000430f66 in kvm_main_loop ()
    at /home/ozaki-r/git/qemu-kvm/qemu-kvm.c:2121
#22 0x000000000040f0ba in main_loop () at /home/ozaki-r/git/qemu-kvm/vl.c:4209
#23 0x0000000000412d86 in main (argc=14, argv=0x7ffff1c9ab68,
    envp=0x7ffff1c9abe0) at /home/ozaki-r/git/qemu-kvm/vl.c:6237
(gdb) list
1524            env->kvm_cpu_state.queued_work_last->next = &wi;
1525        env->kvm_cpu_state.queued_work_last = &wi;
1526        wi.next = NULL;
1527        wi.done = false;
1528
1529        pthread_kill(env->kvm_cpu_state.thread, SIG_IPI);
1530        while (!wi.done)
1531            qemu_cond_wait(&qemu_work_cond);
1532    }
1533
(gdb) print env->kvm_cpu_state.thread
$1 = 0


This looks like the thread is not created when sending SIG_IPI.

My short investigation says current code calls pthread_kill()
before pthread_create():

qemu_system_cpu_hot_add
=> pc_new_cpu
     => cpu_init
     => apic_init
          => apic_reset
               => apic_init_reset
                    => kvm_load_mpstate
                         => on_vcpu
                              => pthread_kill
     => qemu_init_vcpu
          => kvm_init_vcpu
               => pthread_create


Any ideas for fix?


Note that commit id is
  855ea2a3cd4ebb15bfe328023f6df29bacbffc85
and qemu command line is
  qemu-system-x86_64 -hda vm.img -kernel /boot/vmlinuz-2.6.33-rc3 \
    -initrd /boot/initramfs-2.6.33-rc3.img -append 'root=/dev/sda3 ro quiet' \
    -curses -smp 2,maxcpus=4
and command in qemu console is
  cpu_set 2 online


Thanks in advance,
  ozaki-r
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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