HeadlinesBriefing favicon HeadlinesBriefing.com

TCP Zero-Copy Mechanics in Linux Kernel Explained

Hacker News •
×

Linux kernel's TCP zero-copy feature fundamentally reduces network data copying overhead by directly referencing userspace buffers in kernel structures. The MSG_ZEROCOPY flag in the sendmsg() syscall, added in 2017, allows data to bypass kernel copies when sending. This relies on scatter-gather DMA support in network hardware. io_uring later integrated zero-copy send operations in 2022, adding asynchronous notifications.

The receive side is more complex, requiring hardware features like TCP header split and specialized memory registration via io_uring_register_ifq or netlink commands. Crucially, flow steering must ensure packets hit the correct receive queue, and data arrives in arbitrary memory chunks. Support for device memory buffers, like GPU or storage memory, arrived in September 2024, using dma-buf file descriptors registered via io_uring or netlink.