系统相关
首页 > 系统相关> > 深入理解SPDK: 内存管理

深入理解SPDK: 内存管理

作者:互联网

CPU 内存 物理地址空间会散列 ( interleave between channel/memory controller);

NVME 设备对使用内存物理地址空间的限制:
The NVMe 1.0 specification requires all physical memory to be describable by what is called a PRP list. To be described by a PRP list, memory must have the following properties:

NVME 设备通过DMA传输数据
NVMe devices transfer data to and from system memory using Direct Memory Access (DMA). Specifically, they send messages across the PCI bus requesting data transfers. In the absence of an IOMMU, these messages contain physical memory addresses. These data transfers happen without involving the CPU, and the MMU is responsible for making access to memory coherent.

The memory is broken into physical 4KiB pages, which we'll call device pages.
The first device page can be a partial page starting at any 4-byte aligned address. It may extend up to the end of the current physical page, but not beyond.
If there is more than one device page, the first device page must end on a physical 4KiB page boundary.
The last device page begins on a physical 4KiB page boundary, but is not required to end on a physical 4KiB page boundary.

The specification allows for device pages to be other sizes than 4KiB, but all known devices as of this writing use 4KiB.

用户态的程序(SPDK)使用户态的地址,而nvme 设备需要使用物理地址,因此需要实现这两个地址之间的转换(映射)。

可以考虑的方法:

虽然这并非内核刻意的设计,但内核对huge page的处理不同于传统4KB page的处理,kernel 从不回改变它对应的物理内存的位置。

在没有IOMMU的情况下,上面通过huge page 申请到的虚拟地址还是需要通过转换成物理地址。
MMU:mem virtual address <----> physical address of memory
IOMMU: pci bus address of nvme device buffer/cache <----> buffer virtual address
数据交换: mem virtual address <=====> buffer virtual address

标签:4KiB,address,SPDK,深入,内存,memory,device,page,physical
来源: http://blog.51cto.com/xiamachao/2349968