在IRQ合并之前,NAPI有哪些优势? [英] What are the advantages NAPI before the IRQ Coalesce?

查看:99
本文介绍了在IRQ合并之前,NAPI有哪些优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,有两种方法可以避免高负载网络中的某些硬件中断开销,当硬件中断太多时,切换到它们会花费太多时间.这对于性能和程序风格的选择方法非常重要.

As known there are two approach to avoid some overheads of hardware interrupts in highload networks, when there are too many hardware interrupts, that switching to them takes too much time. It is very important for performance and choosing approach of programm style.

  1. NAPI(新API)-不使用硬件中断 ,并且每隔一定时间轮询以太网设备.默认情况下,Linux内核使用中断驱动模式,并且仅在传入数据包的流量超过特定阈值时才切换到轮询模式.
  1. NAPI (New API) - Does not use hardware interrupts, and polls the Ethernet-device every certain period of time. The Linux kernel uses the interrupt-driven mode by default and only switches to polling mode when the flow of incoming packets exceeds a certain threshold.

http://en.wikipedia.org/wiki/New_API 内核可以定期 检查以检查传入的网络数据包是否到达 中断,从而消除了中断处理的开销.

http://en.wikipedia.org/wiki/New_API The kernel can periodically check for the arrival of incoming network packets without being interrupted, which eliminates the overhead of interrupt processing.

  1. 中断合并-使用硬件中断,但是如果发生中断,然后禁用中断并在特定时间段内开始投票,之后进行轮询终止并激活中断.
  1. Interrupt coalescing - Uses hardware interrupts, but if interrupt occur, then disables interrupt and starts poll, for certain period of time, after which the polling is terminated and the interrupt is activated.

https://en.wikipedia.org/wiki/Interrupt_coalescing 一种技术 通常会触发硬件中断的事件是 保留,或者直到一定数量的工作待处理,或者 超时计时器触发器.

https://en.wikipedia.org/wiki/Interrupt_coalescing a technique in which events which would normally trigger a hardware interrupt are held back, either until a certain amount of work is pending, or a timeout timer triggers.

这两种方法的中断成本均不高-这是默认中断驱动模式的优势.

Both approaches have not significant costs of interruption - this is advantage befor default interrupt-driven mode.

但是第二种方法-中断合并更合理,因为它是:

But the second approach - Interrupt coalescing is more rational because it:

  • 更少的延迟-程序包到达后,立即尝试处理它,立即发生中断,或者如果最近发生了中断,则对它进行轮询.相反的NAPI不会立即处理该帧,但是将等待一段时间以进行下一次轮询.

  • Less latency - Once the package arrived, immediately tries to handle it immediately interrupt occurs or poll it if the interrupt has occurred recently. Opposite NAPI will not process the frame immediately, but will wait certain period of time for the next poll.

CPU使用率降低-仅在至少有一个数据包到达时才开始轮询.但是,即使没有收到帧,也没有像NAPI那样徒劳地进行轮询.

Less CPU usage - Starts the poll only if at least one packet has already come. But is not doing a poll in vain, even if frames has not received, as if it did NAPI.

IRQ合并之前NAPI有哪些优势?

What are the advantages NAPI before the IRQ Coalesce?

推荐答案

我将NAPI视为中断合并的一种形式.我认为您的问题可能源于对NAPI的误解.首先,NAPI涉及到中断.而且,NAPI的轮询实际上不是徒劳的".请记住,对于NAPI,想法是高吞吐量的流量是突发性的. NAPI仅在数据包收到中断"发生后才启动".

I view NAPI as a form of interrupt coalescing. I think your question may stem from a misunderstanding about NAPI. First of all, interrupts are involved with NAPI. Also, NAPI's polling is actually not "in vain". Remember, for NAPI, the idea is that high throughput traffic is bursty. NAPI only "starts" after an "packet received interrupt" happens.

以下是应该如何使用NAPI的快速概述:

Here's a quick overview of how NAPI is supposed to be used:

内核启动已收到数据包"中断,使用NAPI的网络设备驱动程序会检测到该中断.然后,网络设备驱动程序禁用与接收数据包有关的中断,并使用NAPI,告诉Linux网络子系统轮询设备驱动程序.轮询功能由设备驱动程序实现,并传递给网络子系统,并包含设备驱动程序的数据包处理程序.在收到足够的数据包或达到超时后,将重新启用数据包接收中断,然后一切重新开始.

The kernel kicks off the "packet received" interrupt, which a network device driver using NAPI detects. The network device driver then disables interrupts related to receiving packets and using NAPI, tells the Linux networking subsystem to poll the device driver. The poll function is implemented by the device driver, and is passed to the networking subsystem, and contains the device driver's packet handler. After enough packets are received or a timeout is reached, packet-receiving interrupts are re-enabled, and everything starts over again.

因此,NAPI基本上只是Linux网络子系统中的集中式API,用于支持中断合并以减少接收活动锁的情况. NAPI为设备驱动程序开发人员提供了一个干净的框架,用于中断合并. NAPI不会一直运行,而只会在实际接收到流量时才会发生,从而使它本质上是一种中断合并方案……至少在我的书中.

So NAPI is basically just a centralized API in the Linux networking subsystem for supporting interrupt coalescing to reduce receive livelock situations. NAPI gives device driver developers a clean framework for interrupt coalescing. NAPI does not run all the time, but only happens when traffic is actually received, making it essentially an interrupt coalescing scheme... At least in my book.

注意:这全部是在使用NAPI的网络设备驱动程序的上下文中进行的,但实际上NAPI可以用于任何类型的中断.这也是NAPI的好处之一.

Note: This was all in the context of a network device driver using NAPI, but in fact NAPI can be used for any kind of interrupt. This is one of the benefits of NAPI, as well.

如果我的理解中有任何错误,请随时指出!!

If there are any errors in my understanding, please feel free to point them out!

这篇关于在IRQ合并之前,NAPI有哪些优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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