天天看点

qemu numa nodes passthrough

 有办法pass host的node到guest node去

 这个可以通过hugetlbfs

 qemu memory backend 有两种

 通常是ram_backend_memory_alloc

 有找到點了?

 另外一种是file_backend_memory_alloc

 mmap直接map到那个file上

 如果准备好hugetlbfs

 mmap就过去了

 所以说, 如果有两个nodes

 一个通过hugetlbfs 从一个numa node中取memory

 一个通过hugetlbfs 从另一个numa node中取memory

 了解了,有趣

 所以是系統先做好兩個file, 分別對應到兩個nodes

 再把这两个nodes pass 给guest, 做为两个guest numa nodes

 然後qemu再去map

 对了

 接有意思

 挺

 對啊

 这样就可以把host nunam,

 这样就可以把host numa node memory 给它pass 到guest了

 不过应该很少用

 qemu_anon_ram_alloc

 最後call到這裡來

 mmap

 應該沒錯?

 没错, 那个是普通的方式

 我看到s390有定義自己的

 其他都是用這個

 回家看清楚點在和你討論

 嗯, 好的

 -object memory-backend-ram,size=1024M,policy=bind,host-nodes=0,id=ram-node0 -numa node,nodeid=0,cpus=0,memdev=ram-node0

 -object memory-backend-ram,size=1024M,policy=bind,host-nodes=1,id=ram-node1 -numa node,nodeid=1,cpus=1,memdev=ram-node1

 比如这就是一个特别的方式

 ha,,  看来不用hugetlbfs也得, host_memory_backend_memory_complete 里面它动了手脚

 mbind  在 #ifdef CONFIG_NUMA 下面

  每个memory-backend-ram初始化完毕, 这个host_memory_backend_memory_complete都会跑一次

 之前mmap的virtual memory还没有给physical frame呢, 所以还没真用哪一个numa node的memory

 这段代码先mbind一下, 然后preallocate

mbind針對mem region,如果每個region都是模擬成一個node,設好了以後就不會變了

 通过hugetlbfs >> -object memory-backend-file,id=ram0,size=1G,mem-path=/dev/hugepages/hugetlbfs-16M -numa node,nodeid=0,cpus=0,memdev=ram0

An example qemu cmd with explicit host bridge definition,

./x86_64-softmmu/qemu-system-x86_64 -enable-kvm -m 2048M -smp 4 \

    -object memory-backend-ram,size=1024M,policy=bind,prealloc=on,host-nodes=0-1,id=ram-node0 \

    -numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \

    -object memory-backend-ram,size=1024M,policy=bind,prealloc=on,host-nodes=1,id=ram-node1 \

    -numa node,nodeid=1,cpus=2-3,memdev=ram-node1 \

    -device pxb,id=bridge1,bus=pci.0,numa_node=1,bus_nr=4 \

    -device pxb,id=bridge2,bus=pci.0,numa_node=0,bus_nr=8 \

    -device pxb,id=bridge3,bus=pci.0,bus_nr=16,bus=pci.0 \

    -drive if=none,id=drive0,file=../trusty-server-cloudimg-amd64-disk1.img \

    -device virtio-blk-pci,drive=drive0,scsi=off,bus=bridge3 \

    -nographic

继续阅读