kern/85176: optimization of fdalloc

Divacky Roman xdivac02 at stud.fit.vutbr.cz
Sun Aug 21 08:20:20 GMT 2005


>Number:         85176
>Category:       kern
>Synopsis:       optimization of fdalloc
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 21 08:20:17 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Divacky Roman
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
home
>Environment:
FreeBSD witten 7.0-CURRENT FreeBSD 7.0-CURRENT #64: Sun Aug 21 09:42:53 CEST
2005     root at witten:/usr/obj/usr/src/sys/NEOLOGISM  i386


	
>Description:

fdalloc contains a dupliacte code which is removed by this patch + hinting by
fd_freefile, should be a bit faster

if commited - the commented code should/could be just removed
	
>How-To-Repeat:
apply the patch

>Fix:

Index: kern_descrip.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_descrip.c,v
retrieving revision 1.279
diff -u -r1.279 kern_descrip.c
--- kern_descrip.c	25 Jun 2005 03:34:49 -0000	1.279
+++ kern_descrip.c	21 Aug 2005 07:29:24 -0000
@@ -1242,6 +1242,9 @@
 	maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
 	PROC_UNLOCK(p);
 
+	/* hinting by fd_freefile */
+	if (fdp->fd_freefile > minfd)
+		minfd = fdp->fd_freefile;	   
 	/*
 	 * Search the bitmap for a free descriptor.  If none is found, try
 	 * to grow the file table.  Keep at it until we either get a file
@@ -1267,7 +1270,9 @@
 	    ("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);
+	/* this is done by fdused
+	 * fdp->fd_freefile = fd_first_free(fdp, fd, fdp->fd_nfiles);
+	 */
 	*result = fd;
 	return (0);
 }
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list