New API: Difference between revisions

Content deleted Content added
m Further reading: lwn.net supports https; use protocol-relative URLs
GreenC bot (talk | contribs)
Reformat 1 archive link. Wayback Medic 2.5 per WP:URLREQ#citeftp
 
(22 intermediate revisions by 15 users not shown)
Line 1:
{{multipleMultiple issues|
{{noNo footnotes|date=April 2013}}
{{primaryPrimary sources|date=April 2013}}
{{Lead too short|date=April 2015}}
}}
 
'''New API''' (also referred to as '''NAPI''') is an interface to use [[Interrupt coalescing|interrupt mitigation]] techniques for networking devices in the [[Linux kernel]]. Such an approach is intended to reduce the overhead of packet receiving. The idea is to defer incoming message handling until there is a sufficient amount of them so that it is worth handling them all at once.
Such an approach is intended to reduce the overhead of packet receiving. The idea is to defer incoming message handling until there is a sufficient amount of them so that it is worth handling them all at once.
 
==Motivation==
A straightforward method of implementing a network driver is to interrupt the kernel by issuing an [[interrupt request]] (IRQ) for each and every incoming packet. However, servicing IRQs is costly in terms of processor resources and time. Therefore, the straightforward implementation can be very inefficient in high-speed networks, constantly interrupting the kernel with the thousands of packets per second. Overall performance of the system as well as network throughput can suffer as a result.
 
[[Polling (computer science)|Polling]] is an alternative to interrupt-based processing. The kernel can periodically check for the arrival of incoming network packets without being interrupted, which eliminates the overhead of interrupt processing. Establishing an optimal polling frequency is important, however. Too frequent polling wastes CPU resources by repeatedly checking for incoming packets that have not yet arrived. On the other hand, polling too infrequently introduces latency by reducing system reactivity to incoming packets, and it may result in the loss of packets if the incoming packet buffer fills up before being processed.
Line 15:
 
==Compliant drivers==
A driver using the '''NAPI''' interface will work as follow :
* Packet receive interrupts are disabled.
* The driver provides a poll method to the kernel. That method will fetch all incoming packets available, on the network card or a [[Direct memory access|DMA]] ring, so that they will then be handled by the kernel.
Line 22:
==Advantages==
* The load induced by [[interrupt request|interrupts]] is reduced even though the kernel has to poll.
* Packets are less likely to be re-ordered, while out of order packet handling might be a bottleneck otherwise. {{Citation needed|date=June 2020}}
* In case the kernel is unable to handle all incoming packets, the kernel does not have to do any work in order to drop them: they are simply overwritten in the [[network card]]'s incoming [[ring buffer]]. Without NAPI, the kernel has to handle every incoming packet regardless of whether there is time to service it, which leads to [[thrashing (computer science)|thrashing]].
 
==History==
NAPI was an over-three-year effort by Alexey Kuznetsov, Jamal Hadi Salim and Robert Olsson. Initial effort to include NAPI was met with resistance by some members of the community, however [[David S. Miller|David Miller]] worked hard to ensure NAPI's inclusion.
 
A lot of real world testing was done in the [[Uppsala University|Uppsala university]] network before inclusion. In fact, [https://www.slu.se www.slu.se] was the first production NAPI-based OS and is still powered to this day by NAPI-based Bifrost/Linux routers. The [https://wiki.linuxfoundation.org/networking/pktgen pktgen] [[Packet generator|traffic generator]] was also born around this time. Pktgen was extensively used to test NAPI scenarios not induced by real world traffic.
 
==References==
{{Reflist}}
 
==Further reading==
Line 34 ⟶ 37:
| url = http://www.usenix.org/publications/library/proceedings/als01/full_papers/jamal/jamal.pdf
| title = Beyond softnet
|author1=Jamal Hadi Salim |author2=Robert Olsson |author3=Alexey Kuznetsov | date = 2001-11-10
| author = Jamal Hadi Salim, Robert Olsson, Alexey Kuznetsov
| date = 2001-11-10
| conference = 5th Annual Linux Showcase & Conference (ALS '01)
| conferenceurlconference-url = http://www.usenix.org/publications/library/proceedings/als01/
| pages = 165–172
| accessdateaccess-date = 2011-03-06
}} The classical NAPI paper.
*{{cite web
Line 46 ⟶ 48:
| date = 2003-04-28
| work = [[LWN.net]]
| url = https://lwn.net/Articles/30107/
| accessdateaccess-date = 2011-03-06
}}
*{{cite web
Line 54 ⟶ 56:
| date = 2006-12-18
| work = [[LWN.net]]
| url = https://lwn.net/Articles/214457/
| accessdateaccess-date = 2011-03-06
}}
*{{cite book
| author author1= Jonathan Corbet, |author2=Alessandro Rubini, |author3=Greg Kroah-Hartman | title = Linux Device Drivers
| titleurl = Linux Device= Drivershttps://lwn.net/Kernel/LDD3/
| url = http://lwn.net/Kernel/LDD3/
| chapter = Chapter 17: Networking drivers
| chapterurlchapter-url = httphttps://lwn.net/images/pdf/LDD3/ch17.pdf
|date=February 2005
| edition = 3rd
| publisher = O'Reilly Media
| isbn = 978-0-596-00590-0
| accessdateaccess-date = 2011-03-06
}}
 
==External links==
* [ftp://robur.slu.se/pub/Linux/net-development/NAPI/ Early NAPI work] {{Deaddead link|date=JanuaryMay 20142025|bot=medic}}{{cbignore|bot=medic}}
* [http://www.linuxfoundation.org/collaborate/workgroups/networking/napi NAPI description on Linux Foundation] {{Webarchive|url=https://web.archive.org/web/20160611104440/http://www.linuxfoundation.org/collaborate/workgroups/networking/napi |date=2016-06-11 }}
* [https://web.archive.org/web/20111030030517/http://www.linuxfoundation.org/collaborate/workgroups/networking/networkoverview Network overview], November 19, 2009, The Linux Foundation, by Rami Rosen ](archived //from Thethe Linuxoriginal Foundationon October 30, 2011)
 
{{Linux kernel}}
{{Linux}}
 
[[Category:Interfaces of the Linux kernel]]
[[Category:Linux kernel features]]
[[Category:Linux drivers]]
[[Category:Ethernet]]