]>
Commit | Line | Data |
---|---|---|
7f87a3cd SL |
1 | From 3c20a3e37153bca1580e092b0d1d2051e1236cf9 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Wed, 10 Apr 2024 09:13:56 +0000 | |
4 | Subject: net: ena: Wrong missing IO completions check order | |
5 | ||
6 | From: David Arinzon <darinzon@amazon.com> | |
7 | ||
8 | [ Upstream commit f7e417180665234fdb7af2ebe33d89aaa434d16f ] | |
9 | ||
10 | Missing IO completions check is called every second (HZ jiffies). | |
11 | This commit fixes several issues with this check: | |
12 | ||
13 | 1. Duplicate queues check: | |
14 | Max of 4 queues are scanned on each check due to monitor budget. | |
15 | Once reaching the budget, this check exits under the assumption that | |
16 | the next check will continue to scan the remainder of the queues, | |
17 | but in practice, next check will first scan the last already scanned | |
18 | queue which is not necessary and may cause the full queue scan to | |
19 | last a couple of seconds longer. | |
20 | The fix is to start every check with the next queue to scan. | |
21 | For example, on 8 IO queues: | |
22 | Bug: [0,1,2,3], [3,4,5,6], [6,7] | |
23 | Fix: [0,1,2,3], [4,5,6,7] | |
24 | ||
25 | 2. Unbalanced queues check: | |
26 | In case the number of active IO queues is not a multiple of budget, | |
27 | there will be checks which don't utilize the full budget | |
28 | because the full scan exits when reaching the last queue id. | |
29 | The fix is to run every TX completion check with exact queue budget | |
30 | regardless of the queue id. | |
31 | For example, on 7 IO queues: | |
32 | Bug: [0,1,2,3], [4,5,6], [0,1,2,3] | |
33 | Fix: [0,1,2,3], [4,5,6,0], [1,2,3,4] | |
34 | The budget may be lowered in case the number of IO queues is less | |
35 | than the budget (4) to make sure there are no duplicate queues on | |
36 | the same check. | |
37 | For example, on 3 IO queues: | |
38 | Bug: [0,1,2,0], [1,2,0,1] | |
39 | Fix: [0,1,2], [0,1,2] | |
40 | ||
41 | Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") | |
42 | Signed-off-by: Amit Bernstein <amitbern@amazon.com> | |
43 | Signed-off-by: David Arinzon <darinzon@amazon.com> | |
44 | Reviewed-by: Shannon Nelson <shannon.nelson@amd.com> | |
45 | Signed-off-by: Paolo Abeni <pabeni@redhat.com> | |
46 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
47 | --- | |
48 | drivers/net/ethernet/amazon/ena/ena_netdev.c | 21 +++++++++++--------- | |
49 | 1 file changed, 12 insertions(+), 9 deletions(-) | |
50 | ||
51 | diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c | |
52 | index fa65971949fce..f403a5acda5b0 100644 | |
53 | --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c | |
54 | +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c | |
55 | @@ -3672,10 +3672,11 @@ static void check_for_missing_completions(struct ena_adapter *adapter) | |
56 | { | |
57 | struct ena_ring *tx_ring; | |
58 | struct ena_ring *rx_ring; | |
59 | - int i, budget, rc; | |
60 | + int qid, budget, rc; | |
61 | int io_queue_count; | |
62 | ||
63 | io_queue_count = adapter->xdp_num_queues + adapter->num_io_queues; | |
64 | + | |
65 | /* Make sure the driver doesn't turn the device in other process */ | |
66 | smp_rmb(); | |
67 | ||
68 | @@ -3688,27 +3689,29 @@ static void check_for_missing_completions(struct ena_adapter *adapter) | |
69 | if (adapter->missing_tx_completion_to == ENA_HW_HINTS_NO_TIMEOUT) | |
70 | return; | |
71 | ||
72 | - budget = ENA_MONITORED_TX_QUEUES; | |
73 | + budget = min_t(u32, io_queue_count, ENA_MONITORED_TX_QUEUES); | |
74 | ||
75 | - for (i = adapter->last_monitored_tx_qid; i < io_queue_count; i++) { | |
76 | - tx_ring = &adapter->tx_ring[i]; | |
77 | - rx_ring = &adapter->rx_ring[i]; | |
78 | + qid = adapter->last_monitored_tx_qid; | |
79 | + | |
80 | + while (budget) { | |
81 | + qid = (qid + 1) % io_queue_count; | |
82 | + | |
83 | + tx_ring = &adapter->tx_ring[qid]; | |
84 | + rx_ring = &adapter->rx_ring[qid]; | |
85 | ||
86 | rc = check_missing_comp_in_tx_queue(adapter, tx_ring); | |
87 | if (unlikely(rc)) | |
88 | return; | |
89 | ||
90 | - rc = !ENA_IS_XDP_INDEX(adapter, i) ? | |
91 | + rc = !ENA_IS_XDP_INDEX(adapter, qid) ? | |
92 | check_for_rx_interrupt_queue(adapter, rx_ring) : 0; | |
93 | if (unlikely(rc)) | |
94 | return; | |
95 | ||
96 | budget--; | |
97 | - if (!budget) | |
98 | - break; | |
99 | } | |
100 | ||
101 | - adapter->last_monitored_tx_qid = i % io_queue_count; | |
102 | + adapter->last_monitored_tx_qid = qid; | |
103 | } | |
104 | ||
105 | /* trigger napi schedule after 2 consecutive detections */ | |
106 | -- | |
107 | 2.43.0 | |
108 |