跳至主要內容

DPDK Ring and ivshmem

LincZero大约 1 分钟

DPDK Ring and ivshmem

DPDK Ring

DPDK Ring提供了一个FIFO无锁队列,支持丰富的队列操作,比如

  • Multi-consumer or single-consumer dequeue
  • Multi-producer or single-producer enqueue
  • Bulk dequeue - Dequeues the specified count of objects if successful; otherwise fails
  • Bulk enqueue - Enqueues the specified count of objects if successful; otherwise fails
  • Burst dequeue - Dequeue the maximum available objects if the specified count cannot be fulfilled
  • Burst enqueue - Enqueue the maximum available objects if the specified count cannot be fulfilled

![dpdk ring enqueue](05. Ring和共享内存.assets/ring-structure.svg)

图片来源Ring Library - dpdk.orgopen in new window

ivshmem

ivshmem则通过把内存映射成虚拟机PCI设备提供了虚拟机间(host-to-guest or guest-to-guest)共享内存的机制。

![Typical ivshmem use case](05. Ring和共享内存.assets/typical-ivshmem-use-case.png)

图片来源DPDK IVSHMEM Libraryopen in new window

DPDK ivshmem:

![DPDK nics](05. Ring和共享内存.assets/dpdk-nics.jpeg)

图片来源使用OVS DPDK (by quqi99)open in new window

ivshmem使用示例

# on the host
mount tmpfs /dev/shm -t tmpfs -osize=32m
ivshmem_server -m 64 -p/tmp/nahanni &

# start VM
qemu-system-x86_64  -hda mg -L /pc-bios/ --smp 4 –chardev socket,path=/tmp/nahanni,id=nahanni-device ivshmem,chardev=nahanni,size=32m,msi=off -serial telnet:0.0.0.0:4000,server,nowait,nodelay-enable-kvm&

# inside VM
modprobe kvm_ivshmem
cat/proc/devices | grep kvm_ivshmem
mknod-mode=666 /dev/ivshmem c 245 0

参考文档