为什么Linux内核中没有零拷贝网络? [英] Why no zero-copy networking in linux kernel?

查看:179
本文介绍了为什么Linux内核中没有零拷贝网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道linux内核(或任何其他主流操作系统)为何不具有零拷贝联网功能的原因?零拷贝是指数据包/数据流不会被复制以传递给用户空间中的应用程序,例如使用内存池类型的分配器在内核空间和用户空间之间共享内存.我自己提出了三种理论:

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)我猜有安全方面的顾虑.但是,当用户空间和内核仅用作缓冲区时,真的没有办法使它们在用户空间和内核之间安全地共享吗?

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)我认为存在稳定性问题.但是我们不能假设谁使用零拷贝网络和需要实例化并通过一个内存池,以便内核调用知道内存管理吗?知道足以避免泄漏吗?

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)到目前为止,尚未完成/不需要.我真的无法想象没有人要求此功能,因为每个使用小数据包大小的人通常都会受到慢速" TCP堆栈实现的瓶颈,并且提供了第三方工具可用于0副本网络,可与特殊功能一起使用网卡.

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.

可以随意发表任何猜测,但请注明您是假设还是更深入地了解保持StackOverflow-quality的原因:-)

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 :-)

推荐答案

如今,零复制网络有一些选择:

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.

请注意,使用TCP进行零复制可能很不方便,因为TCP段带有标头和有效负载,但是应用程序仅关注有效负载,因此必须将有效负载但标头不复制到应用程序的连续缓冲区中.

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.

这篇关于为什么Linux内核中没有零拷贝网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆