From 37eacd1a0ff00b08beb61cf7f5d4e4a699e2a5bb Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 29 Mar 2008 04:45:47 +0000 Subject: [PATCH] Add two tunables to run netisr and udp_thread without mplock, so experiment could be conducted under controlled environment. Default values of these two tunables are to run netisr/udp_thread with mplock. --- sys/net/netisr.c | 11 ++++++++--- sys/netinet/ip_demux.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/sys/net/netisr.c b/sys/net/netisr.c index ad2e972cac..9353c2484a 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -35,7 +35,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/net/netisr.c,v 1.38 2008/03/29 03:37:15 sephe Exp $ + * $DragonFly: src/sys/net/netisr.c,v 1.39 2008/03/29 04:45:47 sephe Exp $ */ #include @@ -75,6 +75,9 @@ lwkt_port netisr_sync_port; static int (*netmsg_fwd_port_fn)(lwkt_port_t, lwkt_msg_t); +static int netisr_mpsafe_thread = 0; +TUNABLE_INT("netisr.mpsafe_thread", &netisr_mpsafe_thread); + /* * netisr_afree_rport replymsg function, only used to handle async * messages which the sender has abandoned to their fate. @@ -144,8 +147,10 @@ netisr_init(void) * Create default per-cpu threads for generic protocol handling. */ for (i = 0; i < ncpus; ++i) { - lwkt_create(netmsg_service_loop, NULL, NULL, &netisr_cpu[i], 0, i, - "netisr_cpu %d", i); + lwkt_create(netisr_mpsafe_thread ? + netmsg_service_loop_mpsafe : netmsg_service_loop, + NULL, NULL, &netisr_cpu[i], + 0, i, "netisr_cpu %d", i); netmsg_service_port_init(&netisr_cpu[i].td_msgport); } diff --git a/sys/netinet/ip_demux.c b/sys/netinet/ip_demux.c index 6912894f70..9ee55e9138 100644 --- a/sys/netinet/ip_demux.c +++ b/sys/netinet/ip_demux.c @@ -30,7 +30,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/netinet/ip_demux.c,v 1.38 2008/03/26 14:44:59 sephe Exp $ + * $DragonFly: src/sys/netinet/ip_demux.c,v 1.39 2008/03/29 04:45:47 sephe Exp $ */ #include "opt_inet.h" @@ -64,6 +64,9 @@ extern struct thread netisr_cpu[]; static struct thread tcp_thread[MAXCPU]; static struct thread udp_thread[MAXCPU]; +static int udp_mpsafe_thread = 0; +TUNABLE_INT("net.inet.udp.mpsafe_thread", &udp_mpsafe_thread); + static __inline int INP_MPORT_HASH(in_addr_t faddr, in_addr_t laddr, in_port_t fport, in_port_t lport) @@ -385,8 +388,10 @@ udp_thread_init(void) int cpu; for (cpu = 0; cpu < ncpus2; cpu++) { - lwkt_create(netmsg_service_loop, NULL, NULL, - &udp_thread[cpu], 0, cpu, "udp_thread %d", cpu); + lwkt_create(udp_mpsafe_thread ? + netmsg_service_loop_mpsafe : netmsg_service_loop, + NULL, NULL, &udp_thread[cpu], 0, cpu, + "udp_thread %d", cpu); netmsg_service_port_init(&udp_thread[cpu].td_msgport); } } -- 2.11.4.GIT