Skip to content

Commit f7e4171

Browse files
davidarinzonPaolo Abeni
authored andcommitted
net: ena: Wrong missing IO completions check order
Missing IO completions check is called every second (HZ jiffies). This commit fixes several issues with this check: 1. Duplicate queues check: Max of 4 queues are scanned on each check due to monitor budget. Once reaching the budget, this check exits under the assumption that the next check will continue to scan the remainder of the queues, but in practice, next check will first scan the last already scanned queue which is not necessary and may cause the full queue scan to last a couple of seconds longer. The fix is to start every check with the next queue to scan. For example, on 8 IO queues: Bug: [0,1,2,3], [3,4,5,6], [6,7] Fix: [0,1,2,3], [4,5,6,7] 2. Unbalanced queues check: In case the number of active IO queues is not a multiple of budget, there will be checks which don't utilize the full budget because the full scan exits when reaching the last queue id. The fix is to run every TX completion check with exact queue budget regardless of the queue id. For example, on 7 IO queues: Bug: [0,1,2,3], [4,5,6], [0,1,2,3] Fix: [0,1,2,3], [4,5,6,0], [1,2,3,4] The budget may be lowered in case the number of IO queues is less than the budget (4) to make sure there are no duplicate queues on the same check. For example, on 3 IO queues: Bug: [0,1,2,0], [1,2,0,1] Fix: [0,1,2], [0,1,2] Fixes: 1738cd3 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Amit Bernstein <amitbern@amazon.com> Signed-off-by: David Arinzon <darinzon@amazon.com> Reviewed-by: Shannon Nelson <shannon.nelson@amd.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 713a851 commit f7e4171

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,10 +3481,11 @@ static void check_for_missing_completions(struct ena_adapter *adapter)
34813481
{
34823482
struct ena_ring *tx_ring;
34833483
struct ena_ring *rx_ring;
3484-
int i, budget, rc;
3484+
int qid, budget, rc;
34853485
int io_queue_count;
34863486

34873487
io_queue_count = adapter->xdp_num_queues + adapter->num_io_queues;
3488+
34883489
/* Make sure the driver doesn't turn the device in other process */
34893490
smp_rmb();
34903491

@@ -3497,27 +3498,29 @@ static void check_for_missing_completions(struct ena_adapter *adapter)
34973498
if (adapter->missing_tx_completion_to == ENA_HW_HINTS_NO_TIMEOUT)
34983499
return;
34993500

3500-
budget = ENA_MONITORED_TX_QUEUES;
3501+
budget = min_t(u32, io_queue_count, ENA_MONITORED_TX_QUEUES);
35013502

3502-
for (i = adapter->last_monitored_tx_qid; i < io_queue_count; i++) {
3503-
tx_ring = &adapter->tx_ring[i];
3504-
rx_ring = &adapter->rx_ring[i];
3503+
qid = adapter->last_monitored_tx_qid;
3504+
3505+
while (budget) {
3506+
qid = (qid + 1) % io_queue_count;
3507+
3508+
tx_ring = &adapter->tx_ring[qid];
3509+
rx_ring = &adapter->rx_ring[qid];
35053510

35063511
rc = check_missing_comp_in_tx_queue(adapter, tx_ring);
35073512
if (unlikely(rc))
35083513
return;
35093514

3510-
rc = !ENA_IS_XDP_INDEX(adapter, i) ?
3515+
rc = !ENA_IS_XDP_INDEX(adapter, qid) ?
35113516
check_for_rx_interrupt_queue(adapter, rx_ring) : 0;
35123517
if (unlikely(rc))
35133518
return;
35143519

35153520
budget--;
3516-
if (!budget)
3517-
break;
35183521
}
35193522

3520-
adapter->last_monitored_tx_qid = i % io_queue_count;
3523+
adapter->last_monitored_tx_qid = qid;
35213524
}
35223525

35233526
/* trigger napi schedule after 2 consecutive detections */

0 commit comments

Comments
 (0)