Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Feb 2016 02:54:36 +0000
From:      "sepherosa_gmail.com (Sepherosa Ziehau)" <phabric-noreply@FreeBSD.org>
To:        freebsd-net@freebsd.org
Subject:   [Differential] [Request, 42 lines] D5272: hyperv/hn: Add option to allow sharing TX taskq between hn instances
Message-ID:  <differential-rev-PHID-DREV-5ew7qdtgrz2cn67gpxpi-req@FreeBSD.org>

next in thread | raw e-mail | index | archive | help

--b1_870e3205ad69492660fb29ee2522b569
Content-Type: text/plain; charset = "utf-8"
Content-Transfer-Encoding: 8bit

sepherosa_gmail.com created this revision.
sepherosa_gmail.com added reviewers: network, adrian, delphij, royger, decui_microsoft.com, honzhan_microsoft.com, howard0su_gmail.com.
sepherosa_gmail.com added subscribers: freebsd-net-list, freebsd-virtualization-list.

REVISION SUMMARY
  It is off by default.  This eases further experimenting on this driver.

REVISION DETAIL
  https://reviews.freebsd.org/D5272

AFFECTED FILES
  sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -238,6 +238,11 @@
   #endif
   #endif
   
  +static int hn_share_tx_taskq = 0;
  +TUNABLE_INT("hw.hn.share_tx_taskq", &hn_share_tx_taskq);
  +
  +static struct taskqueue	*hn_tx_taskq;
  +
   /*
    * Forward declarations
    */
  @@ -353,10 +358,14 @@
   	if (hn_trust_hostip)
   		sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP;
   
  -	sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  -	    taskqueue_thread_enqueue, &sc->hn_tx_taskq);
  -	taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
  -	    device_get_nameunit(dev));
  +	if (hn_tx_taskq == NULL) {
  +		sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  +		    taskqueue_thread_enqueue, &sc->hn_tx_taskq);
  +		taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
  +		    device_get_nameunit(dev));
  +	} else {
  +		sc->hn_tx_taskq = hn_tx_taskq;
  +	}
   	TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc);
   	TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc);
   
  @@ -602,7 +611,8 @@
   
   	taskqueue_drain(sc->hn_tx_taskq, &sc->hn_start_task);
   	taskqueue_drain(sc->hn_tx_taskq, &sc->hn_txeof_task);
  -	taskqueue_free(sc->hn_tx_taskq);
  +	if (sc->hn_tx_taskq != hn_tx_taskq)
  +		taskqueue_free(sc->hn_tx_taskq);
   
   	ifmedia_removeall(&sc->hn_media);
   #if defined(INET) || defined(INET6)
  @@ -2039,6 +2049,28 @@
   	NV_UNLOCK(sc);
   }
   
  +static void
  +hn_tx_taskq_create(void *arg __unused)
  +{
  +	if (!hn_share_tx_taskq)
  +		return;
  +
  +	hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  +	    taskqueue_thread_enqueue, &hn_tx_taskq);
  +	taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
  +}
  +SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_FIRST,
  +    hn_tx_taskq_create, NULL);
  +
  +static void
  +hn_tx_taskq_destroy(void *arg __unused)
  +{
  +	if (hn_tx_taskq != NULL)
  +		taskqueue_free(hn_tx_taskq);
  +}
  +SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_FIRST,
  +    hn_tx_taskq_destroy, NULL);
  +
   static device_method_t netvsc_methods[] = {
           /* Device interface */
           DEVMETHOD(device_probe,         netvsc_probe),

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, network, adrian, delphij, royger, decui_microsoft.com, honzhan_microsoft.com, howard0su_gmail.com
Cc: freebsd-virtualization-list, freebsd-net-list

--b1_870e3205ad69492660fb29ee2522b569
Content-Type: text/x-patch; charset=utf-8; name="D5272.13283.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="D5272.13283.patch"

ZGlmZiAtLWdpdCBhL3N5cy9kZXYvaHlwZXJ2L25ldHZzYy9odl9uZXR2c2NfZHJ2X2ZyZWVic2Qu
YyBiL3N5cy9kZXYvaHlwZXJ2L25ldHZzYy9odl9uZXR2c2NfZHJ2X2ZyZWVic2QuYwotLS0gYS9z
eXMvZGV2L2h5cGVydi9uZXR2c2MvaHZfbmV0dnNjX2Rydl9mcmVlYnNkLmMKKysrIGIvc3lzL2Rl
di9oeXBlcnYvbmV0dnNjL2h2X25ldHZzY19kcnZfZnJlZWJzZC5jCkBAIC0yMzgsNiArMjM4LDEx
IEBACiAjZW5kaWYKICNlbmRpZgogCitzdGF0aWMgaW50IGhuX3NoYXJlX3R4X3Rhc2txID0gMDsK
K1RVTkFCTEVfSU5UKCJody5obi5zaGFyZV90eF90YXNrcSIsICZobl9zaGFyZV90eF90YXNrcSk7
CisKK3N0YXRpYyBzdHJ1Y3QgdGFza3F1ZXVlCSpobl90eF90YXNrcTsKKwogLyoKICAqIEZvcndh
cmQgZGVjbGFyYXRpb25zCiAgKi8KQEAgLTM1MywxMCArMzU4LDE0IEBACiAJaWYgKGhuX3RydXN0
X2hvc3RpcCkKIAkJc2MtPmhuX3RydXN0X2hjc3VtIHw9IEhOX1RSVVNUX0hDU1VNX0lQOwogCi0J
c2MtPmhuX3R4X3Rhc2txID0gdGFza3F1ZXVlX2NyZWF0ZV9mYXN0KCJobl90eCIsIE1fV0FJVE9L
LAotCSAgICB0YXNrcXVldWVfdGhyZWFkX2VucXVldWUsICZzYy0+aG5fdHhfdGFza3EpOwotCXRh
c2txdWV1ZV9zdGFydF90aHJlY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NikKQEAgLTIwMzksNiArMjA0OSwyOCBAQAogCU5WX1VOTE9D
SyhzYyk7CiB9CiAKK3N0YXRpYyB2b2lkCitobl90eF90YXNrcV9jcmVhdGUodm9pZCAqYXJnIF9f
dW51c2VkKQoreworCWlmICghaG5fc2hhcmVfdHhfdGFza3EpCisJCXJldHVybjsKKworCWhuX3R4
X3Rhc2txID0gdGFza3F1ZXVlX2NyZWF0ZV9mYXN0KCJobl90eCIsIE1fV0FJVE9LLAorCSAgICB0
YXNrcXVldWVfdGhyZWFkX2VucXVldWUsICZobl90eF90YXNrcSk7CisJdGFza3F1ZXVlX3N0YXJ0
X3RocmVhZHMoJmhuX3R4X3Rhc2txLCAxLCBQSV9ORVQsICJobiB0eCIpOworfQorU1lTSU5JVCho
bl90eHRxX2NyZWF0ZSwgU0lfU1VCX0RSSVZFUlMsIFNJX09SREVSX0ZJUlNULAorICAgIGhuX3R4
X3Rhc2txX2NyZWF0ZSwgTlVMTCk7CisKK3N0YXRpYyB2b2lkCitobl90eF90YXNrcV9kZXN0cm95
KHZvaWQgKmFyZyBfX3VudXNlZCkKK3sKKwlpZiAoaG5fdHhfdGFza3EgIT0gTlVMTCkKKwkJdGFz
a3F1ZXVlX2ZyZWUoaG5fdHhfdGFza3EpOworfQorU1lTVU5JTklUKGhuX3R4dHFfZGVzdHJveSwg
U0lfU1VCX0RSSVZFUlMsIFNJX09SREVSX0ZJUlNULAorICAgIGhuX3R4X3Rhc2txX2Rlc3Ryb3ks
IE5VTEwpOworCiBzdGF0aWMgZGV2aWNlX21ldGhvZF90IG5ldHZzY19tZXRob2RzW10gPSB7CiAg
ICAgICAgIC8qIERldmljZSBpbnRlcmZhY2UgKi8KICAgICAgICAgREVWTUVUSE9EKGRldmljZV9w
cm9iZSwgICAgICAgICBuZXR2c2NfcHJvYmUpLAoK


--b1_870e3205ad69492660fb29ee2522b569--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?differential-rev-PHID-DREV-5ew7qdtgrz2cn67gpxpi-req>