kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* When I boot two virtio-rng devices, guest will hang
@ 2014-07-28  7:32 Amos Kong
  2014-07-28  7:55 ` Amit Shah
  0 siblings, 1 reply; 7+ messages in thread
From: Amos Kong @ 2014-07-28  7:32 UTC (permalink / raw)
  To: Amit Shah; +Cc: kvm

QEMU commandline:

./x86_64-softmmu/qemu-system-x86_64 --enable-kvm   -m 2000 -drive file=/images/nolvm.qcow2 --kernel /home/devel/linux/arch/x86/boot/bzImage -append "ro root=/dev/sda1 console=ttyS0,115200"  -monitor unix:/tmp/m,nowait,server -device virtio-net-pci,netdev=h0,vectors=17,mq=on,id=n0 -netdev tap,id=h0,queues=8 -device virtio-net-pci,netdev=h1,vectors=0,mq=on,id=n1 -netdev tap,id=h1,queues=8  -vnc :0 -mon chardev=qmp,mode=control,pretty=on -chardev socket,id=qmp,host=localhost,port=1234,server,nowait -serial stdio -object rng-random,filename=/dev/urandom,id=rng0   -device virtio-rng-pci,rng=rng0,id=h0 -object rng-random,filename=/dev/urandom,id=rng1   -device virtio-rng-pci,rng=rng1,id=h1

It works when I only add one virtio-rng device. Did you touch this
problem?

I'm using latest net-next/master (ac3d2e5a9ef2f4d8f57c50070c4883ecb7cec29f)

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.16.0-rc6+ (amos@z) (gcc version 4.8.3 20140624 (Red Hat 4.8.3-1) (GCC) ) #363 SMP Mon Jul 28 15:05:44 CST 2014
[    0.000000] Command line: ro root=/dev/sda1 console=ttyS0,115200
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007cffdfff] usable
[    0.000000] BIOS-e820: [mem 0x000000007cffe000-0x000000007cffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.8 present.
[    0.000000] Hypervisor detected: KVM
[    0.000000] AGP: No AGP bridge found
[    0.000000] e820: last_pfn = 0x7cffe max_arch_pfn = 0x400000000
[    0.000000] PAT not supported by CPU.
[    0.000000] found SMP MP-table at [mem 0x000f0e90-0x000f0e9f] mapped at [ffff8800000f0e90]
[    0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff]
[    0.000000] init_memory_mapping: [mem 0x7cc00000-0x7cdfffff]
[    0.000000] init_memory_mapping: [mem 0x7c000000-0x7cbfffff]
[    0.000000] init_memory_mapping: [mem 0x00100000-0x7bffffff]
[    0.000000] init_memory_mapping: [mem 0x7ce00000-0x7cffdfff]
[    0.000000] ACPI: Early table checksum verification disabled
[    0.000000] ACPI: RSDP 0x00000000000F0C90 000014 (v00 BOCHS )
[    0.000000] ACPI: RSDT 0x000000007CFFFEF0 000034 (v01 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACP 0x000000007CFFF1D3 000074 (v01 BOCHS  BXPCFACP 00000001 BXPC 00000001)
[    0.000000] ACPI: DSDT 0x000000007CFFE040 001193 (v01 BOCHS  BXPCDSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACS 0x000000007CFFE000 000040
[    0.000000] ACPI: SSDT 0x000000007CFFF247 000BF9 (v01 BOCHS  BXPCSSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: APIC 0x000000007CFFFE40 000078 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
[    0.000000] ACPI: HPET 0x000000007CFFFEB8 000038 (v01 BOCHS  BXPCHPET 00000001 BXPC 00000001)
[    0.000000] No NUMA configuration found
[    0.000000] Faking a node at [mem 0x0000000000000000-0x000000007cffdfff]
[    0.000000] Initmem setup node 0 [mem 0x00000000-0x7cffdfff]
[    0.000000]   NODE_DATA [mem 0x7cfea000-0x7cffdfff]
[    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.000000] kvm-clock: cpu 0, msr 0:7cfe8001, primary cpu clock
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x00001000-0x00ffffff]
[    0.000000]   DMA32    [mem 0x01000000-0xffffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00001000-0x0009efff]
[    0.000000]   node   0: [mem 0x00100000-0x7cffdfff]
[    0.000000] ACPI: PM-Timer IO Port: 0x608
[    0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[    0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.000000] smpboot: Allowing 1 CPUs, 0 hotplug CPUs
[    0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff]
[    0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff]
[    0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff]
[    0.000000] e820: [mem 0x7d000000-0xfeffbfff] available for PCI devices
[    0.000000] Booting paravirtualized kernel on KVM
[    0.000000] setup_percpu: NR_CPUS:128 nr_cpumask_bits:128 nr_cpu_ids:1 nr_node_ids:1
[    0.000000] PERCPU: Embedded 27 pages/cpu @ffff88007cc00000 s81152 r8192 d21248 u2097152
[    0.000000] KVM setup async PF for cpu 0
[    0.000000] kvm-stealtime: cpu 0, msr 7cc0d080
[    0.000000] Built 1 zonelists in Node order, mobility grouping on.  Total pages: 503879
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: ro root=/dev/sda1 console=ttyS0,115200
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] AGP: Checking aperture...
[    0.000000] AGP: No AGP bridge found
[    0.000000] Memory: 1998212K/2047600K available (6874K kernel code, 1055K rwdata, 3048K rodata, 1416K init, 1416K bss, 49388K reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=128 to nr_cpu_ids=1.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS:8448 nr_irqs:256 16
[    0.000000] Console: colour VGA+ 80x25
[    0.000000] console [ttyS0] enabled
[    0.000000] allocated 8388608 bytes of page_cgroup
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] tsc: Detected 2893.428 MHz processor
[    0.002000] Calibrating delay loop (skipped) preset value.. 5786.85 BogoMIPS (lpj=2893428)
[    0.002382] pid_max: default: 32768 minimum: 301
[    0.003011] ACPI: Core revision 20140424
[    0.004747] ACPI: All ACPI Tables successfully acquired
[    0.005000] Security Framework initialized
[    0.005000] SELinux:  Initializing.
[    0.005220] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.006589] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.007188] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
[    0.008007] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
[    0.009153] Initializing cgroup subsys memory
[    0.010038] Initializing cgroup subsys devices
[    0.011007] Initializing cgroup subsys freezer
[    0.011552] Initializing cgroup subsys net_cls
[    0.012006] Initializing cgroup subsys blkio
[    0.012534] Initializing cgroup subsys perf_event
[    0.013054] mce: CPU supports 10 MCE banks
[    0.014020] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.014020] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
[    0.014020] tlb_flushall_shift: 6
[    0.025553] Freeing SMP alternatives memory: 24K (ffffffff81e6b000 - ffffffff81e71000)
[    0.029326] ftrace: allocating 25929 entries in 102 pages
[    0.036206] Enabling x2apic
[    0.036598] Enabled x2apic
[    0.037003] Switched APIC routing to physical x2apic.
[    0.038554] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.039001] smpboot: CPU0: Intel QEMU Virtual CPU version 2.0.92 (fam: 06, model: 06, stepping: 03)
[    0.041000] Performance Events: Broken PMU hardware detected, using software events only.
[    0.041004] Failed to access perfctr msr (MSR c1 is 0)
[    0.042606] x86: Booted up 1 node, 1 CPUs
[    0.043002] smpboot: Total of 1 processors activated (5786.85 BogoMIPS)
[    0.044104] NMI watchdog: disabled (cpu0): hardware events not enabled
[    0.044959] devtmpfs: initialized
[    0.046107] atomic64_test: passed for x86-64 platform with CX8 and with SSE
[    0.047002] RTC time:  7:25:09, date: 07/28/14
[    0.047609] NET: Registered protocol family 16
[    0.048079] cpuidle: using governor ladder
[    0.048578] cpuidle: using governor menu
[    0.049043] ACPI: bus type PCI registered
[    0.049526] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.050090] PCI: Using configuration type 1 for base access
[    0.052452] ACPI: Added _OSI(Module Device)
[    0.052991] ACPI: Added _OSI(Processor Device)
[    0.053002] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.054001] ACPI: Added _OSI(Processor Aggregator Device)
[    0.055921] ACPI: Interpreter enabled
[    0.056004] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S1_] (20140424/hwxface-580)
[    0.057270] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S2_] (20140424/hwxface-580)
[    0.058287] ACPI: (supports S0 S3 S4 S5)
[    0.059001] ACPI: Using IOAPIC for interrupt routing
[    0.059602] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.062395] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    0.063005] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
[    0.064005] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[    0.064840] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.065287] acpiphp: Slot [3] registered
[    0.066045] acpiphp: Slot [4] registered
[    0.067032] acpiphp: Slot [5] registered
[    0.067739] acpiphp: Slot [6] registered
[    0.068028] acpiphp: Slot [7] registered
[    0.068422] acpiphp: Slot [8] registered
[    0.069017] acpiphp: Slot [9] registered
[    0.069452] acpiphp: Slot [10] registered
[    0.070001] acpiphp: Slot [11] registered
[    0.070363] acpiphp: Slot [12] registered
[    0.070754] acpiphp: Slot [13] registered
[    0.071016] acpiphp: Slot [14] registered
[    0.071380] acpiphp: Slot [15] registered
[    0.071803] acpiphp: Slot [16] registered
[    0.072016] acpiphp: Slot [17] registered
[    0.072412] acpiphp: Slot [18] registered
[    0.073015] acpiphp: Slot [19] registered
[    0.073396] acpiphp: Slot [20] registered
[    0.073783] acpiphp: Slot [21] registered
[    0.074015] acpiphp: Slot [22] registered
[    0.074446] acpiphp: Slot [23] registered
[    0.075016] acpiphp: Slot [24] registered
[    0.075539] acpiphp: Slot [25] registered
[    0.076016] acpiphp: Slot [26] registered
[    0.076515] acpiphp: Slot [27] registered
[    0.077016] acpiphp: Slot [28] registered
[    0.077513] acpiphp: Slot [29] registered
[    0.078016] acpiphp: Slot [30] registered
[    0.078526] acpiphp: Slot [31] registered
[    0.079009] PCI host bridge to bus 0000:00
[    0.079504] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.080002] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7]
[    0.081002] pci_bus 0000:00: root bus resource [io  0x0d00-0xadff]
[    0.081737] pci_bus 0000:00: root bus resource [io  0xae0f-0xaeff]
[    0.082002] pci_bus 0000:00: root bus resource [io  0xaf20-0xafdf]
[    0.083002] pci_bus 0000:00: root bus resource [io  0xafe4-0xffff]
[    0.084009] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff]
[    0.085003] pci_bus 0000:00: root bus resource [mem 0x7d000000-0xfebfffff]
[    0.091716] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io  0x01f0-0x01f7]
[    0.092002] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io  0x03f6]
[    0.093002] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io  0x0170-0x0177]
[    0.094002] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io  0x0376]
[    0.095399] pci 0000:00:01.3: quirk: [io  0x0600-0x063f] claimed by PIIX4 ACPI
[    0.096009] pci 0000:00:01.3: quirk: [io  0x0700-0x070f] claimed by PIIX4 SMB
[    0.132469] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[    0.133279] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[    0.134293] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[    0.135102] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[    0.135871] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    0.136357] ACPI: Enabled 16 GPEs in block 00 to 0F
[    0.137088] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none
[    0.138001] vgaarb: loaded
[    0.138342] vgaarb: bridge control possible 0000:00:02.0
[    0.139061] SCSI subsystem initialized
[    0.140012] ACPI: bus type USB registered
[    0.140507] usbcore: registered new interface driver usbfs
[    0.141009] usbcore: registered new interface driver hub
[    0.141655] usbcore: registered new device driver usb
[    0.142046] PCI: Using ACPI for IRQ routing
[    0.143172] NetLabel: Initializing
[    0.143587] NetLabel:  domain hash size = 128
[    0.144002] NetLabel:  protocols = UNLABELED CIPSOv4
[    0.144610] NetLabel:  unlabeled traffic allowed by default
[    0.145037] HPET: 3 timers in total, 0 timers will be used for per-cpu timer
[    0.146015] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
[    0.146653] hpet0: 3 comparators, 64-bit 100.000000 MHz counter
[    0.151059] Switched to clocksource kvm-clock
[    0.155268] pnp: PnP ACPI init
[    0.155712] ACPI: bus type PNP registered
[    0.156621] pnp: PnP ACPI: found 6 devices
[    0.157127] ACPI: bus type PNP unregistered
[    0.163277] NET: Registered protocol family 2
[    0.163949] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.164866] TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
[    0.165692] TCP: Hash tables configured (established 16384 bind 16384)
[    0.166488] TCP: reno registered
[    0.166886] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[    0.167613] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    0.168492] NET: Registered protocol family 1
[    0.169048] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[    0.169769] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[    0.170485] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[    0.171866] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.172645] Initialise system trusted keyring
[    0.173222] audit: initializing netlink subsys (disabled)
[    0.173907] audit: type=2000 audit(1406532309.432:1): initialized
[    0.174810] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[    0.176647] VFS: Disk quotas dquot_6.5.2
[    0.177176] Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.178223] msgmni has been set to 3902
[    0.179343] alg: No test for stdrng (krng)
[    0.179884] NET: Registered protocol family 38
[    0.180427] Key type asymmetric registered
[    0.180919] Asymmetric key parser 'x509' registered
[    0.181538] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.182448] io scheduler noop registered
[    0.182995] io scheduler deadline registered
[    0.183632] io scheduler cfq registered (default)
[    0.184312] pci_hotplug: PCI Hot Plug PCI Core version: 0.5
[    0.184994] pciehp: PCI Express Hot Plug Controller Driver version: 0.4
[    0.185881] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[    0.186775] ACPI: Power Button [PWRF]
[    0.187315] GHES: HEST is not enabled!
[    0.188037] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
[    0.189546] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10
[    0.191160] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10
[    0.193347] ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 11
[    0.195317] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.222140] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    0.223503] Non-volatile memory driver v1.3
[    1.172293] tsc: Refined TSC clocksource calibration: 2893.436 MHz
qemu: terminating on signal 2           <---------- (I have to cancel QEMU process by Ctrl + C)


-- 
			Amos.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: When I boot two virtio-rng devices, guest will hang
  2014-07-28  7:32 When I boot two virtio-rng devices, guest will hang Amos Kong
@ 2014-07-28  7:55 ` Amit Shah
  2014-07-28  8:49   ` Amos Kong
  0 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2014-07-28  7:55 UTC (permalink / raw)
  To: Amos Kong; +Cc: Herbert Xu, kvm, Virtualization List

[-- Attachment #1: Type: text/plain, Size: 2857 bytes --]

On (Mon) 28 Jul 2014 [15:32:42], Amos Kong wrote:
> QEMU commandline:
> 
> ./x86_64-softmmu/qemu-system-x86_64 --enable-kvm   -m 2000 -drive file=/images/nolvm.qcow2 --kernel /home/devel/linux/arch/x86/boot/bzImage -append "ro root=/dev/sda1 console=ttyS0,115200"  -monitor unix:/tmp/m,nowait,server -device virtio-net-pci,netdev=h0,vectors=17,mq=on,id=n0 -netdev tap,id=h0,queues=8 -device virtio-net-pci,netdev=h1,vectors=0,mq=on,id=n1 -netdev tap,id=h1,queues=8  -vnc :0 -mon chardev=qmp,mode=control,pretty=on -chardev socket,id=qmp,host=localhost,port=1234,server,nowait -serial stdio -object rng-random,filename=/dev/urandom,id=rng0   -device virtio-rng-pci,rng=rng0,id=h0 -object rng-random,filename=/dev/urandom,id=rng1   -device virtio-rng-pci,rng=rng1,id=h1
> 
> It works when I only add one virtio-rng device. Did you touch this
> problem?
> 
> I'm using latest net-next/master (ac3d2e5a9ef2f4d8f57c50070c4883ecb7cec29f)

<snip>
> [    0.223503] Non-volatile memory driver v1.3
> [    1.172293] tsc: Refined TSC clocksource calibration: 2893.436 MHz
> qemu: terminating on signal 2           <---------- (I have to cancel QEMU process by Ctrl + C)

This looks similar to what I saw when driver asks for randomness from the host
before probe is completed.

Does the following patch help?

While the driver is setup (DRIVER_OK is set), the vqs aren't marked
usable before the probe for the other device finishes as well.  That's
not a scenario I considered.  We can try to put this patch in 3.16,
but it won't be applicable for 3.17, where this is handled the proper
way.  Also, 3.15 isn't affected, since that doesn't have multi-device
support.

Also attaching a patch that enables traces in qemu so it's easier to
see what's going on.


diff --git a/drivers/char/hw_random/virtio-rng.c
b/drivers/char/hw_random/virtio-rng.c
index e9b15bc..124cac5 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -34,12 +34,11 @@ struct virtrng_info {
        unsigned int data_avail;
        struct completion have_data;
        bool busy;
+       bool probe_done;
        char name[25];
        int index;
 };
 
-static bool probe_done;
-
 static void random_recv_done(struct virtqueue *vq)
 {
        struct virtrng_info *vi = vq->vdev->priv;
@@ -73,7 +72,7 @@ static int virtio_read(struct hwrng *rng, void *buf,
-size_t size, bool wait)
         * Don't ask host for data till we're setup.  This call can
         * happen during hwrng_register(), after commit d9e7972619.
         */
-       if (unlikely(!probe_done))
+       if (unlikely(!vi->probe_done))
                return 0;
 
        if (!vi->busy) {
@@ -146,7 +145,7 @@ static int probe_common(struct virtio_device
*vdev)
                return err;
        }
 
-       probe_done = true;
+       vi->probe_done = true;
        return 0;
 }
 

		Amit

[-- Attachment #2: 0001-virtio-rng-add-some-trace-events.patch --]
[-- Type: text/plain, Size: 2494 bytes --]

>From ec1aa555b67628beefa0ac6902baa2cc2e156f58 Mon Sep 17 00:00:00 2001
Message-Id: <ec1aa555b67628beefa0ac6902baa2cc2e156f58.1406533638.git.amit.shah@redhat.com>
From: Amit Shah <amit.shah@redhat.com>
Date: Mon, 21 Jul 2014 14:46:28 +0530
Subject: [PATCH 1/1] virtio-rng: add some trace events

Add some trace events to virtio-rng for easier debugging

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio/virtio-rng.c | 7 +++++++
 trace-events           | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 7c5a675..4a6472b 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -16,6 +16,7 @@
 #include "hw/virtio/virtio-rng.h"
 #include "sysemu/rng.h"
 #include "qom/object_interfaces.h"
+#include "trace.h"
 
 static bool is_guest_ready(VirtIORNG *vrng)
 {
@@ -24,6 +25,7 @@ static bool is_guest_ready(VirtIORNG *vrng)
         && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
         return true;
     }
+    trace_virtio_rng_guest_not_ready(vrng);
     return false;
 }
 
@@ -62,6 +64,7 @@ static void chr_read(void *opaque, const void *buf, size_t size)
         offset += len;
 
         virtqueue_push(vrng->vq, &elem, len);
+        trace_virtio_rng_pushed(vrng, len);
     }
     virtio_notify(vdev, vrng->vq);
 }
@@ -81,7 +84,11 @@ static void virtio_rng_process(VirtIORNG *vrng)
         quota = MIN((uint64_t)vrng->quota_remaining, (uint64_t)UINT32_MAX);
     }
     size = get_request_size(vrng->vq, quota);
+
+    trace_virtio_rng_request(vrng, size, quota);
+
     size = MIN(vrng->quota_remaining, size);
+
     if (size) {
         rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
     }
diff --git a/trace-events b/trace-events
index 11a17a8..99f39ac 100644
--- a/trace-events
+++ b/trace-events
@@ -41,6 +41,11 @@ virtio_irq(void *vq) "vq %p"
 virtio_notify(void *vdev, void *vq) "vdev %p vq %p"
 virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u"
 
+# hw/virtio/virtio-rng.c
+virtio_rng_guest_not_ready(void *rng) "rng %p: guest not ready"
+virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
+virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes requested, %u bytes quota left"
+
 # hw/char/virtio-serial-bus.c
 virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t value) "port %u, event %u, value %u"
 virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, throttle %d"
-- 
1.9.3


[-- Attachment #3: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: When I boot two virtio-rng devices, guest will hang
  2014-07-28  7:55 ` Amit Shah
@ 2014-07-28  8:49   ` Amos Kong
  2014-07-28  9:12     ` Amit Shah
  0 siblings, 1 reply; 7+ messages in thread
From: Amos Kong @ 2014-07-28  8:49 UTC (permalink / raw)
  To: Amit Shah; +Cc: kvm, Virtualization List, Herbert Xu

On Mon, Jul 28, 2014 at 01:25:14PM +0530, Amit Shah wrote:
> On (Mon) 28 Jul 2014 [15:32:42], Amos Kong wrote:
> > QEMU commandline:
> > 
> > ./x86_64-softmmu/qemu-system-x86_64 --enable-kvm   -m 2000 -drive file=/images/nolvm.qcow2 --kernel /home/devel/linux/arch/x86/boot/bzImage -append "ro root=/dev/sda1 console=ttyS0,115200"  -monitor unix:/tmp/m,nowait,server -device virtio-net-pci,netdev=h0,vectors=17,mq=on,id=n0 -netdev tap,id=h0,queues=8 -device virtio-net-pci,netdev=h1,vectors=0,mq=on,id=n1 -netdev tap,id=h1,queues=8  -vnc :0 -mon chardev=qmp,mode=control,pretty=on -chardev socket,id=qmp,host=localhost,port=1234,server,nowait -serial stdio -object rng-random,filename=/dev/urandom,id=rng0   -device virtio-rng-pci,rng=rng0,id=h0 -object rng-random,filename=/dev/urandom,id=rng1   -device virtio-rng-pci,rng=rng1,id=h1
> > 
> > It works when I only add one virtio-rng device. Did you touch this
> > problem?
> > 
> > I'm using latest net-next/master (ac3d2e5a9ef2f4d8f57c50070c4883ecb7cec29f)
 
Hi Amit,

> <snip>
> > [    0.223503] Non-volatile memory driver v1.3
> > [    1.172293] tsc: Refined TSC clocksource calibration: 2893.436 MHz
> > qemu: terminating on signal 2           <---------- (I have to cancel QEMU process by Ctrl + C)
> 
> This looks similar to what I saw when driver asks for randomness from the host
> before probe is completed.
> 
> Does the following patch help?

This patch was already inclued in latest net-next/master
patch commit: e052dbf554610e2104c5a7518c4d8374bed701bb

> While the driver is setup (DRIVER_OK is set), the vqs aren't marked
> usable before the probe for the other device finishes as well.  That's
> not a scenario I considered.  We can try to put this patch in 3.16,
> but it won't be applicable for 3.17, where this is handled the proper
> way.  Also, 3.15 isn't affected, since that doesn't have multi-device
> support.
> 
> Also attaching a patch that enables traces in qemu so it's easier to
> see what's going on.
>
> diff --git a/drivers/char/hw_random/virtio-rng.c
> b/drivers/char/hw_random/virtio-rng.c
> index e9b15bc..124cac5 100644
> --- a/drivers/char/hw_random/virtio-rng.c
> +++ b/drivers/char/hw_random/virtio-rng.c
> @@ -34,12 +34,11 @@ struct virtrng_info {
>         unsigned int data_avail;
>         struct completion have_data;
>         bool busy;
> +       bool probe_done;
>         char name[25];
>         int index;
>  };
>  
> -static bool probe_done;
> -
>  static void random_recv_done(struct virtqueue *vq)
>  {
>         struct virtrng_info *vi = vq->vdev->priv;
> @@ -73,7 +72,7 @@ static int virtio_read(struct hwrng *rng, void *buf,
> -size_t size, bool wait)
>          * Don't ask host for data till we're setup.  This call can
>          * happen during hwrng_register(), after commit d9e7972619.
>          */
> -       if (unlikely(!probe_done))
> +       if (unlikely(!vi->probe_done))
>                 return 0;
>  
>         if (!vi->busy) {
> @@ -146,7 +145,7 @@ static int probe_common(struct virtio_device
> *vdev)
>                 return err;
>         }
>  
> -       probe_done = true;
> +       vi->probe_done = true;
>         return 0;
>  }
>  
> 
> 		Amit

> >From ec1aa555b67628beefa0ac6902baa2cc2e156f58 Mon Sep 17 00:00:00 2001
> Message-Id: <ec1aa555b67628beefa0ac6902baa2cc2e156f58.1406533638.git.amit.shah@redhat.com>
> From: Amit Shah <amit.shah@redhat.com>
> Date: Mon, 21 Jul 2014 14:46:28 +0530
> Subject: [PATCH 1/1] virtio-rng: add some trace events
> 
> Add some trace events to virtio-rng for easier debugging
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  hw/virtio/virtio-rng.c | 7 +++++++
>  trace-events           | 5 +++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
> index 7c5a675..4a6472b 100644
> --- a/hw/virtio/virtio-rng.c
> +++ b/hw/virtio/virtio-rng.c
> @@ -16,6 +16,7 @@
>  #include "hw/virtio/virtio-rng.h"
>  #include "sysemu/rng.h"
>  #include "qom/object_interfaces.h"
> +#include "trace.h"
>  
>  static bool is_guest_ready(VirtIORNG *vrng)
>  {
> @@ -24,6 +25,7 @@ static bool is_guest_ready(VirtIORNG *vrng)
>          && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
>          return true;
>      }
> +    trace_virtio_rng_guest_not_ready(vrng);
>      return false;
>  }
>  
> @@ -62,6 +64,7 @@ static void chr_read(void *opaque, const void *buf, size_t size)
>          offset += len;
>  
>          virtqueue_push(vrng->vq, &elem, len);
> +        trace_virtio_rng_pushed(vrng, len);
>      }
>      virtio_notify(vdev, vrng->vq);
>  }
> @@ -81,7 +84,11 @@ static void virtio_rng_process(VirtIORNG *vrng)
>          quota = MIN((uint64_t)vrng->quota_remaining, (uint64_t)UINT32_MAX);
>      }
>      size = get_request_size(vrng->vq, quota);
> +
> +    trace_virtio_rng_request(vrng, size, quota);
> +
>      size = MIN(vrng->quota_remaining, size);
> +
>      if (size) {
>          rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
>      }
> diff --git a/trace-events b/trace-events
> index 11a17a8..99f39ac 100644
> --- a/trace-events
> +++ b/trace-events
> @@ -41,6 +41,11 @@ virtio_irq(void *vq) "vq %p"
>  virtio_notify(void *vdev, void *vq) "vdev %p vq %p"
>  virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u"
>  
> +# hw/virtio/virtio-rng.c
> +virtio_rng_guest_not_ready(void *rng) "rng %p: guest not ready"
> +virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
> +virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes requested, %u bytes quota left"
> +
>  # hw/char/virtio-serial-bus.c
>  virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t value) "port %u, event %u, value %u"
>  virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, throttle %d"
> -- 
> 1.9.3
> 


-- 
			Amos.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: When I boot two virtio-rng devices, guest will hang
  2014-07-28  8:49   ` Amos Kong
@ 2014-07-28  9:12     ` Amit Shah
  2014-07-28 12:11       ` Amos Kong
  0 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2014-07-28  9:12 UTC (permalink / raw)
  To: Amos Kong; +Cc: Herbert Xu, kvm, Virtualization List

On (Mon) 28 Jul 2014 [16:49:20], Amos Kong wrote:
> On Mon, Jul 28, 2014 at 01:25:14PM +0530, Amit Shah wrote:
> > On (Mon) 28 Jul 2014 [15:32:42], Amos Kong wrote:
> > > QEMU commandline:
> > > 
> > > ./x86_64-softmmu/qemu-system-x86_64 --enable-kvm   -m 2000 -drive file=/images/nolvm.qcow2 --kernel /home/devel/linux/arch/x86/boot/bzImage -append "ro root=/dev/sda1 console=ttyS0,115200"  -monitor unix:/tmp/m,nowait,server -device virtio-net-pci,netdev=h0,vectors=17,mq=on,id=n0 -netdev tap,id=h0,queues=8 -device virtio-net-pci,netdev=h1,vectors=0,mq=on,id=n1 -netdev tap,id=h1,queues=8  -vnc :0 -mon chardev=qmp,mode=control,pretty=on -chardev socket,id=qmp,host=localhost,port=1234,server,nowait -serial stdio -object rng-random,filename=/dev/urandom,id=rng0   -device virtio-rng-pci,rng=rng0,id=h0 -object rng-random,filename=/dev/urandom,id=rng1   -device virtio-rng-pci,rng=rng1,id=h1
> > > 
> > > It works when I only add one virtio-rng device. Did you touch this
> > > problem?
> > > 
> > > I'm using latest net-next/master (ac3d2e5a9ef2f4d8f57c50070c4883ecb7cec29f)
>  
> Hi Amit,
> 
> > <snip>
> > > [    0.223503] Non-volatile memory driver v1.3
> > > [    1.172293] tsc: Refined TSC clocksource calibration: 2893.436 MHz
> > > qemu: terminating on signal 2           <---------- (I have to cancel QEMU process by Ctrl + C)
> > 
> > This looks similar to what I saw when driver asks for randomness from the host
> > before probe is completed.
> > 
> > Does the following patch help?
> 
> This patch was already inclued in latest net-next/master
> patch commit: e052dbf554610e2104c5a7518c4d8374bed701bb

No, it's a different one, goes on top of the commit you referenced.

		Amit

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: When I boot two virtio-rng devices, guest will hang
  2014-07-28  9:12     ` Amit Shah
@ 2014-07-28 12:11       ` Amos Kong
  2014-08-05 10:28         ` Amos Kong
  0 siblings, 1 reply; 7+ messages in thread
From: Amos Kong @ 2014-07-28 12:11 UTC (permalink / raw)
  To: Amit Shah; +Cc: Herbert Xu, kvm, Virtualization List

On Mon, Jul 28, 2014 at 02:42:13PM +0530, Amit Shah wrote:
> On (Mon) 28 Jul 2014 [16:49:20], Amos Kong wrote:
> > On Mon, Jul 28, 2014 at 01:25:14PM +0530, Amit Shah wrote:
> > > On (Mon) 28 Jul 2014 [15:32:42], Amos Kong wrote:
> > > > QEMU commandline:
> > > > 
> > > > ./x86_64-softmmu/qemu-system-x86_64 --enable-kvm   -m 2000 -drive file=/images/nolvm.qcow2 --kernel /home/devel/linux/arch/x86/boot/bzImage -append "ro root=/dev/sda1 console=ttyS0,115200"  -monitor unix:/tmp/m,nowait,server -device virtio-net-pci,netdev=h0,vectors=17,mq=on,id=n0 -netdev tap,id=h0,queues=8 -device virtio-net-pci,netdev=h1,vectors=0,mq=on,id=n1 -netdev tap,id=h1,queues=8  -vnc :0 -mon chardev=qmp,mode=control,pretty=on -chardev socket,id=qmp,host=localhost,port=1234,server,nowait -serial stdio -object rng-random,filename=/dev/urandom,id=rng0   -device virtio-rng-pci,rng=rng0,id=h0 -object rng-random,filename=/dev/urandom,id=rng1   -device virtio-rng-pci,rng=rng1,id=h1
> > > > 
> > > > It works when I only add one virtio-rng device. Did you touch this
> > > > problem?
> > > > 
> > > > I'm using latest net-next/master (ac3d2e5a9ef2f4d8f57c50070c4883ecb7cec29f)
> >  
> > Hi Amit,
> > 
> > > <snip>
> > > > [    0.223503] Non-volatile memory driver v1.3
> > > > [    1.172293] tsc: Refined TSC clocksource calibration: 2893.436 MHz
> > > > qemu: terminating on signal 2           <---------- (I have to cancel QEMU process by Ctrl + C)
> > > 
> > > This looks similar to what I saw when driver asks for randomness from the host
> > > before probe is completed.
> > > 
> > > Does the following patch help?
> > 
> > This patch was already inclued in latest net-next/master
> > patch commit: e052dbf554610e2104c5a7518c4d8374bed701bb
> 
> No, it's a different one, goes on top of the commit you referenced.
 
Thanks. This patch fixed the problem.

-- 
			Amos.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: When I boot two virtio-rng devices, guest will hang
  2014-07-28 12:11       ` Amos Kong
@ 2014-08-05 10:28         ` Amos Kong
  2014-08-05 17:45           ` Amos Kong
  0 siblings, 1 reply; 7+ messages in thread
From: Amos Kong @ 2014-08-05 10:28 UTC (permalink / raw)
  To: Amit Shah; +Cc: Herbert Xu, kvm, Virtualization List

3.16 (guest hangs with two rng devices)
3.16 + quick fix (can startup with two rng devices) (hotplug issue 1 + hotplug issue 2 exist)
lates torvalds/linux.git + amit 4 patches (can startup with two rng devices) (only hotplug issue 2 exists)

However, the 4 patches also fixed the hang issue, the hotplug issue was fixed a little.
The hotplug issue is effected by the backend, or maybe it's not a real issue, because
the rng device can be hot-removed after dd process is killed.


Hotplug issue 1:
  1. boot up guest with two rng device (rng0 uses /dev/urandom, rng1 uses /dev/random)
  2. read data by dd in guest
  3 (option 1). hot-remove rng0, then hot-remove rng1 -> result: _only rng1_ can't be removed until dd process is killed
  3 (option 2). hot-remove rng1, then hot-remove rng0 -> result: two devices can be removed successfully, dd process will exit automatically.

  If we use /dev/urandom for rng0 and rng1, _rng0 & rng1_ can be removed, dd process will exit automatically.

Hotplug issue 2:
  If we use /dev/random for rng0 and rng1, _rng0 & rng1_ can't be removed until dd process is killed.

Hotplug issue 3:
  If we use /dev/random for rng0 and rng1, _only rng1_ can't be removed until dd process is killed.


(The difference between /dev/random and /dev/urandom is the speed.)

Thanks, Amos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: When I boot two virtio-rng devices, guest will hang
  2014-08-05 10:28         ` Amos Kong
@ 2014-08-05 17:45           ` Amos Kong
  0 siblings, 0 replies; 7+ messages in thread
From: Amos Kong @ 2014-08-05 17:45 UTC (permalink / raw)
  To: Amit Shah; +Cc: Herbert Xu, kvm, Virtualization List

On Tue, Aug 05, 2014 at 06:28:54PM +0800, Amos Kong wrote:
> 3.16 (guest hangs with two rng devices)
> 3.16 + quick fix (can startup with two rng devices) (hotplug issue 1 + hotplug issue 2 exist)
> lates torvalds/linux.git + amit 4 patches (can startup with two rng devices) (only hotplug issue 2 exists)
> 
> However, the 4 patches also fixed the hang issue, the hotplug issue was fixed a little.
> The hotplug issue is effected by the backend, or maybe it's not a real issue, because
> the rng device can be hot-removed after dd process is killed.
> 
> 
> Hotplug issue 1:
>   1. boot up guest with two rng device (rng0 uses /dev/urandom, rng1 uses /dev/random)
>   2. read data by dd in guest
>   3 (option 1). hot-remove rng0, then hot-remove rng1 -> result: _only rng1_ can't be removed until dd process is killed
>   3 (option 2). hot-remove rng1, then hot-remove rng0 -> result: two devices can be removed successfully, dd process will exit automatically.
> 
>   If we use /dev/urandom for rng0 and rng1, _rng0 & rng1_ can be removed, dd process will exit automatically.
> 
> Hotplug issue 2:
>   If we use /dev/random for rng0 and rng1, _rng0 & rng1_ can't be removed until dd process is killed.
> 
> Hotplug issue 3:
>   If we use /dev/random for rng0 and rng1, _only rng1_ can't be removed until dd process is killed.

Hi Amit,

I finally found the root problem and posted a fix to upstream:
  http://lists.linuxfoundation.org/pipermail/virtualization/2014-August/027049.html

It can help to fix the hotplug issues on 3.16 & latest kernel, so
stable kernel is CCed.

> (The difference between /dev/random and /dev/urandom is the speed.)
> 
> Thanks, Amos

-- 
			Amos.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-05 17:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-28  7:32 When I boot two virtio-rng devices, guest will hang Amos Kong
2014-07-28  7:55 ` Amit Shah
2014-07-28  8:49   ` Amos Kong
2014-07-28  9:12     ` Amit Shah
2014-07-28 12:11       ` Amos Kong
2014-08-05 10:28         ` Amos Kong
2014-08-05 17:45           ` Amos Kong

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).