From xdivac02@stud.fit.vutbr.cz  Sun Aug 21 08:11:35 2005
Return-Path: <xdivac02@stud.fit.vutbr.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EBF3416A421
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 Aug 2005 08:11:35 +0000 (GMT)
	(envelope-from xdivac02@stud.fit.vutbr.cz)
Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.10.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 716DF43D5A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 Aug 2005 08:11:33 +0000 (GMT)
	(envelope-from xdivac02@stud.fit.vutbr.cz)
Received: from eva.fit.vutbr.cz (localhost [127.0.0.1])
	by eva.fit.vutbr.cz (envelope-from xdivac02@eva.fit.vutbr.cz) (8.13.4/8.13.3) with ESMTP id j7L8BUWm075667
	(version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 Aug 2005 10:11:30 +0200 (CEST)
Received: (from xdivac02@localhost)
	by eva.fit.vutbr.cz (8.13.4/8.13.3/Submit) id j7L8BU96075666;
	Sun, 21 Aug 2005 10:11:30 +0200 (CEST)
Message-Id: <200508210811.j7L8BU96075666@eva.fit.vutbr.cz>
Date: Sun, 21 Aug 2005 10:11:30 +0200 (CEST)
From: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
Reply-To: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: optimization of fdalloc
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         85176
>Category:       kern
>Synopsis:       [kernel] [patch] optimization of fdalloc
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 21 08:20:17 GMT 2005
>Closed-Date:    Sat Nov 11 00:46:05 GMT 2006
>Last-Modified:  Sat Nov 11 00:46:05 GMT 2006
>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@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:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Mon Aug 22 13:55:55 GMT 2005 
Responsible-Changed-Why:  
fdalloc is my baby. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85176 
State-Changed-From-To: open->patched 
State-Changed-By: des 
State-Changed-When: Fri Aug 26 11:17:27 GMT 2005 
State-Changed-Why:  
Committed to -CURRENT, awaiting MFC. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85176 
State-Changed-From-To: patched->closed 
State-Changed-By: des 
State-Changed-When: Sat Nov 11 00:46:03 UTC 2006 
State-Changed-Why:  
MFCed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85176 
>Unformatted:
