ibmvnic: Do not replenish RX buffers after every polling loop
authorDwip N. Banerjee <dnbanerg@us.ibm.com>
Thu, 19 Nov 2020 01:12:25 +0000 (19:12 -0600)
committerJakub Kicinski <kuba@kernel.org>
Sat, 21 Nov 2020 03:50:41 +0000 (19:50 -0800)
Reduce the amount of time spent replenishing RX buffers by only doing
so once available buffers has fallen under a certain threshold, in this
case half of the total number of buffers, or if the polling loop exits
before the packets processed is less than its budget. Non-exhaustion of
NAPI budget implies lower incoming packet pressure, allowing the leeway
to refill the buffers in preparation for any impending burst.

Signed-off-by: Dwip N. Banerjee <dnbanerg@us.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ibm/ibmvnic.c

index 96df6d8..9fe43ab 100644 (file)
@@ -2537,7 +2537,10 @@ restart_poll:
                frames_processed++;
        }
 
-       if (adapter->state != VNIC_CLOSING)
+       if (adapter->state != VNIC_CLOSING &&
+           ((atomic_read(&adapter->rx_pool[scrq_num].available) <
+             adapter->req_rx_add_entries_per_subcrq / 2) ||
+             frames_processed < budget))
                replenish_rx_pool(adapter, &adapter->rx_pool[scrq_num]);
        if (frames_processed < budget) {
                if (napi_complete_done(napi, frames_processed)) {