vtnet: Pre-allocate debugnet data immediately
Don't wait until the vtnet_debugnet_init() call happens, because at that point we might already have allocated something from vtnet_tx_header_zone. Some systems showed this panic: vtnet0: link state changed to UP panic: keg vtnet_tx_hdr initialization after use. cpuid = 5 time = 1578427700 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe004db427f0 vpanic() at vpanic+0x17e/frame 0xfffffe004db42850 panic() at panic+0x43/frame 0xfffffe004db428b0 uma_zone_reserve() at uma_zone_reserve+0xf6/frame 0xfffffe004db428f0 vtnet_debugnet_init() at vtnet_debugnet_init+0x77/frame 0xfffffe004db42930 debugnet_any_ifnet_update() at debugnet_any_ifnet_update+0x42/frame 0xfffffe004db42980 do_link_state_change() at do_link_state_change+0x1b3/frame 0xfffffe004db429d0 taskqueue_run_locked() at taskqueue_run_locked+0x178/frame 0xfffffe004db42a30 taskqueue_run() at taskqueue_run+0x4d/frame 0xfffffe004db42a50 ithread_loop() at ithread_loop+0x1d6/frame 0xfffffe004db42ab0 fork_exit() at fork_exit+0x80/frame 0xfffffe004db42af0 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe004db42af0 --- trap 0, rip = 0, rsp = 0, rbp = 0 --- KDB: enter: panic [ thread pid 12 tid 100011 ] Stopped at kdb_enter+0x37: movq $0,0x1084eb6(%rip) db> Reviewed by: cem, markj Differential Revision: https://reviews.freebsd.org/D23073
This commit is contained in:
parent
2138e99bf5
commit
29bfe2102d
@ -337,10 +337,21 @@ vtnet_modevent(module_t mod, int type, void *unused)
|
||||
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
if (loaded++ == 0)
|
||||
if (loaded++ == 0) {
|
||||
vtnet_tx_header_zone = uma_zcreate("vtnet_tx_hdr",
|
||||
sizeof(struct vtnet_tx_header),
|
||||
NULL, NULL, NULL, NULL, 0, 0);
|
||||
#ifdef DEBUGNET
|
||||
/*
|
||||
* We need to allocate from this zone in the transmit path, so ensure
|
||||
* that we have at least one item per header available.
|
||||
* XXX add a separate zone like we do for mbufs? otherwise we may alloc
|
||||
* buckets
|
||||
*/
|
||||
uma_zone_reserve(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
|
||||
uma_prealloc(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case MOD_QUIESCE:
|
||||
if (uma_zone_get_cur(vtnet_tx_header_zone) > 0)
|
||||
@ -3982,15 +3993,6 @@ vtnet_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
|
||||
*ncl = DEBUGNET_MAX_IN_FLIGHT;
|
||||
*clsize = sc->vtnet_rx_clsize;
|
||||
VTNET_CORE_UNLOCK(sc);
|
||||
|
||||
/*
|
||||
* We need to allocate from this zone in the transmit path, so ensure
|
||||
* that we have at least one item per header available.
|
||||
* XXX add a separate zone like we do for mbufs? otherwise we may alloc
|
||||
* buckets
|
||||
*/
|
||||
uma_zone_reserve(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
|
||||
uma_prealloc(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user