Skip to contentSkip to conversation

RDMA/irdma: Add budget to CEQE processing loop

PATCH Applied Jacob Moroni 3 participants 3 messages Nov 26 – Nov 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/irdma: Add budget to CEQE processing loop

irdma_process_ceq() processes CEQEs until the CEQ is empty and runs in a tasklet. Under heavy load, CEQEs can be emitted as fast as they are processed, so the tasklet does not return, which leads to RCU stalls.

Fix this by implementing a budget in the CEQ handling loop. If the budget is exhausted, the tasklet is rescheduled, which gives the kernel a chance to defer to ksoftirqd appropriately.

Fixes 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitions")
---
 drivers/infiniband/hw/irdma/hw.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/infiniband/hw/irdma/hw.c +22 -6
index 53aa1491c4f6..e71089fd5f56 100644
@@ -166,25 +166,31 @@ static void irdma_process_reserved_ceqe(struct irdma_pci_f *rf,
 	}
 }
 
+/* CEQEs handled by one run of a CEQ tasklet before it reschedules itself */
+#define IRDMA_CEQ_BUDGET	256
+
 /**
  * irdma_process_ceq - handle ceq for completions
  * @rf: RDMA PCI function
  * @ceq: ceq having cq for completion
+ *
+ * Return: True if the CEQ was found empty, false if the budget ran out.
  */
-static void irdma_process_ceq(struct irdma_pci_f *rf, struct irdma_ceq *ceq)
+static bool irdma_process_ceq(struct irdma_pci_f *rf, struct irdma_ceq *ceq)
 {
 	struct irdma_sc_dev *dev = &rf->sc_dev;
+	u32 budget = IRDMA_CEQ_BUDGET;
 	struct irdma_sc_ceq *sc_ceq;
 	unsigned long flags;
 	u32 cq_idx;
 
 	sc_ceq = &ceq->sc_ceq;
-	do {
+	while (budget--) {
 		spin_lock_irqsave(&ceq->ce_lock, flags);
 
 		if (!irdma_sc_process_ceq(dev, sc_ceq, &cq_idx)) {
 			spin_unlock_irqrestore(&ceq->ce_lock, flags);
-			break;
+			return true;
 		}
 
 		/* Normal CQs must be handled while holding CEQ lock. */
@@ -197,7 +203,9 @@ static void irdma_process_ceq(struct irdma_pci_f *rf, struct irdma_ceq *ceq)
 		spin_unlock_irqrestore(&ceq->ce_lock, flags);
 
 		irdma_process_reserved_ceqe(rf, dev, cq_idx);
-	} while (1);
+	}
+
+	return false;
 }
 
 static void irdma_set_flush_fields(struct irdma_sc_qp *qp,
@@ -548,10 +556,15 @@ static void irdma_ena_intr(struct irdma_sc_dev *dev, u32 msix_id)
 static void irdma_dpc(struct tasklet_struct *t)
 {
 	struct irdma_pci_f *rf = from_tasklet(rf, t, dpc_tasklet);
+	bool ceq_done = true;
 
 	if (rf->msix_shared)
-		irdma_process_ceq(rf, rf->ceqlist);
+		ceq_done = irdma_process_ceq(rf, rf->ceqlist);
 	irdma_process_aeq(rf);
+	if (!ceq_done) {
+		tasklet_schedule(&rf->dpc_tasklet);
+		return;
+	}
 	irdma_ena_intr(&rf->sc_dev, rf->iw_msixtbl[0].idx);
 }
 
@@ -564,7 +577,10 @@ static void irdma_ceq_dpc(struct tasklet_struct *t)
 	struct irdma_ceq *iwceq = from_tasklet(iwceq, t, dpc_tasklet);
 	struct irdma_pci_f *rf = iwceq->rf;
 
-	irdma_process_ceq(rf, iwceq);
+	if (!irdma_process_ceq(rf, iwceq)) {
+		tasklet_schedule(&iwceq->dpc_tasklet);
+		return;
+	}
 	irdma_ena_intr(&rf->sc_dev, iwceq->msix_idx);
 }
 

base-commit: 94e81a1f3ffabb388f7d0a9674bb1d3acc067e00

Signature · 1 line
2.56.1.839.g22a8290db9-goog
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines

irdma_process_ceq() processes CEQEs until the CEQ is empty and runs in a tasklet. Under heavy load, CEQEs can be emitted as fast as they are processed, so the tasklet does not return, which leads to RCU stalls.

Fix this by implementing a budget in the CEQ handling loop. If the budget is exhausted, the tasklet is rescheduled, which gives the kernel a chance to defer to ksoftirqd appropriately.

Fixes 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitions")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Jacob Moroni
Quoted 10 lines · Jacob Moroni

irdma_process_ceq() processes CEQEs until the CEQ is empty and runs in a tasklet. Under heavy load, CEQEs can be emitted as fast as they are processed, so the tasklet does not return, which leads to RCU stalls.

Fix this by implementing a budget in the CEQ handling loop. If the budget is exhausted, the tasklet is rescheduled, which gives the kernel a chance to defer to ksoftirqd appropriately.

[...]

Applied, thanks!

[1/1] RDMA/irdma: Add budget to CEQE processing loop

      https://git.kernel.org/rdma/rdma/c/211a4cfd857ddc

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>