Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why no zero-copy networking in linux kernel? [closed]

I'd like to know the reasons for why the linux kernel (or any other mainstream OS) does not have a feature for zero copy networking ? By zero copy I mean, that an packet/datastream does not get copied for passing to an application in userspace but e.g. uses a memory-pool type of allocator to share the memory between kernel and userspace. I've came up with 3 theory's on my own:

a) I guess there are security concerns. But is there really no way of making memory shared securily between userspace and kernel when they are just used as a buffer ?

b) I guess there are stability concerns. But can't we assume that whoever uses zero-copy networking and e.g. needs to instanciate and pass a memory-pool for the kernel call is aware of memory management? Aware enough to avoid leaks ?

c) It just haven't been done/needed so far. I can't really imagine that nobody requested this feature, as everybody who is using small packet sizes is typically bottlenecked by the "slow" TCP-stack implementation and there are 3rd party tools out there offered for 0-copy networking for usage with special network cards.

Feel free to post any guesses, but please mark whether you are assuming or have a deeper knowledge of the reasons to keep StackOverflow-quality :-)

like image 981
user1610743 Avatar asked Mar 03 '14 14:03

user1610743


People also ask

How does DPDK bypass kernel?

OVS-DPDK moves the OVS kernel data path into userspace. Frames are then retrieved directly from the NIC using a poll mode driver (PMD), allowing us to bypass the kernel. With the frame and the VNF both now within userspace, further techniques can be used to move the frame between OVS and the VNF, such as vHost User.

What is zero copy in Linux?

"Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another or in which unnecessary data copies are avoided.

What is TCP zero copy?

The TCP Zero-copy API is intended to assist the development of higher-performance embedded network applications by allowing the application direct access to the TCP/IP stack packet buffers.


1 Answers

There are a few options nowadays for zero-copy networking:

  • PF_RING ZC (Zero Copy).
  • Linux native zero-copy TCP.
  • Intel Data Plane Development Kit.
  • OpenOnload for proprietary hardware.

Note, that zero-copy with TCP may be inconvenient, because TCP segments carry headers and payload, but applications are only concerned with payload, so that payload but not headers must be copied into a contiguous buffer for your application.

like image 189
Maxim Egorushkin Avatar answered Oct 02 '22 22:10

Maxim Egorushkin