Give hugepage memory for guests in KVM virtualization

[root@humbles-lap qemu_upstream]# cat /proc/meminfo |grep -i huge
AnonHugePages:    434176 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB  ======; 2M
[root@humbles-lap qemu_upstream]#
 
[root@humbles-lap qemu_upstream]# sysctl -a |grep -i huge
vm.nr_hugepages = 0
vm.nr_hugepages_mempolicy = 0
vm.hugetlb_shm_group = 0
vm.hugepages_treat_as_movable = 0
vm.nr_overcommit_hugepages = 0
 
My guest have '512M' of memory , so I decided to give <strong>"256" ( total 256*2M=512) as the number of hugepages
 
[root@humbles-lap qemu_upstream]# sysctl vm.nr_hugepages=256
vm.nr_hugepages = 256
[root@humbles-lap qemu_upstream]#
 
[root@humbles-lap qemu_upstream]# sysctl -a |grep -i huge
vm.nr_hugepages = 256
vm.nr_hugepages_mempolicy = 256
vm.hugetlb_shm_group = 0
vm.hugepages_treat_as_movable = 0
vm.nr_overcommit_hugepages = 0
[root@humbles-lap qemu_upstream]#
 
So, hugepage assignment reflected here:
 
[root@humbles-lap qemu_upstream]# cat /proc/meminfo |grep -i huge
AnonHugePages:    450560 kB
HugePages_Total:     256
HugePages_Free:      256
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
[root@humbles-lap qemu_upstream]#
 
Once you assigned hugepages, you need to restart 'libvirtd" service...
 
[root@humbles-lap hpages]# service libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
[root@humbles-lap hpages]#
 
Check mount point for 'existence' of a directory as shown below:
 
[root@humbles-lap qemu_upstream]# cd /dev/hpages/
[root@humbles-lap hpages]# ls
libvirt
[root@humbles-lap hpages]# cd libvirt/
[root@humbles-lap libvirt]# ls
qemu
[root@humbles-lap libvirt]# cd qemu/
[root@humbles-lap qemu]# ls
[root@humbles-lap qemu]#
With the current configuration, I have NOT specified to have 'hugepage' backed memory for my guest..
 
[root@humbles-lap qemu_upstream]# cat /etc/libvirt/qemu/rhel5.4-x86_64-kvm.xml |grep -i memory
memory;524288/memory;
currentMemory;524288/currentMemory;
[root@humbles-lap qemu_upstream]#
 
I edited my guest xml configuration to say, this guest memory is backed with "HUGEPAGES"..
 
[root@humbles-lap qemu_upstream]# cat /etc/libvirt/qemu/rhel5.4-x86_64-kvm.xml|grep -i memory -A 2
memory;524288/memory;
currentMemory;524288/currentMemory;
;memoryBacking;
    hugepages/;
  /memoryBacking;
vcpu;2/vcpu;
os;
[root@humbles-lap qemu_upstream]#
 
Started guest:
 
[root@humbles-lap qemu_upstream]# virsh create /etc/libvirt/qemu/rhel5.4-x86_64-kvm.xml
Domain rhel5.4-x86_64-kvm created from /etc/libvirt/qemu/rhel5.4-x86_64-kvm.xml
 
[root@humbles-lap qemu_upstream]# virsh list
Id Name                 State
----------------------------------
1 rhel5.4-x86_64-kvm   running
 
[root@humbles-lap qemu_upstream]#
 
Now, check 'meminfo' in HOST system to know whether "HUGEPAGES" are used with GUESTS..
 
[root@humbles-lap qemu_upstream]# cat /proc/meminfo |grep -i huge
AnonHugePages:    483328 kB
HugePages_Total:     256
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
[root@humbles-lap qemu_upstream]#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值