From owner-p4-projects@FreeBSD.ORG Mon Mar 27 13:43:00 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E882C16A420; Mon, 27 Mar 2006 13:42:59 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AB55516A401 for ; Mon, 27 Mar 2006 13:42:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E95E43D5C for ; Mon, 27 Mar 2006 13:42:59 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2RDgxLw016860 for ; Mon, 27 Mar 2006 13:42:59 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2RDgxRR016857 for perforce@freebsd.org; Mon, 27 Mar 2006 13:42:59 GMT (envelope-from jhb@freebsd.org) Date: Mon, 27 Mar 2006 13:42:59 GMT Message-Id: <200603271342.k2RDgxRR016857@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 94109 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Mar 2006 13:43:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=94109 Change 94109 by jhb@jhb_tibook on 2006/03/27 13:42:14 Use MPSAFE vn_open() to conditionally grab Giant around VFS operations in the kernel linker. Affected files ... .. //depot/projects/smpng/sys/kern/kern_linker.c#44 edit .. //depot/projects/smpng/sys/kern/link_elf.c#33 edit .. //depot/projects/smpng/sys/kern/link_elf_obj.c#9 edit .. //depot/projects/smpng/sys/notes#69 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_linker.c#44 (text+ko) ==== @@ -1406,7 +1406,7 @@ struct nameidata nd; struct thread *td = curthread; /* XXX */ char *result, **cpp, *sep; - int error, len, extlen, reclen, flags; + int error, len, extlen, reclen, flags, vfslocked; enum vtype type; extlen = 0; @@ -1427,16 +1427,18 @@ * Attempt to open the file, and return the path if * we succeed and it's a regular file. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, td); + NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, result, td); flags = FREAD; error = vn_open(&nd, &flags, 0, -1); if (error == 0) { + vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); type = nd.ni_vp->v_type; if (vap) VOP_GETATTR(nd.ni_vp, vap, td->td_ucred, td); VOP_UNLOCK(nd.ni_vp, 0, td); vn_close(nd.ni_vp, FREAD, td->td_ucred, td); + VFS_UNLOCK_GIANT(vfslocked); if (type == VREG) return (result); } @@ -1464,6 +1466,7 @@ u_char *hints = NULL; u_char *cp, *recptr, *bufend, *result, *best, *pathbuf, *sep; int error, ival, bestver, *intp, reclen, found, flags, clen, blen; + int vfslocked = 0; result = NULL; bestver = found = 0; @@ -1475,13 +1478,14 @@ snprintf(pathbuf, reclen, "%.*s%s%s", pathlen, path, sep, linker_hintfile); - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, td); + NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, pathbuf, td); flags = FREAD; error = vn_open(&nd, &flags, 0, -1); if (error) goto bad; + vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); - if (nd.ni_vp->v_type != VREG) + if (nd.ni_vp->v_type != VREG) { goto bad; best = cp = NULL; error = VOP_GETATTR(nd.ni_vp, &vattr, cred, td); @@ -1503,6 +1507,7 @@ goto bad; VOP_UNLOCK(nd.ni_vp, 0, td); vn_close(nd.ni_vp, FREAD, cred, td); + VFS_UNLOCK_GIANT(vfslocked); nd.ni_vp = NULL; if (reclen != 0) { printf("can't read %d\n", reclen); @@ -1571,6 +1576,7 @@ if (nd.ni_vp != NULL) { VOP_UNLOCK(nd.ni_vp, 0, td); vn_close(nd.ni_vp, FREAD, cred, td); + VFS_UNLOCK_GIANT(vfslocked); } /* * If nothing found or hints is absent - fallback to the old ==== //depot/projects/smpng/sys/kern/link_elf.c#33 (text+ko) ==== @@ -556,17 +556,17 @@ int symstrindex; int symcnt; int strcnt; - - GIANT_REQUIRED; + int vfslocked; shdr = NULL; lf = NULL; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); + NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, filename, td); flags = FREAD; error = vn_open(&nd, &flags, 0, -1); if (error) return error; + vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC error = mac_check_kld_load(curthread->td_ucred, nd.ni_vp); @@ -859,6 +859,7 @@ free(firstpage, M_LINKER); VOP_UNLOCK(nd.ni_vp, 0, td); vn_close(nd.ni_vp, FREAD, td->td_ucred, td); + VFS_UNLOCK_GIANT(vfslocked); return error; } ==== //depot/projects/smpng/sys/kern/link_elf_obj.c#9 (text+ko) ==== @@ -393,19 +393,19 @@ int nsym; int pb, rl, ra; int alignmask; - - GIANT_REQUIRED; + int vfslocked; shdr = NULL; lf = NULL; mapsize = 0; hdr = NULL; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); + NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, filename, td); flags = FREAD; error = vn_open(&nd, &flags, 0, -1); if (error) return error; + vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC error = mac_check_kld_load(td->td_ucred, nd.ni_vp); @@ -788,6 +788,7 @@ free(hdr, M_LINKER); VOP_UNLOCK(nd.ni_vp, 0, td); vn_close(nd.ni_vp, FREAD, td->td_ucred, td); + VFS_UNLOCK_GIANT(vfslocked); return error; } ==== //depot/projects/smpng/sys/notes#69 (text+ko) ==== @@ -104,6 +104,7 @@ + linker_load_module + linker_file_lookup_set + linker_file_unload + - really remove Giant Active child branches: - jhb_intr - fast ithreads and MSI? (perhaps do MSI in jhb_acpipci)