本文将介绍下NVMe中的Shadow doorbell buffer机制。

Overview


The guest driver only writes to the MMIO register when EventIdx has been reached. This eliminates some MMIO writes.

Identify

可以参考hw/nvme: Implement shadow doorbell buffer support中的NVME_OACS_DBBUF = 1 << 8

Doorbell Buffer Config command

doorbell values are written by the nvme driver (guest OS) and the event index is written by the virtual device (host OS).

The Doorbell Buffer Config admin command is implemented for the guest to enable shadow doobell buffer. When this feature is enabled, each SQ/CQ is associated with two buffers, i.e., Shadow Doorbell buffer and EventIdx buffer. According to the Spec, each queue’s doorbell register is only updated when the Shadow Doorbell buffer value changes from being less than or equal to the value of the corresponding EventIdx buffer entry to being greater than that value. Therefore, the number of MMIO’s on the doorbell registers is greatly reduced.

Updating Controller Doorbell Registers using a Shadow Doorbell Buffer


参考资料:

  1. https://nvmexpress.org/wp-content/uploads/NVM_Express_Revision_1.3.pdf
  2. block/NVMe: introduce a new vhost NVMe host device to QEMU
  3. nvme: improve performance for virtual NVMe devices
  4. Accelerating NVMe I/Os in Virtual Machine via SPDK vhost* Solution
  5. hw/nvme: Add shadow doorbell buffer support
  6. hw/nvme: Implement shadow doorbell buffer support