svn commit: r195259 - head/sys/kern
Jeff Roberson
jeff at FreeBSD.org
Wed Jul 1 20:43:47 UTC 2009
Author: jeff
Date: Wed Jul 1 20:43:46 2009
New Revision: 195259
URL: http://svn.freebsd.org/changeset/base/195259
Log:
- Use fd_lastfile + 1 as the upper bound on nd. This is more correct than
using the size of the descriptor array.
- A lock is not needed to fetch fd_lastfile. The results are stale the
instant it is dropped.
- Use a private mutex pool for select since the pool mutex is not used
as a leaf.
- Fetch the si_mtx pointer first before resorting to hashing to compute
the mutex address.
Reviewed by: McKusick
Approved by: re (kib)
Modified:
head/sys/kern/sys_generic.c
Modified: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c Wed Jul 1 20:42:17 2009 (r195258)
+++ head/sys/kern/sys_generic.c Wed Jul 1 20:43:46 2009 (r195259)
@@ -124,6 +124,7 @@ struct selfd {
};
static uma_zone_t selfd_zone;
+static struct mtx_pool *mtxpool_select;
#ifndef _SYS_SYSPROTO_H_
struct read_args {
@@ -794,11 +795,8 @@ kern_select(struct thread *td, int nd, f
if (nd < 0)
return (EINVAL);
fdp = td->td_proc->p_fd;
-
- FILEDESC_SLOCK(fdp);
- if (nd > td->td_proc->p_fd->fd_nfiles)
- nd = td->td_proc->p_fd->fd_nfiles; /* forgiving; slightly wrong */
- FILEDESC_SUNLOCK(fdp);
+ if (nd > fdp->fd_lastfile + 1)
+ nd = fdp->fd_lastfile + 1;
/*
* Allocate just enough bits for the non-null fd_sets. Use the
@@ -1373,7 +1371,9 @@ selrecord(selector, sip)
stp->st_free2 = NULL;
else
panic("selrecord: No free selfd on selq");
- mtxp = mtx_pool_find(mtxpool_sleep, sip);
+ mtxp = sip->si_mtx;
+ if (mtxp == NULL)
+ mtxp = mtx_pool_find(mtxpool_select, sip);
/*
* Initialize the sfp and queue it in the thread.
*/
@@ -1529,6 +1529,8 @@ SYSINIT(select, SI_SUB_SYSCALLS, SI_ORDE
static void
selectinit(void *dummy __unused)
{
+
selfd_zone = uma_zcreate("selfd", sizeof(struct selfd), NULL, NULL,
NULL, NULL, UMA_ALIGN_PTR, 0);
+ mtxpool_select = mtx_pool_create("select mtxpool", 128, MTX_DEF);
}
More information about the svn-src-head
mailing list