Linux: Configuring RX POLLING (NAPI)

In Linux, Receive Side Scaling (RSS) and Network Adapter Poll Mode (NAPI) are two techniques that can be used to improve the performance of network I/O on multi-core systems. NAPI, in particular, allows for more efficient handling of network traffic by reducing the overhead associated with interrupt handling.

To configure NAPI, you can follow these steps:

  1. Identify the network interface that you want to configure. You can do this by running the ifconfig command, which will display a list of all network interfaces that are currently available on the system.
  2. Check whether NAPI is currently enabled for the network interface. You can do this by running the ethtool command with the name of the network interface as an argument. For example:
    sudo ethtool -k eth0

    This will display a list of offload options that are currently enabled for the interface. Look for the rx-usecs option, which controls the polling interval for NAPI.

  3. Enable NAPI by setting the rx-usecs option to a value of 0. This will cause the network driver to use NAPI instead of interrupt-driven I/O. You can set this option using the ethtool command with the -C option. For example:
    sudo ethtool -C eth0 rx-usecs 0

    Note that not all network drivers support NAPI, so this option may not be available for all interfaces.

  4. Verify that NAPI is working by monitoring the interrupt rate for the network interface. You can do this using the sar command, which is part of the sysstat package. For example:
    sudo sar -n DEV 1

    This will display a real-time view of network statistics, including the interrupt rate for each network interface. Look for a decrease in the interrupt rate for the interface that you configured with NAPI.

After completing these steps, NAPI should be enabled for the network interface, which should help to improve the performance of network I/O on multi-core systems. However, be aware that enabling NAPI may have some implications for certain network applications, as it may change the timing and order in which packets are delivered to the application.

Leave a Comment