Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178330290
D62442.1796506142.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D62442.1796506142.diff
View Options
diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c
--- a/sys/dev/gve/gve_main.c
+++ b/sys/dev/gve/gve_main.c
@@ -245,6 +245,14 @@
if_setdrvflagbits(priv->ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING);
+ /*
+ * gve_xmit_ifp() tests IFF_DRV_RUNNING inside a net epoch section.
+ * Wait for the callers that saw it set, so that none of them can
+ * still enqueue xmit_task or transmit directly once the ring
+ * taskqueues are quiesced and freed below.
+ */
+ NET_EPOCH_WAIT();
+
if (gve_destroy_rx_rings(priv) != 0)
goto reset;
diff --git a/sys/dev/gve/gve_plat.h b/sys/dev/gve/gve_plat.h
--- a/sys/dev/gve/gve_plat.h
+++ b/sys/dev/gve/gve_plat.h
@@ -36,6 +36,7 @@
#include <sys/bitset.h>
#include <sys/bus.h>
#include <sys/endian.h>
+#include <sys/epoch.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
diff --git a/sys/dev/gve/gve_tx.c b/sys/dev/gve/gve_tx.c
--- a/sys/dev/gve/gve_tx.c
+++ b/sys/dev/gve/gve_tx.c
@@ -897,13 +897,24 @@
gve_xmit_ifp(if_t ifp, struct mbuf *mbuf)
{
struct gve_priv *priv = if_getsoftc(ifp);
+ struct epoch_tracker et;
struct gve_tx_ring *tx;
bool is_br_empty;
- int err;
+ int err = 0;
uint32_t i;
- if (__predict_false((if_getdrvflags(priv->ifp) & IFF_DRV_RUNNING) == 0))
- return (ENODEV);
+ NET_EPOCH_ENTER(et);
+ /*
+ * Test IFF_DRV_RUNNING inside the epoch section: gve_down() clears
+ * it and then calls NET_EPOCH_WAIT(), so a caller that sees it set
+ * here finishes before the ring taskqueues are quiesced and freed.
+ */
+ if (__predict_false(
+ (if_getdrvflags(priv->ifp) & IFF_DRV_RUNNING) == 0)) {
+ m_freem(mbuf);
+ err = ENODEV;
+ goto out;
+ }
if (M_HASHTYPE_GET(mbuf) != M_HASHTYPE_NONE)
i = mbuf->m_pkthdr.flowid % priv->tx_cfg.num_queues;
@@ -917,7 +928,8 @@
counter_u64_add_protected(tx->stats.tx_dropped_pkt, 1);
counter_exit();
m_freem(mbuf);
- return (ENODEV);
+ err = ENODEV;
+ goto out;
}
is_br_empty = drbr_empty(ifp, tx->br);
@@ -926,10 +938,11 @@
if (!atomic_load_bool(&tx->stopped))
taskqueue_enqueue(tx->xmit_tq, &tx->xmit_task);
counter_enter();
- counter_u64_add_protected(tx->stats.tx_dropped_pkt_nospace_bufring, 1);
+ counter_u64_add_protected(
+ tx->stats.tx_dropped_pkt_nospace_bufring, 1);
counter_u64_add_protected(tx->stats.tx_dropped_pkt, 1);
counter_exit();
- return (err);
+ goto out;
}
/*
@@ -942,7 +955,9 @@
} else if (!atomic_load_bool(&tx->stopped))
taskqueue_enqueue(tx->xmit_tq, &tx->xmit_task);
- return (0);
+out:
+ NET_EPOCH_EXIT(et);
+ return (err);
}
void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 5, 9:29 PM (3 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42241440
Default Alt Text
D62442.1796506142.diff (2 KB)
Attached To
Mode
D62442: gve: Synchronize gve_xmit_ifp() with gve_down() using NET_EPOCH
Attached
Detach File
Event Timeline