Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tune the polling period of NAPI?

I can understand that NAPI in Linux will change from interrupt to poll mode to handle the high packet rate.

NAPI uses weight to decide how many packets to process in each poll period; It also makes sure that the packet handling in each poll period is less than one jiffies.

However, I couldn't find in anywhere (google) what is the poll period of NAPI? Can we change the poll period to any value we want?

Thank you very much for any of your help!


From what I observe, it seems that NAPI's poll period is 2 second, but I want to make sure my observation is correct.

like image 231
Mike Avatar asked Feb 09 '23 13:02

Mike


1 Answers

NAPI packet processing is controlled in two ways:

  1. With the netdev_budget which is the total number of packets that can be processed. This can be tuned by setting the net.core.netdev_budget sysctl.
  2. On Linux 4.12+, with netdev_budget_usecs which is the total time in microseconds that can be spent processing packets. The corresponding sysctl parameter is net.core.netdev_budget_usecs. On Linux < 4.12, the sysctl does not exist and this value is hardcoded to 2 jiffies. It cannot be tuned.

I wrote a detailed blog post describing the Linux network stack in detail that may interest you and this section shows the code for the NAPI processing loop where the hardcoded timeout can be found.

like image 58
Joe Damato Avatar answered Feb 13 '23 02:02

Joe Damato