Zero-copy network transmission with io_uring
Zero-copy network transmission with io_uring
Posted Dec 31, 2021 21:47 UTC (Fri) by NYKevin (subscriber, #129325)In reply to: Zero-copy network transmission with io_uring by Wol
Parent article: Zero-copy network transmission with io_uring
Alternatives:
* The kernel calls free or something similar to free for you. But malloc (or tcmalloc, or whatever you're using to allocate memory) is a black box from the kernel's perspective, because it lives in userspace, and the only way the kernel can plausibly invoke it is to either inject a thread (shudder) or preempt an existing thread and borrow its stack. You end up with all of the infelicities of signal handlers, which notoriously cannot allocate or free memory because malloc and free are usually not reentrant. That means your "something similar to free" just ends up being a more elaborate and complicated version of exactly the same completion mechanism, and userspace still has to do the actual memory management itself.
* The buffer is mmap'd, and the kernel unmaps it for you when it's done. There are performance issues here; mmap simply cannot compete with a highly optimized userspace malloc, assuming the workload is reasonably compatible with the latter. However, this does at least have the advantage of being *possible* without ridiculous "let's inject a thread" tricks. But since the whole point of zero-copy is to improve performance, that's probably not enough.
