3 ms·
Having written device drivers before, the first thing I wondered was how he allocated a fixed region of physical memory in user space... "In kernel space there
by cesarb 8y ago
Having written device drivers before, the first thing I wondered was how he allocated a fixed region of physical memory in user space...
"In kernel space there is an API to allocate DMA memory, in user space we have to use other mechanisms since this API is not available here. To disable swapping, we can use mlock(2). [...] However, mlock(2) only ensures that the page is kept in memory. The kernel is still able to move pages to different physical addresses. To circumvent this problem, we use huge pages with a size of 2 MiB. These pages cannot be migrated yet by the Linux kernel, thus stay resident in physical memory."
He didn't, he's depending on an implementation quirk which might change in the future (and also depending on the physical memory backing huge pages being in a region which can be reached by the network device through DMA, though that's probably always true on x86 when memory encryption is not in use).
- sk_hazratali 8y agohttps://www.sherekhudahazratali.com/2018/11/noor-wala-aya-hai-lyrics.html https://www.sherekhudahazratali.com/2018/11/noor-wala-aya-ha...
- codingbeer 8y agoDPDK also relies on this quirk if there is no IOMMU available. He does mention the IOMMU as future work, but in the context of security.
- deepsun 8y agoWell, Linus is obsessed with "don't break userspace", so as long as there is N > 0 users who use that implementation detail, it will stay forever and become documented limitation of Linux kernel :(