Module Name: src Committed By: rmind Date: Mon Aug 29 00:39:16 UTC 2011
Modified Files: src/sys/kern: sys_select.c Log Message: Add kern.direct_select sysctl. Default to 0 for now. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/kern/sys_select.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_select.c diff -u src/sys/kern/sys_select.c:1.35 src/sys/kern/sys_select.c:1.36 --- src/sys/kern/sys_select.c:1.35 Tue Aug 9 06:36:51 2011 +++ src/sys/kern/sys_select.c Mon Aug 29 00:39:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_select.c,v 1.35 2011/08/09 06:36:51 hannken Exp $ */ +/* $NetBSD: sys_select.c,v 1.36 2011/08/29 00:39:16 rmind Exp $ */ /*- * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. @@ -84,7 +84,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.35 2011/08/09 06:36:51 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.36 2011/08/29 00:39:16 rmind Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -103,6 +103,7 @@ #include <sys/atomic.h> #include <sys/socketvar.h> #include <sys/sleepq.h> +#include <sys/sysctl.h> /* Flags for lwp::l_selflag. */ #define SEL_RESET 0 /* awoken, interrupted, or not yet polling */ @@ -147,6 +148,7 @@ }; static selcluster_t *selcluster[SELCLUSTERS] __read_mostly; +static int direct_select __read_mostly = 0; /* * Select system call. @@ -378,9 +380,7 @@ fd_mask *ibitp, *obitp; int msk, i, j, fd, n; file_t *fp; - kmutex_t *lock; - lock = curlwp->l_selcluster->sc_lock; ibitp = (fd_mask *)(bits + ni * 0); obitp = (fd_mask *)(bits + ni * 3); n = 0; @@ -408,15 +408,15 @@ fd_putfile(fd); } if (obits != 0) { -#ifndef NO_DIRECT_SELECT - if (obits != *ibitp) + if (direct_select) { + kmutex_t *lock; + lock = curlwp->l_selcluster->sc_lock; mutex_spin_enter(lock); - *obitp |= obits; - if (obits != *ibitp) + *obitp |= obits; mutex_spin_exit(lock); -#else - *obitp |= obits; -#endif + } else { + *obitp |= obits; + } } ibitp++; obitp++; @@ -715,15 +715,15 @@ */ l = sip->sel_lwp; oflag = l->l_selflag; -#ifndef NO_DIRECT_SELECT - if (!sel_setevents(l, sip, events)) { + + if (!direct_select) { + l->l_selflag = SEL_RESET; + } else if (!sel_setevents(l, sip, events)) { /* No events to return. */ mutex_spin_exit(lock); return; } -#else - l->l_selflag = SEL_RESET; -#endif + /* * If thread is sleeping, wake it up. If it's not * yet asleep, it will notice the change in state @@ -932,3 +932,23 @@ error = 0; return (error); } + +/* + * System control nodes. + */ +SYSCTL_SETUP(sysctl_select_setup, "sysctl select setup") +{ + const struct sysctlnode *node = NULL; + + sysctl_createv(clog, 0, NULL, &node, + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "kern", NULL, + NULL, 0, NULL, 0, + CTL_KERN, CTL_EOL); + sysctl_createv(clog, 0, &node, NULL, + CTLFLAG_PERMANENT | CTLFLAG_READWRITE, + CTLTYPE_INT, "direct_select", + SYSCTL_DESCR("Enable/disable direct select (for testing)"), + NULL, 0, &direct_select, 0, + CTL_CREATE, CTL_EOL); +}