Define hugepages in qemu using ubuntu without libvirt

Viewed 601

I am using qemu, with kvm and I load ubuntu 18.04 image, the qemu is loaded with the following command:

qemu-system-x86_64 -boot c -m 16G -smp 4 -vnc :0 -enable-kvm -drive if=virtio,file=ubuntu.qcow2,cache=none

I don't use libvirt.

I need to change hugepages from the default 2048kb to 1GB. I configured my host vm to support this size

Configuration:

cat /proc/meminfo | grep Huge
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:      13
HugePages_Free:       13
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB
Hugetlb:        13631488 kB

and in the ubuntu, I configured /etc/default/grub and added GRUB_CMDLINE_LINUX="default_hugepagesz=1G hugepagesz=1G hugepages=40” and then run

grub-mkconfig -o /boot/grub/grub.cfg 

Execution: after qemu was loaded, in the terminal I run the following commands:

cat /proc/meminfo | grep Huge 
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
**Hugepagesize:       2048 kB**

cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-4.15.0-137-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro default_hugepagesz=1G hugepagesz=1G hugepages=40 maybe-ubiquity

Does anyone have an idea how to define the huge pages to be 1gb in this configuration?

1 Answers

I solved the issue. in qemu-system-x86_64 you can write -cpu help and then you can see all supported cpus and additional flags. in my case I added '-cpu qemu64,pdpe1gb' and then qemu supports huge pages

Related