From 3da2ef9deaec061887e8bef5a8e302e8509c8a8c Mon Sep 17 00:00:00 2001 From: Manohar Castelino Date: Mon, 25 Sep 2017 16:30:56 -0700 Subject: [PATCH] QEMU: Knobs: Huge Page Support: Add support for huge pages Add support to launch virtual machines where the RAM is allocated using huge pages. This is useful for running with a user mode networking stack, and for custom setups which require high performance and low latency. Signed-off-by: Manohar Castelino --- qemu.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/qemu.go b/qemu.go index 66bf21ebc3..364f291be9 100644 --- a/qemu.go +++ b/qemu.go @@ -768,6 +768,16 @@ type Knobs struct { // Daemonize will turn the qemu process into a daemon Daemonize bool + // Both HugePages and MemPrealloc require the Memory.Size of the VM + // to be set, as they need to reserve the memory upfront in order + // for the VM to boot without errors. + // + // HugePages always results in memory pre-allocation. + // However the setup is different from normal pre-allocation. + // Hence HugePages has precedence over MemPrealloc + // HugePages will pre-allocate all the RAM from huge pages + HugePages bool + // MemPrealloc will allocate all the RAM upfront MemPrealloc bool @@ -1025,7 +1035,19 @@ func (config *Config) appendKnobs() { config.qemuParams = append(config.qemuParams, "-daemonize") } - if config.Knobs.MemPrealloc == true { + if config.Knobs.HugePages == true { + if config.Memory.Size != "" { + dimmName := "dimm1" + objMemParam := "memory-backend-file,id=" + dimmName + ",size=" + config.Memory.Size + ",mem-path=/dev/hugepages,share=on,prealloc=on" + numaMemParam := "node,memdev=" + dimmName + + config.qemuParams = append(config.qemuParams, "-object") + config.qemuParams = append(config.qemuParams, objMemParam) + + config.qemuParams = append(config.qemuParams, "-numa") + config.qemuParams = append(config.qemuParams, numaMemParam) + } + } else if config.Knobs.MemPrealloc == true { if config.Memory.Size != "" { dimmName := "dimm1" objMemParam := "memory-backend-ram,id=" + dimmName + ",size=" + config.Memory.Size + ",prealloc=on"