|
|
Log in / Subscribe / Register

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

In order for GC to work, the application has to somehow know whether the kernel is still using the buffer (since the GC cannot descend into kernel memory and trace pointers directly). Therefore, you need some sort of completion mechanism like the one described in this patch in order to notify the GC of that fact. Once that mechanism exists, sure, you can hook it up to a GC or anything else you want, because userspace can manage these buffers in whatever manner it likes.

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.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds