I/O performance regression between 9.0.2 and 11.1.3 on Xen
Marek Marczykowski-Górecki
Reviewed-by Stefano StabelliniHi,
After updating QEMU in a stubdomain on Qubes OS (Xen)[1], I got severe performance regression. The benchmark I noticed it on is Windows installation time - the first phase (until first reboot) went from ~7 min up to ~30 min. The version range isn't exactly trivial, but on the other hand the issue is 100% reliable, so I easily bisected it. The result:
123acd816dccbd358570ec7ab79c5cb2c863780b is the first bad commit commit 123acd816dccbd358570ec7ab79c5cb2c863780b
Author: Edgar E. Iglesias <[email protected]> Date: Mon Apr 29 19:12:42 2024 +0200
xen: mapcache: Unmap first entries in buckets
When invalidating memory ranges, if we happen to hit the first entry in a bucket we were never unmapping it. This was harmless for foreign mappings but now that we're looking to reuse the mapcache for transient grant mappings, we must unmap entries when invalidated.
hw/xen/xen-mapcache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
And indeed, reverting it on top of 11.1.3 fixes the issue. I assume that page gets mapped and unmapped a lot (for disk I/O?).
Let me know if some more information is needed, some logs to collect maybe? Or a simplified test case?
[1] https://github.com/QubesOS/qubes-vmm-xen-stubdom-linux/pull/77
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 4 lines · Marek Marczykowski-Górecki
And indeed, reverting it on top of 11.1.3 fixes the issue. I assume that page gets mapped and unmapped a lot (for disk I/O?).
Let me know if some more information is needed, some logs to collect maybe? Or a simplified test case?
Hi Marek,
Thanks for bisecting this. We hit the same slowdown and carry a patch that keeps foreign DMA mappings cached after their last user releases them. That lets repeated I/O to the same guest pages reuse the mapping.
I have the patch queued for upstreaming. It’s on the edgar/xen-pvh-fixes branch in my tree.
3386b77e09 xen-mapcache: Keep released DMA mappings cached
https://github.com/edgarigl/qemu/commit/3386b77e09e194ffc921c79f28241de8e5545748
Could you try it on QEMU 11.1.3 with 123acd816dcc still applied and let us know whether the Windows install is back to around 7 minutes to first reboot?
Thanks,
Edgar
Quoted 15 lines · Edgar E. Iglesias
Quoted 4 lines · Marek Marczykowski-Górecki
And indeed, reverting it on top of 11.1.3 fixes the issue. I assume that page gets mapped and unmapped a lot (for disk I/O?).
Let me know if some more information is needed, some logs to collect maybe? Or a simplified test case?Hi Marek,
Thanks for bisecting this. We hit the same slowdown and carry a patch that keeps foreign DMA mappings cached after their last user releases them. That lets repeated I/O to the same guest pages reuse the mapping.
I have the patch queued for upstreaming. It’s on the edgar/xen-pvh-fixes branch in my tree.
Quoted 6 lines
3386b77e09xen-mapcache: Keep released DMA mappings cached
https://github.com/edgarigl/qemu/commit/3386b77e09e194ffc921c79f28241de8e5545748Could you try it on QEMU 11.1.3 with
123acd816dccstill applied and let us know whether the Windows install is back to around 7 minutes to first reboot?
Yes, that works too, thanks! You can consider it as my Tested-by.
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab