summaryrefslogtreecommitdiff
path: root/sys/net/if_var.h
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-04-16 04:04:20 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-04-16 04:04:20 +0000
commitd67c1561e6dcace59a295625d39e096ba0fc58f8 (patch)
treef2208cb9f4d59913c90d01444f67ff87eedae063 /sys/net/if_var.h
parent0ffd38748b576e3e48b8ee7fb43e3ea31d9cbabd (diff)
have another go at tx mitigation
the idea is to call the hardware transmit routine less since in a lot of cases posting a producer ring update to the chip is (very) expensive. it's better to do it for several packets instead of each packet, hence calling this tx mitigation. this diff defers the call to the transmit routine to a network taskq, or until a backlog of packets has built up. dragonflybsd uses 16 as the size of it's backlog, so i'm copying them for now. i've tried this before, but previous versions caused deadlocks. i discovered that the deadlocks in the previous version was from ifq_barrier calling taskq_barrier against the nettq. interfaces generally hold NET_LOCK while calling ifq_barrier, but the tq might already be waiting for the lock we hold. this version just doesnt have ifq_barrier call taskq_barrier. it instead relies on the IFF_RUNNING flag and normal ifq serialiser barrier to guarantee the start routine wont be called when an interface is going down. the taskq_barrier is only used during interface destruction to make sure the task struct wont get used in the future, which is already done without the NET_LOCK being held. tx mitigation provides a nice performanace bump in some setups. up to 25% in some cases. tested by tb@ and hrvoje popovski (who's running this in production). ok visa@
Diffstat (limited to 'sys/net/if_var.h')
-rw-r--r--sys/net/if_var.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 4cad0830309..634c6dff9e6 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.95 2019/03/31 13:58:18 mpi Exp $ */
+/* $OpenBSD: if_var.h,v 1.96 2019/04/16 04:04:19 dlg Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -176,6 +176,7 @@ struct ifnet { /* and the entries */
struct ifqueue **if_ifqs; /* [I] pointer to an array of sndqs */
void (*if_qstart)(struct ifqueue *);
unsigned int if_nifqs; /* [I] number of output queues */
+ unsigned int if_txmit; /* [c] txmitigation amount */
struct ifiqueue if_rcv; /* rx/input queue */
struct ifiqueue **if_iqs; /* [I] pointer to the array of iqs */
@@ -303,6 +304,9 @@ do { \
#define IFQ_IS_EMPTY(ifq) ifq_empty(ifq)
#define IFQ_SET_MAXLEN(ifq, len) ifq_set_maxlen(ifq, len)
+#define IF_TXMIT_MIN 1
+#define IF_TXMIT_DEFAULT 16
+
/* default interface priorities */
#define IF_WIRED_DEFAULT_PRIORITY 0
#define IF_WIRELESS_DEFAULT_PRIORITY 4