2 ms·
PCI enumeration turns out to be surprisingly slow, especially when virtualized. Access to PCI config space is done by writing an address to one register and re
by rwmj 3y ago
PCI enumeration turns out to be surprisingly slow, especially when virtualized. Access to PCI config space is done by writing an address to one register and reading the data at that address from another register, repeat for every word in the PCI config space for every device. Each of those register reads and writes takes a VMEXIT, so goes through the host kernel and into qemu and back. Oh yeah, and it used to be done twice, once by SeaBIOS and once by the kernel (the SeaBIOS stuff has been optimized since.)
- toast0 3y agoIf you're dealing with modern systems (which would hopefully include virtual machines), the PCI config space can be memory mapped, and then you don't need to read it through the PCI config registers.
- xp84 3y agoI'm basically a 5yo when it comes to hardware - so my apologies for the dumb question - but I wonder naïvely, could this enumeration be completely cached by default? Most computers have most of the important stuff either soldered down (laptops) or at least not swapped regularly. I think I'd sign up immediately for a system where I had to hold a key at startup the first time I installed a new GPU or something, but otherwise it could boot into Windows in 3 seconds. Since most devices that are likely to change are hot-pluggable, I would imagine that those don't need to be checked on at boot time. I'd love to know where I'm wrong on this, though. Perhaps this is part of what Windows does -- I know that it basically keeps a hibernated image of the non-logged-in RAM state, for use when you shut down (and it throws it out if you do an explicit Restart, for troubleshooting reasons)