consistent未缓存的内存

consistent未缓存的内存

本文介绍了pci_alloc_consistent未缓存的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以公平地说,pci_alloc_consistent分配了一个连续的非缓存,非分页的内核内存块.我问的原因是我在某些内核/驱动程序代码中看到了此注释(不是在原始内核源代码中),并且我认为我理解内存是连续的,但是不确定是否将其分配为非缓存的,因为缓存一致性的想法是保持缓存中的数据与DMA内存一致.

Is it fair to say that pci_alloc_consistent allocates a contiguous non-cached, non-paged kernel memory chunk. The reason I'm asking is that I saw this comment in some kernel/driver code (not in vanilla kernel sources), and I think I understand that the memory is presented as contiguous, however not sure that it's allocated non-cached, because the idea of cache coherency is to maintain data in the cache and DMA memory consistent.

此外,不确定为什么他们将其称为非分页的.

Also, not sure why they call it non-paged.

例如 https://www.kernel.org/doc/Documentation/DMA-API.txt Part Ia部分中说:

一致性存储器是指设备或设备对其进行写操作的存储器处理器或设备可以立即读取处理器不必担心缓存效果.

Consistent memory is memory for which a write by either the device orthe processor can immediately be read by the processor or devicewithout having to worry about caching effects.

所以不能推断出内存是未缓存的,所以我倾向于认为我看到的评论有些误导.

So one can't infer that the memory is non-cached, so I tend to think that comments I saw are somewhat misleading.

我希望能收到有用的评论.谢谢!

I would appreciate to get useful comments. Thanks!

推荐答案

在x86上,缓存是DMA一致性的(这要求缓存控制器监听所有DMA流量),因此一致的内存就是普通(缓存)内存.

On x86, the caches are DMA-coherent (which requires that the cache controller snoops all DMA traffic), so consistent memory is just normal (cached) memory.

在大多数其他体系结构上,缓存不是DMA一致性的,因此pci_alloc_consistent()必须分配非缓存的内存.

On most other architectures, caches are not DMA-coherent, so pci_alloc_consistent() must allocate non-cached memory.

非分页"表示不能将内存交换到磁盘.但是,这是Windows驱动程序编写者会关心的事情.普通的Linux内核分配函数都没有返回可交换内存.

"Non-paged" means that the memory cannot be swapped to disk. However, this is something that a Windows driver writer would care about; none of the normal Linux kernel allocation function returns swappable memory.

这篇关于pci_alloc_consistent未缓存的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 07:26