“零拷贝网络"与“内核绕过"? [英] "zero copy networking" vs "kernel bypass"?

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

问题描述

零拷贝网络"和内核绕过"有什么区别?这两个短语的意思是相同的,还是不同的?内核绕过是零复制网络"中使用的一种技术吗?这就是关系?

What is the difference between "zero-copy networking" and "kernel bypass"? Are they two phrases meaning the same thing, or different? Is kernel bypass a technique used within "zero copy networking" and this is the relationship?

推荐答案

零拷贝网络"有什么区别?和内核绕过"?这两个短语的意思是相同的,还是不同的?内核绕过是零拷贝网络"中使用的一种技术吗?这就是关系?

What is the difference between "zero-copy networking" and "kernel bypass"? Are they two phrases meaning the same thing, or different? Is kernel bypass a technique used within "zero copy networking" and this is the relationship?

TL;DR - 它们是不同的概念,但内核绕过 API/框架很可能支持零拷贝.

TL;DR - They are different concepts, but it is quite likely that zero copy is supported within kernel bypass API/framework.

用户绕过

也应该考虑这种通信方式.DMA-to-DMA 事务可能完全不涉及 CPU.这个想法是使用 splice() 或类似的函数来完全避免 用户空间.注意,使用 splice(),整个数据流不需要绕过用户空间.可以在用户空间中读取标头,并将数据直接流式传输到磁盘.最常见的缺点是 splice() 不执行校验和卸载.

This mode of communicating should also be considered. It maybe possible for DMA-to-DMA transactions which do not involve the CPU at all. The idea is to use splice() or similar functions to avoid user space at all. Note, that with splice(), the entire data stream does not need to bypass user space. Headers can be read in user space and data streamed directly to disk. The most common downfall of this is splice() doesn't do checksum offloading.

零拷贝

零拷贝 的概念只是网络缓冲区固定在适当的位置,不会四处移动.在许多情况下,这并不是真正有益的.大多数现代网络硬件支持分散收集,也称为缓冲区描述符等.其思想是网络硬件理解物理指针.缓冲区描述符通常包括,

The zero copy concept is only that the network buffers are fixed in place and are not moved around. In many cases, this is not really beneficial. Most modern network hardware supports scatter gather, also know as buffer descriptors, etc. The idea is the network hardware understands physical pointers. The buffer descriptor typically consists of,

  1. 数据指针
  2. 长度
  3. 下一个缓冲区描述符

好处是网络标头不需要并排IPTCP存在应用程序标头可以与应用程序数据物理上分开.

The benefit is that the network headers do not need to exist side-by-side and IP, TCP, and Application headers can reside physically seperate from the application data.

如果控制器不支持这一点,则 TCP/IP 标头必须位于 用户数据 之前,以便在发送到 网络控制器.

If a controller doesn't support this, then the TCP/IP headers must precede the user data so that they can be filled in before sending to the network controller.

零拷贝还意味着一些内核用户 MMU 设置,以便共享页面.

zero copy also implies some kernel-user MMU setup so that pages are shared.

内核绕过

当然,你可以绕过内核.这就是 pcap 和其他嗅探器软件一直在做的事情时间.但是,pcap 不会阻止正常的内核处理;但这个概念类似于内核绕过框架所允许的.即,直接将数据包传递到将发生处理标头的用户空间.

Of course, you can bypass the kernel. This is what pcap and other sniffer software has been doing for some time. However, pcap does not prevent the normal kernel processing; but the concept is similar to what a kernel bypass framework would allow. Ie, directly deliver packets to user space where processing headers would happen.

但是,除非与特定的硬件相关联,否则很难看到 用户空间 会获得明确的胜利.某些网络控制器可能在控制器中支持分散聚集,而其他可能不支持.

However, it is difficult to see a case where user space will have a definite win unless it is tied to the particular hardware. Some network controllers may have scatter gather supported in the controller and others may not.

有多种内核接口的化身来完成内核旁路.困难在于接收到的数据和产生用于传输的数据会发生什么.这通常涉及其他设备,因此有很多解决方案.

There are various incarnation of kernel interfaces to accomplish kernel by-pass. A difficulty is what happens with the received data and producing the data for transmission. Often this involve other devices and so there are many solutions.

把这些放在一起......

To put this together...

这两个短语的意思是一样的还是不同的?

Are they two phrases meaning the same thing, or different?

如上希望解释的那样,它们是不同的.

They are different as above hopefully explains.

内核绕过是零拷贝网络"中使用的一种技术吗?这就是关系?

Is kernel bypass a technique used within "zero copy networking" and this is the relationship?

恰恰相反.内核绕过可以使用零拷贝,并且很可能会支持它,因为缓冲区完全在应用程序的控制之下.此外,内核和用户空间之间没有内存共享(这意味着不需要 MMU 共享页面以及可能导致的任何缓存/TLB 影响).所以如果你使用kernel bypass,支持零拷贝往往是有利的;所以一开始可能看起来是一样的.

It is the opposite. Kernel bypass can use zero copy and most likely will support it as the buffers are completely under control of the application. Also, there is no memory sharing between the kernel and user space (meaning no need for MMU shared pages and whatever cache/TLB effects that may cause). So if you are using kernel bypass, it will often be advantageous to support zero copy; so the things may seem the same at first.

如果 scatter-gather DMA 可用(大多数现代控制器),用户空间或内核都可以使用它.零拷贝在这种情况下就没那么有用了.

If scatter-gather DMA is available (most modern controllers) either user space or the kernel can use it. zero copy is not as useful in this case.

参考:

  • Technical reference on OnLoad, a high band width kernel by-pass system.
  • PF Ring as of 2.6.32, if configured
  • Linux kernel network buffer management by David Miller. This gives an idea of how the protocols headers/trailers are managed in the kernel.

这篇关于“零拷贝网络"与“内核绕过"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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