Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177411684
D61233.1794317131.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D61233.1794317131.diff
View Options
diff --git a/sys/dev/gve/gve_tx_dqo.c b/sys/dev/gve/gve_tx_dqo.c
--- a/sys/dev/gve/gve_tx_dqo.c
+++ b/sys/dev/gve/gve_tx_dqo.c
@@ -515,6 +515,13 @@
if (__predict_false(index == -1)) {
tx->dqo.free_pending_pkts_csm = atomic_swap_32(
&tx->dqo.free_pending_pkts_prd, -1);
+ /*
+ * Pairs with atomic_cmpset_rel_32() in
+ * gve_free_pending_packet() so the completion thread's writes
+ * to all slots in the stolen list are visible before this xmit
+ * thread walks ->next and reuses them.
+ */
+ atomic_thread_fence_acq();
index = tx->dqo.free_pending_pkts_csm;
if (__predict_false(index == -1))
@@ -525,9 +532,7 @@
/* Remove pending_pkt from the consumer list */
tx->dqo.free_pending_pkts_csm = pending_pkt->next;
- pending_pkt->state = GVE_PACKET_STATE_PENDING_DATA_COMPL;
-
- gve_set_timestamp(&pending_pkt->enqueue_time_sec);
+ pending_pkt->next = -1;
return (pending_pkt);
}
@@ -545,10 +550,16 @@
/* Add pending_pkt to the producer list */
while (true) {
- old_head = atomic_load_acq_32(&tx->dqo.free_pending_pkts_prd);
+ old_head = atomic_load_32(&tx->dqo.free_pending_pkts_prd);
pending_pkt->next = old_head;
- if (atomic_cmpset_32(&tx->dqo.free_pending_pkts_prd,
+ /*
+ * Pairs with atomic_thread_fence_acq() in
+ * gve_alloc_pending_packet() so this completion thread's
+ * updates to state and ->next are visible before the xmit
+ * thread steals and reuses this slot.
+ */
+ if (atomic_cmpset_rel_32(&tx->dqo.free_pending_pkts_prd,
old_head, index))
break;
}
@@ -621,6 +632,14 @@
if (__predict_false(buf == -1)) {
tx->dqo.free_qpl_bufs_csm = atomic_swap_32(
&tx->dqo.free_qpl_bufs_prd, -1);
+ /*
+ * Pairs with atomic_cmpset_rel_32() in
+ * gve_reap_qpl_bufs_dqo() so the completion thread's
+ * qpl_bufs[] entries for the entire stolen list are visible
+ * before this xmit thread walks and allocates them.
+ */
+ atomic_thread_fence_acq();
+
buf = tx->dqo.free_qpl_bufs_csm;
if (__predict_false(buf == -1))
return (-1);
@@ -748,12 +767,15 @@
return (ENOBUFS);
}
completion_tag = pkt - tx->dqo.pending_pkts;
- pkt->mbuf = mbuf;
err = gve_tx_fill_ctx_descs(tx, mbuf, is_tso, &desc_idx);
if (err)
goto abort;
+ pkt->mbuf = mbuf;
+ pkt->state = GVE_PACKET_STATE_PENDING_DATA_COMPL;
+ gve_set_timestamp(&pkt->enqueue_time_sec);
+
gve_tx_copy_mbuf_and_write_pkt_descs(tx, mbuf, pkt,
has_csum_flag, completion_tag, &desc_idx);
@@ -770,7 +792,6 @@
return (0);
abort:
- pkt->mbuf = NULL;
gve_free_pending_packet(tx, pkt);
return (err);
}
@@ -823,7 +844,6 @@
if (err)
goto abort;
mbuf = *mbuf_ptr; /* gve_map_mbuf_dqo might replace the mbuf chain */
- pkt->mbuf = mbuf;
total_descs_needed = 1 + /* general_ctx_desc */
nsegs + /* pkt_desc */
@@ -838,6 +858,10 @@
if (err)
goto abort_with_dma;
+ pkt->mbuf = mbuf;
+ pkt->state = GVE_PACKET_STATE_PENDING_DATA_COMPL;
+ gve_set_timestamp(&pkt->enqueue_time_sec);
+
bus_dmamap_sync(tx->dqo.buf_dmatag, pkt->dmamap, BUS_DMASYNC_PREWRITE);
for (i = 0; i < nsegs; i++) {
gve_tx_fill_pkt_desc_dqo(tx, &desc_idx,
@@ -861,7 +885,6 @@
abort_with_dma:
gve_unmap_packet(tx, pkt);
abort:
- pkt->mbuf = NULL;
gve_free_pending_packet(tx, pkt);
return (err);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 10, 1:25 PM (11 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41530668
Default Alt Text
D61233.1794317131.diff (3 KB)
Attached To
Mode
D61233: gve: Fix DQO TX free-list memory ordering and pending_pkt state
Attached
Detach File
Event Timeline