From owner-svn-src-all@FreeBSD.ORG  Wed Apr  8 20:25:52 2015
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
Delivered-To: svn-src-all@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id 8E6B38AA;
 Wed,  8 Apr 2015 20:25:52 +0000 (UTC)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 5F1C5350;
 Wed,  8 Apr 2015 20:25:52 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t38KPq0B019879;
 Wed, 8 Apr 2015 20:25:52 GMT (envelope-from gnn@FreeBSD.org)
Received: (from gnn@localhost)
 by svn.freebsd.org (8.14.9/8.14.9/Submit) id t38KPqU0019878;
 Wed, 8 Apr 2015 20:25:52 GMT (envelope-from gnn@FreeBSD.org)
Message-Id: <201504082025.t38KPqU0019878@svn.freebsd.org>
X-Authentication-Warning: svn.freebsd.org: gnn set sender to gnn@FreeBSD.org
 using -f
From: "George V. Neville-Neil" <gnn@FreeBSD.org>
Date: Wed, 8 Apr 2015 20:25:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r281276 - head/sys/net
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.18-1
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 08 Apr 2015 20:25:52 -0000

Author: gnn
Date: Wed Apr  8 20:25:51 2015
New Revision: 281276
URL: https://svnweb.freebsd.org/changeset/base/281276

Log:
  Add support for a netisr polling tunable, which allows run time switching of
  device polling rather than having it only be controlled by the compile
  time option.
  
  Summary: Rubicon Communications (Netgate)
  
  Reviewers: #network, hiren
  
  Reviewed By: #network, hiren
  
  Subscribers: hiren
  
  Differential Revision: https://reviews.freebsd.org/D2258

Modified:
  head/sys/net/netisr.c

Modified: head/sys/net/netisr.c
==============================================================================
--- head/sys/net/netisr.c	Wed Apr  8 20:10:42 2015	(r281275)
+++ head/sys/net/netisr.c	Wed Apr  8 20:25:51 2015	(r281276)
@@ -126,6 +126,13 @@ static struct rmlock	netisr_rmlock;
 
 static SYSCTL_NODE(_net, OID_AUTO, isr, CTLFLAG_RW, 0, "netisr");
 
+#ifdef DEVICE_POLLING
+static int	netisr_polling = 0;	/* Enable Polling. */
+TUNABLE_INT("net.isr.polling_enable", &netisr_polling);
+SYSCTL_INT(_net_isr, OID_AUTO, polling_enable, CTLFLAG_RW,
+    &netisr_polling, 0, "Enable polling");
+#endif
+
 /*-
  * Three global direct dispatch policies are supported:
  *
@@ -789,9 +796,11 @@ swi_net(void *arg)
 	nwsp = arg;
 
 #ifdef DEVICE_POLLING
-	KASSERT(nws_count == 1,
-	    ("%s: device_polling but nws_count != 1", __func__));
-	netisr_poll();
+	if (netisr_polling) {
+		KASSERT(nws_count == 1,
+		    ("%s: device_polling but nws_count != 1", __func__));
+		netisr_poll();
+	}
 #endif
 #ifdef NETISR_LOCKING
 	NETISR_RLOCK(&tracker);
@@ -816,7 +825,8 @@ out:
 	NETISR_RUNLOCK(&tracker);
 #endif
 #ifdef DEVICE_POLLING
-	netisr_pollmore();
+	if (netisr_polling)
+		netisr_pollmore();
 #endif
 }
 
@@ -1071,6 +1081,9 @@ netisr_sched_poll(void)
 {
 	struct netisr_workstream *nwsp;
 
+	if (!netisr_polling)
+		return;
+
 	nwsp = DPCPU_ID_PTR(nws_array[0], nws);
 	NWS_SIGNAL(nwsp);
 }
@@ -1138,7 +1151,7 @@ netisr_init(void *arg)
 	 * multiple netisr threads, so for the time being compiling in device
 	 * polling disables parallel netisr workers.
 	 */
-	if (netisr_maxthreads != 1 || netisr_bindthreads != 0) {
+	if (netisr_polling && (netisr_maxthreads != 1 || netisr_bindthreads != 0)) {
 		printf("netisr_init: forcing maxthreads to 1 and "
 		    "bindthreads to 0 for device polling\n");
 		netisr_maxthreads = 1;