Author: sephe
Date: Wed Apr 27 04:51:28 2016
New Revision: 298688
URL: https://svnweb.freebsd.org/changeset/base/298688

Log:
  hyperv/hn: Restart sending earlier once we gathered some free TX descs
  
  This greatly reduces the oqdrops under heavy workload.
  
  For TCP send/recv test (10K concurrent connections):
  oqdrops is reduced by 17% on sending side, and 57% on receiving side.
  
  For nginx-1.8/wrk-4 1KB object test (10K concurrent connections,
  4 requests/connection):
  oqdrops is reduced by 44% on nginx side, and 10% on wrk side.
  
  MFC after:    1 week
  Sponsored by: Microsoft OSTC

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Wed Apr 27 03:06:53 2016        
(r298687)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Wed Apr 27 04:51:28 2016        
(r298688)
@@ -1185,7 +1185,8 @@ struct hn_tx_ring {
 #endif
        int             hn_txdesc_cnt;
        int             hn_txdesc_avail;
-       int             hn_has_txeof;
+       u_short         hn_has_txeof;
+       u_short         hn_txdone_cnt;
 
        int             hn_sched_tx;
        void            (*hn_txeof)(struct hn_tx_ring *);

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 03:06:53 
2016        (r298687)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 04:51:28 
2016        (r298688)
@@ -155,6 +155,8 @@ __FBSDID("$FreeBSD$");
 
 #define HN_DIRECT_TX_SIZE_DEF          128
 
+#define HN_EARLY_TXEOF_THRESH          8
+
 struct hn_txdesc {
 #ifndef HN_USE_TXDESC_BUFRING
        SLIST_ENTRY(hn_txdesc) link;
@@ -793,6 +795,13 @@ hn_txdesc_hold(struct hn_txdesc *txd)
        atomic_add_int(&txd->refs, 1);
 }
 
+static __inline void
+hn_txeof(struct hn_tx_ring *txr)
+{
+       txr->hn_has_txeof = 0;
+       txr->hn_txeof(txr);
+}
+
 static void
 hn_tx_done(struct hv_vmbus_channel *chan, void *xpkt)
 {
@@ -811,6 +820,13 @@ hn_tx_done(struct hv_vmbus_channel *chan
 
        txr->hn_has_txeof = 1;
        hn_txdesc_put(txr, txd);
+
+       ++txr->hn_txdone_cnt;
+       if (txr->hn_txdone_cnt >= HN_EARLY_TXEOF_THRESH) {
+               txr->hn_txdone_cnt = 0;
+               if (txr->hn_oactive)
+                       hn_txeof(txr);
+       }
 }
 
 void
@@ -831,8 +847,8 @@ netvsc_channel_rollup(struct hv_vmbus_ch
        if (txr == NULL || !txr->hn_has_txeof)
                return;
 
-       txr->hn_has_txeof = 0;
-       txr->hn_txeof(txr);
+       txr->hn_txdone_cnt = 0;
+       hn_txeof(txr);
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to