Opened 3 months ago

Last modified 6 weeks ago

#18962 assigned bug

virtio devices often timeout (never receive interrupts) under guarded heap

Reported by: waddlesplash Owned by: korli
Priority: normal Milestone: Unscheduled
Component: Drivers Version: R1/Development
Keywords: Cc:
Blocked By: Blocking: #19125
Platform: All

Description

I built an image with the guarded heap enabled (USE_GUARDED_HEAP_FOR_MALLOC=1, USE_GUARDED_HEAP_FOR_OBJECT_CACHE=0). When booting it in QEMU with software emulation (no KVM), virtio-scsi and virtio-net often fail to initialize. Sometimes virtio-scsi will work but virtio-net will not; sometimes virtio-scsi will fail to initialize with these messages:

msix configured for 4 vectors
msi-x enabled: 0x8003
virtio_pci: using MSI-X count 4 starting at 24
virtio_scsi: wait failed with status: 0x80000009

(and thus the boot will fail.)

When the devices have failed to initialize, the interrupt count as displayed by "ints" always seems to be 0.

When not using the guarded heap, I haven't gotten equivalent failures yet. The fact that it only happens sometimes under the guarded heap sounds like it could be a race condition.

This is with current master and QEMU 7.0. QEMU invocation:

qemu-system-x86_64 -display sdl -m 4G -nic model=virtio -device virtio-scsi-pci -device scsi-hd,drive=x0 -drive file=haiku-minimum.image,format=raw,if=none,id=x0 -serial stdio -s

Attachments (3)

debug-log.txt (6.4 KB ) - added by kallisti5 6 weeks ago.
debug log. Guarded heap + debug in virtio_pci / virtio_scsi
irq.png (23.2 KB ) - added by kallisti5 6 weeks ago.
virtio interrupts (added panic to the wait timeout)
guarded_heaps.png (76.3 KB ) - added by kallisti5 6 weeks ago.
guarded heap area info. interrupt data addresses

Download all attachments as: .zip

Change History (5)

comment:1 by kallisti5, 6 weeks ago

Blocking: 19125 added

comment:2 by kallisti5, 6 weeks ago

reproduced with:

diff --git a/build/config_headers/kernel_debug_config.h b/build/config_headers/kernel_debug_config.h
index 22f0a40b90..23ff2972d4 100644
--- a/build/config_headers/kernel_debug_config.h
+++ b/build/config_headers/kernel_debug_config.h
@@ -104,14 +104,14 @@
 // Use the selected allocator as generic memory allocator (malloc()/free()).
 #define USE_DEBUG_HEAP_FOR_MALLOC              0
        // Heap implementation with additional debugging facilities.
-#define USE_GUARDED_HEAP_FOR_MALLOC            0
+#define USE_GUARDED_HEAP_FOR_MALLOC            1
        // Heap implementation that allocates memory so that the end of the
        // allocation always coincides with a page end and is followed by a guard
        // page which is marked non-present. Out of bounds access (both read and
        // write) therefore cause a crash (unhandled page fault). Note that this
        // allocator is neither speed nor space efficient, indeed it wastes huge
        // amounts of pages and address space so it is quite easy to hit limits.
-#define USE_SLAB_ALLOCATOR_FOR_MALLOC  1
+#define USE_SLAB_ALLOCATOR_FOR_MALLOC  0
        // Heap implementation based on the slab allocator (for production use).
 
 // Replace the object cache with the guarded heap to force debug features. Also

Plus https://review.haiku-os.org/c/haiku/+/8369

by kallisti5, 6 weeks ago

Attachment: debug-log.txt added

debug log. Guarded heap + debug in virtio_pci / virtio_scsi

by kallisti5, 6 weeks ago

Attachment: irq.png added

virtio interrupts (added panic to the wait timeout)

by kallisti5, 6 weeks ago

Attachment: guarded_heaps.png added

guarded heap area info. interrupt data addresses

Note: See TracTickets for help on using tickets.