Skip to contentSkip to conversation

i386: load kernel on xen using DMA

PATCH In review Marek Marczykowski-Górecki 3 participants 4 messages Apr 26, 2021 – Mar 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386: load kernel on xen using DMA

Kernel on Xen is loaded via fw_cfg. Previously it used non-DMA version, which loaded the kernel (and initramfs) byte by byte. Change this to DMA, to load in bigger chunks.
This change alone reduces load time of a (big) kernel+initramfs from ~10s down to below 1s.

This change was suggested initially here:
https://lore.kernel.org/xen-devel/[email protected]/
Apparently this alone is already enough to get massive speedup.

---
 hw/i386/pc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/pc.c +2 -1
index 8a84b25a03..14e43d4da4 100644
@@ -839,7 +839,8 @@ void xen_load_linux(PCMachineState *pcms)
 
     assert(MACHINE(pcms)->kernel_filename != NULL);
 
-    fw_cfg = fw_cfg_init_io(FW_CFG_IO_BASE);
+    fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
+                                &address_space_memory);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus);
     rom_set_fw(fw_cfg);
 
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Marek Marczykowski-Górecki

Kernel on Xen is loaded via fw_cfg. Previously it used non-DMA version, which loaded the kernel (and initramfs) byte by byte. Change this to DMA, to load in bigger chunks.
This change alone reduces load time of a (big) kernel+initramfs from ~10s down to below 1s.

This change was suggested initially here:
https://lore.kernel.org/xen-devel/[email protected]/
Apparently this alone is already enough to get massive speedup.

---
 hw/i386/pc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/pc.c +0 -0
index 8a84b25a03..14e43d4da4 100644

hw/i386/pc.c void xen_load_linux(PCMachineState *pcms) · line 845

Quoted 8 lines
hw/i386/pc.c +2 -1
@@ -839,7 +839,8 @@ void xen_load_linux(PCMachineState *pcms)
 
     assert(MACHINE(pcms)->kernel_filename != NULL);
 
-    fw_cfg = fw_cfg_init_io(FW_CFG_IO_BASE);
+    fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
+                                &address_space_memory);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus);
     rom_set_fw(fw_cfg);

Gentle ping. The fix looks perfectly sane to me but I don't have any x86 Xen HW to test this one. Are the x86 maintainers happy to take this on?

FWIW:

Signature · 1 line
Alex Bennée
#2 lore raw
Quoted 26 lines · Alex Bennée
Quoted 23 lines · Marek Marczykowski-Górecki

Kernel on Xen is loaded via fw_cfg. Previously it used non-DMA version, which loaded the kernel (and initramfs) byte by byte. Change this to DMA, to load in bigger chunks.
This change alone reduces load time of a (big) kernel+initramfs from ~10s down to below 1s.

This change was suggested initially here:
https://lore.kernel.org/xen-devel/[email protected]/
Apparently this alone is already enough to get massive speedup.

---
 hw/i386/pc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/pc.c +0 -0
index 8a84b25a03..14e43d4da4 100644
@@ -839,7 +839,8 @@ void xen_load_linux(PCMachineState *pcms)
 
     assert(MACHINE(pcms)->kernel_filename != NULL);
 
Quoted 8 lines

hw/i386/pc.c void xen_load_linux(PCMachineState *pcms) · line 845

Quoted 5 lines
hw/i386/pc.c +2 -1
-    fw_cfg = fw_cfg_init_io(FW_CFG_IO_BASE);
+    fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
+                                &address_space_memory);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus);
     rom_set_fw(fw_cfg);

Gentle ping. The fix looks perfectly sane to me but I don't have any x86 Xen HW to test this one. Are the x86 maintainers happy to take this on?

Ping...

Quoted 8 lines

FWIW:

Signature · 1 line
Alex Bennée
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Reviewed-by
#3 lore raw
In reply to Alex Bennée
Quoted 26 lines · Alex Bennée
Quoted 23 lines · Marek Marczykowski-Górecki

Kernel on Xen is loaded via fw_cfg. Previously it used non-DMA version, which loaded the kernel (and initramfs) byte by byte. Change this to DMA, to load in bigger chunks.
This change alone reduces load time of a (big) kernel+initramfs from ~10s down to below 1s.

This change was suggested initially here:
https://lore.kernel.org/xen-devel/[email protected]/
Apparently this alone is already enough to get massive speedup.

---
 hw/i386/pc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/pc.c +0 -0
index 8a84b25a03..14e43d4da4 100644
@@ -839,7 +839,8 @@ void xen_load_linux(PCMachineState *pcms)
 
     assert(MACHINE(pcms)->kernel_filename != NULL);
 
Quoted 8 lines

hw/i386/pc.c void xen_load_linux(PCMachineState *pcms) · line 845

Quoted 5 lines
hw/i386/pc.c +2 -1
-    fw_cfg = fw_cfg_init_io(FW_CFG_IO_BASE);
+    fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
+                                &address_space_memory);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus);
     rom_set_fw(fw_cfg);

Gentle ping. The fix looks perfectly sane to me but I don't have any x86 Xen HW to test this one. Are the x86 maintainers happy to take this on?

Yes. It looks like it works well with both SeaBIOS and OVMF, so the patch is good.

Quoted 3 lines

FWIW:

Thanks,

Signature · 1 line
Anthony PERARD