summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2005-08-26 11:16:39 +0000
committerdes <des@FreeBSD.org>2005-08-26 11:16:39 +0000
commit6222a26a3b2248379acb5ba8ed9923029ccd8a9a (patch)
tree682e5a10d186fecfd6eac02e49889e99d69cafe8 /sys
parent7c5f6cabc9239f2525eb117021754427d7f1d202 (diff)
downloadFreeBSD-src-6222a26a3b2248379acb5ba8ed9923029ccd8a9a.zip
FreeBSD-src-6222a26a3b2248379acb5ba8ed9923029ccd8a9a.tar.gz
Two minor optimizations of fdalloc():
- if minfd < fd_freefile (as is most often the case, since minfd is usually 0), set it to fd_freefile. - remove a call to fd_first_free() which duplicates work already done by fdused(). This change results in a small but measurable speedup for processes with large numbers (several thousands) of open files. PR: kern/85176 Submitted by: Divacky Roman <xdivac02@stud.fit.vutbr.cz> MFC after: 3 weeks
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_descrip.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index d30fb65..c2bfb93 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1238,6 +1238,9 @@ fdalloc(struct thread *td, int minfd, int *result)
FILEDESC_LOCK_ASSERT(fdp, MA_OWNED);
+ if (fdp->fd_freefile > minfd)
+ minfd = fdp->fd_freefile;
+
PROC_LOCK(p);
maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
PROC_UNLOCK(p);
@@ -1267,7 +1270,6 @@ fdalloc(struct thread *td, int minfd, int *result)
("free descriptor isn't"));
fdp->fd_ofileflags[fd] = 0; /* XXX needed? */
fdused(fdp, fd);
- fdp->fd_freefile = fd_first_free(fdp, fd, fdp->fd_nfiles);
*result = fd;
return (0);
}
OpenPOWER on IntegriCloud