简体   繁体   English

在 /proc/mtrr 和 /proc/iomem 中识别 DMA 内存?

[英]Identify DMA memory in /proc/mtrr and /proc/iomem?

I wonder if there is a way to identify memory used for DMA mapping in some proc files, such as mtrr and iomem , or via lspic -vv .我想知道是否有一种方法可以识别某些 proc 文件中用于 DMA 映射的内存,例如mtrriomem ,或者通过lspic -vv

In my /proc/mtrr , there is only one uncachable region, and it seems to be pointing at the 'PCI hole' at 3.5-4GB, almost.在我的/proc/mtrr ,只有一个uncachable区域,它似乎几乎指向 3.5-4GB 的“PCI 孔”。

base=0x0e0000000 ( 3584MB), size=  512MB, count=1: uncachable

By cross verifying with /proc/iomem , of this 512MB region, only the last 21 MB before 4GB is NOT consumed by PCI Bus, and that 21MB sliver is occupied by things like pnp/IOAPIC/Reserved .通过与/proc/iomem交叉验证,在这个 512MB 区域中,只有 4GB 之前的最后 21 MB 不被 PCI 总线消耗,并且 21MB 的细长条被pnp/IOAPIC/Reserved类的东西占用。

So my questions are:所以我的问题是:

  1. What is the signature of DMA region in /proc/mtrr and /proc/iomem /proc/mtrr/proc/iomem中 DMA 区域的签名是什么
  2. Are there other places, such as other proc files and commands that I can use to see DMA region?是否有其他地方,例如其他 proc 文件和命令可用于查看 DMA 区域?
  3. It seems by adding rows to /proc/mtrr , a privileged user can change caching mechanism of any memory, at runtime.似乎通过向/proc/mtrr添加行,特权用户可以在运行时更改任何内存的缓存机制。 So besides the fact that DMA has to be lower 32bit(assuming without DAC), are there other special requirement for DMA memory allocation?那么除了DMA必须低于32位(假设没有DAC)之外,DMA内存分配还有其他特殊要求吗? If there are no further requirment, then maybe the only hint I can use to identify DMA memory would be /proc/mtrr ?如果没有进一步的要求,那么我可以用来识别 DMA 内存的唯一提示可能是/proc/mtrr

DMA (Direct Memory Access) is just where a device accesses memory itself (without asking CPU to feed the data to the device). DMA(直接内存访问)只是设备访问内存本身的地方(不要求 CPU 将数据提供给设备)。 For a (simplified) example of DMA;对于 DMA 的(简化的)示例; imagine a random process does a write() , and this bubbles its way up (through VFS, through file system, through any RAID layer, etc) until it reaches some kind of disk controller driver;想象一个随机进程执行write() ,并且这会向上冒泡(通过 VFS、通过文件系统、通过任何 RAID 层等),直到它到达某种磁盘控制器驱动程序; then the disk controller driver tells its disk controller "transfer N bytes from this physical address to that place on the disk and let me know when the transfer has been done".然后磁盘控制器驱动程序告诉它的磁盘控制器“将 N 个字节从这个物理地址传输到磁盘上的那个位置,并在传输完成时通知我”。 Most devices (disk controllers, network cards, video cards, sound cards, USB controllers, ...) use DMA in some way.大多数设备(磁盘控制器、网卡、显卡、声卡、USB 控制器等)都以某种方式使用 DMA。 Under load, all the devices in your computer may be doing thousands of transfers (via. DMA) per second, potentially scattered across all usable RAM.在负载下,您计算机中的所有设备可能每秒进行数千次传输(通过 DMA),可能分散在所有可用的 RAM 中。

As far as I know;据我所知; there are no files in /proc/ that would help (most likely because it changes too fast and too often to bother providing any, and there'd be very little reason for anyone to ever want to look at it). /proc/没有可以提供帮助的文件(很可能是因为它更改得太快且太频繁而无法提供任何文件,并且几乎没有任何人想要查看它)。

The MTTRs are mostly irrelevant - they only control the CPU's caches and have no effect on DMA requests from devices. MTTR 大多无关紧要——它们只控制 CPU 的缓存,对来自设备的 DMA 请求没有影响。

The /proc/iomem is also irrelevant. /proc/iomem也无关紧要。 It only shows which areas devices are using for their own registers and has nothing to do with RAM (and therefore has nothing to do with DMA).它只显示设备用于自己的寄存器的区域,与 RAM 无关(因此与 DMA 无关)。

Note 1: DMA doesn't have to be in the lower 32-bit (eg most PCI devices have supported 64-bit DMA/bus mastering for a decade or more);注 1:DMA 不必处于较低的 32 位(例如,大多数 PCI 设备已经支持 64 位 DMA/总线主控十年或更长时间); and for the rare devices that don't support 64-bit it's possible for Linux to use an IOMMU to remap their requests (so the device thinks it's using 32-bit addresses when it actually isn't).对于不支持 64 位的罕见设备,Linux 可以使用 IOMMU 来重新映射它们的请求(因此设备认为它正在使用 32 位地址,而实际上并非如此)。

Note 2: Once upon a time (a long time ago) there were "ISA DMA controller chips".注2:曾几何时(很久以前)有“ISA DMA 控制器芯片”。 Like the ISA bus itself;就像ISA总线本身一样; these were restricted to the first 16 MiB of the physical address space (and had other restrictions - eg not supporting transfers that cross a 64 KiB boundary).这些仅限于物理地址空间的前 16 MiB(并且还有其他限制 - 例如不支持跨越 64 KiB 边界的传输)。 These chips haven't really had a reason to exist since floppy disk controllers became obsolete.自从软盘控制器过时,这些芯片就没有真正存在的理由。 You might have a /proc/dma describing these (but if you do it probably only says "cascade" to indicate how the chips connect, with no devices using them).你可能有一个/proc/dma描述这些(但如果你这样做,它可能只会说“级联”来指示芯片如何连接,没有设备使用它们)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM