Introduce and use the NET_EPOCH_DRAIN_CALLBACKS() macro

Reviewed by:	melifao, kp
Differential Revision:	https://reviews.freebsd.org/D35968
This commit is contained in:
Zhenlei Huang 2022-07-29 15:02:39 +02:00 committed by Kristof Provost
parent b07a48d4f3
commit 150486f6a9
6 changed files with 7 additions and 6 deletions

View File

@ -1143,7 +1143,7 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
* which lead to leave group calls, which in turn access the
* belonging ifnet structure:
*/
epoch_drain_callbacks(net_epoch_preempt);
NET_EPOCH_DRAIN_CALLBACKS();
/*
* In any case (destroy or vmove) detach us from the groups
@ -4206,7 +4206,7 @@ if_deregister_com_alloc(u_char type)
* fixes issues about late invocation of if_destroy(), which leads
* to memory leak from if_com_alloc[type] allocated if_l2com.
*/
epoch_drain_callbacks(net_epoch_preempt);
NET_EPOCH_DRAIN_CALLBACKS();
if_com_alloc[type] = NULL;
if_com_free[type] = NULL;

View File

@ -600,7 +600,7 @@ vnet_bridge_uninit(const void *unused __unused)
BRIDGE_LIST_LOCK_DESTROY();
/* Callbacks may use the UMA zone. */
epoch_drain_callbacks(net_epoch_preempt);
NET_EPOCH_DRAIN_CALLBACKS();
uma_zdestroy(V_bridge_rtnode_zone);
}

View File

@ -1509,7 +1509,7 @@ set_fib_algo(uint32_t fibnum, int family, struct sysctl_oid *oidp, struct sysctl
fib_cleanup_algo(rh, true, false);
/* Drain cb so user can unload the module after userret if so desired */
epoch_drain_callbacks(net_epoch_preempt);
NET_EPOCH_DRAIN_CALLBACKS();
return (0);
}

View File

@ -299,7 +299,7 @@ rtables_destroy(const void *unused __unused)
* nexthops deletions will be scheduled for the next epoch run
* and will be completed after vnet teardown.
*/
epoch_drain_callbacks(net_epoch_preempt);
NET_EPOCH_DRAIN_CALLBACKS();
free(V_rt_tables, M_RTABLE);
vnet_rtzone_destroy();

View File

@ -5186,7 +5186,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td
break;
}
/* Ensure there's no more ethernet rules to clean up. */
epoch_drain_callbacks(net_epoch_preempt);
NET_EPOCH_DRAIN_CALLBACKS();
PF_RULES_WLOCK();
for (i = 0, ioe = ioes; i < io->size; i++, ioe++) {
ioe->anchor[sizeof(ioe->anchor) - 1] = '\0';

View File

@ -109,6 +109,7 @@ extern epoch_t net_epoch_preempt;
#define NET_EPOCH_EXIT(et) epoch_exit_preempt(net_epoch_preempt, &(et))
#define NET_EPOCH_WAIT() epoch_wait_preempt(net_epoch_preempt)
#define NET_EPOCH_CALL(f, c) epoch_call(net_epoch_preempt, (f), (c))
#define NET_EPOCH_DRAIN_CALLBACKS() epoch_drain_callbacks(net_epoch_preempt)
#define NET_EPOCH_ASSERT() MPASS(in_epoch(net_epoch_preempt))
#define NET_TASK_INIT(t, p, f, c) TASK_INIT_FLAGS(t, p, f, c, TASK_NETWORK)
#define NET_GROUPTASK_INIT(gtask, prio, func, ctx) \