pci_alloc_consistent uncached memory

2019-06-06 07:35发布

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.

E.g. https://www.kernel.org/doc/Documentation/DMA-API.txt in section Part Ia says:

Consistent memory is memory for which a write by either the device or the processor can immediately be read by the processor or device without 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!

1条回答
够拽才男人
2楼-- · 2019-06-06 08:29

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.

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

"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.

查看更多
登录 后发表回答