为什么Linux内核中没有零拷贝网络?

时间:2022-12-31 10:58:47

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:

我想知道为什么linux内核(或任何其他主流操作系统)没有零拷贝网络功能的原因?零拷贝我的意思是,没有复制数据包/数据流以传递给用户空间中的应用程序,例如使用内存池类型的分配器来共享内核和用户空间之间的内存。我自己想出了3个理论:

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 ?

a)我猜有安全问题。但当它们仅用作缓冲区时,是否真的没有办法在用户空间和内核之间安全地共享内存?

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 ?

b)我猜有稳定性问题。但我们不能假设使用零拷贝网络的人,例如需要instanciate和传递内存池为内核调用是否知道内存管理?意识到足以避免泄漏?

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.

c)到目前为止还没有完成/需要。我无法想象没有人要求这个功能,因为每个使用小数据包大小的人通常会受到“慢速”TCP堆栈实施的瓶颈,并且有第三方工具可用于0-copy网络以供特殊用途使用网卡。

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

随意发布任何猜测,但请标记您是否正在假设或更深入了解保持*质量的原因:-)

1 个解决方案

#1


5  

There is 3rd-party zero-copy networking for Linux, it is not a standard feature though.

Linux有第三方零拷贝网络,但它不是标准功能。

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.

注意,使用TCP进行零拷贝可能不方便,因为TCP段承载头和有效负载,但应用程序只关注有效负载,因此必须将有效负载而不是头部复制到应用程序的连续缓冲区中。

#1


5  

There is 3rd-party zero-copy networking for Linux, it is not a standard feature though.

Linux有第三方零拷贝网络,但它不是标准功能。

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.

注意,使用TCP进行零拷贝可能不方便,因为TCP段承载头和有效负载,但应用程序只关注有效负载,因此必须将有效负载而不是头部复制到应用程序的连续缓冲区中。