From owner-svn-src-all@FreeBSD.ORG Sat Jun 9 18:50:33 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A627106566C; Sat, 9 Jun 2012 18:50:33 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2624D8FC14; Sat, 9 Jun 2012 18:50:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q59IoXTY048601; Sat, 9 Jun 2012 18:50:33 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q59IoWIi048599; Sat, 9 Jun 2012 18:50:32 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206091850.q59IoWIi048599@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 9 Jun 2012 18:50:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236822 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jun 2012 18:50:33 -0000 Author: pjd Date: Sat Jun 9 18:50:32 2012 New Revision: 236822 URL: http://svn.freebsd.org/changeset/base/236822 Log: There is no need to drop the FILEDESC lock around malloc(M_WAITOK) anymore, as we now use sx lock for filedesc structure protection. Reviewed by: kib MFC after: 1 month Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Sat Jun 9 18:48:06 2012 (r236821) +++ head/sys/kern/kern_descrip.c Sat Jun 9 18:50:32 2012 (r236822) @@ -1428,9 +1428,7 @@ out: } /* - * Grow the file table to accomodate (at least) nfd descriptors. This may - * block and drop the filedesc lock, but it will reacquire it before - * returning. + * Grow the file table to accomodate (at least) nfd descriptors. */ static void fdgrowtable(struct filedesc *fdp, int nfd) @@ -1456,7 +1454,6 @@ fdgrowtable(struct filedesc *fdp, int nf return; /* allocate a new table and (if required) new bitmaps */ - FILEDESC_XUNLOCK(fdp); ntable = malloc((nnfiles * OFILESIZE) + sizeof(struct freetable), M_FILEDESC, M_ZERO | M_WAITOK); nfileflags = (char *)&ntable[nnfiles]; @@ -1465,20 +1462,7 @@ fdgrowtable(struct filedesc *fdp, int nf M_FILEDESC, M_ZERO | M_WAITOK); else nmap = NULL; - FILEDESC_XLOCK(fdp); - /* - * We now have new tables ready to go. Since we dropped the - * filedesc lock to call malloc(), watch out for a race. - */ - onfiles = fdp->fd_nfiles; - if (onfiles >= nnfiles) { - /* we lost the race, but that's OK */ - free(ntable, M_FILEDESC); - if (nmap != NULL) - free(nmap, M_FILEDESC); - return; - } bcopy(fdp->fd_ofiles, ntable, onfiles * sizeof(*ntable)); bcopy(fdp->fd_ofileflags, nfileflags, onfiles); otable = fdp->fd_ofiles;