kern/86290: minor optimizations + cleanup to vrele usage + stuff
Divacky Roman
xdivac02 at stud.fit.vutbr.cz
Sun Sep 18 02:30:06 PDT 2005
>Number: 86290
>Category: kern
>Synopsis: minor optimizations + cleanup to vrele usage + stuff
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Sun Sep 18 09:30:05 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 #93: Sat Sep 17 14:02:36 CEST
2005 root at witten:/usr/obj/usr/src/sys/NEOLOGISM i386
>Description:
this patch removes some Giant locking which I believe is unecessary. it also
cleans up one nasty naming bug.
>How-To-Repeat:
apply the patch
>Fix:
? cscope.out
Index: kern_exit.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_exit.c,v
retrieving revision 1.265
diff -u -r1.265 kern_exit.c
--- kern_exit.c 2 Sep 2005 20:20:01 -0000 1.265
+++ kern_exit.c 17 Sep 2005 12:00:46 -0000
@@ -227,7 +227,6 @@
* Reset any sigio structures pointing to us as a result of
* F_SETOWN with our pid.
*/
- mtx_lock(&Giant); /* XXX: not sure if needed */
funsetownlst(&p->p_sigiolst);
/*
@@ -235,7 +234,6 @@
* This may block!
*/
fdfree(td);
- mtx_unlock(&Giant);
/*
* If this thread tickled GEOM, we need to wait for the giggling to
@@ -360,11 +358,8 @@
p->p_tracecred = NULL;
mtx_unlock(&ktrace_mtx);
PROC_UNLOCK(p);
- if (tracevp != NULL) {
- mtx_lock(&Giant);
+ if (tracevp != NULL)
vrele(tracevp);
- mtx_unlock(&Giant);
- }
if (tracecred != NULL)
crfree(tracecred);
#endif
@@ -373,9 +368,7 @@
*/
if ((vtmp = p->p_textvp) != NULL) {
p->p_textvp = NULL;
- mtx_lock(&Giant);
vrele(vtmp);
- mtx_unlock(&Giant);
}
/*
@@ -452,7 +445,7 @@
mtx_unlock(&p->p_pptr->p_sigacts->ps_mtx);
pp = p->p_pptr;
- PROC_UNLOCK(pp);
+ PROC_UNLOCK(p->p_pptr);
proc_reparent(p, initproc);
p->p_sigparent = SIGCHLD;
PROC_LOCK(p->p_pptr);
Index: kern_jail.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_jail.c,v
retrieving revision 1.50
diff -u -r1.50 kern_jail.c
--- kern_jail.c 23 Jun 2005 22:13:28 -0000 1.50
+++ kern_jail.c 17 Sep 2005 12:00:46 -0000
@@ -174,9 +174,7 @@
prisoncount--;
mtx_unlock(&allprison_mtx);
e_dropvnref:
- mtx_lock(&Giant);
vrele(pr->pr_root);
- mtx_unlock(&Giant);
e_killmtx:
mtx_destroy(&pr->pr_mtx);
FREE(pr, M_PRISON);
@@ -298,9 +296,7 @@
pr = (struct prison *)context;
- mtx_lock(&Giant);
vrele(pr->pr_root);
- mtx_unlock(&Giant);
mtx_destroy(&pr->pr_mtx);
if (pr->pr_linux != NULL)
Index: kern_ktrace.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_ktrace.c,v
retrieving revision 1.101
diff -u -r1.101 kern_ktrace.c
--- kern_ktrace.c 24 Jun 2005 12:05:24 -0000 1.101
+++ kern_ktrace.c 17 Sep 2005 12:00:46 -0000
@@ -267,11 +267,8 @@
{
crfree(req->ktr_cred);
- if (req->ktr_vp != NULL) {
- mtx_lock(&Giant);
+ if (req->ktr_vp != NULL)
vrele(req->ktr_vp);
- mtx_unlock(&Giant);
- }
if (req->ktr_header.ktr_buffer != NULL)
free(req->ktr_header.ktr_buffer, M_KTRACE);
mtx_lock(&ktrace_mtx);
@@ -739,11 +736,8 @@
}
mtx_unlock(&ktrace_mtx);
PROC_UNLOCK(p);
- if (tracevp != NULL) {
- mtx_lock(&Giant);
+ if (tracevp != NULL)
vrele(tracevp);
- mtx_unlock(&Giant);
- }
if (tracecred != NULL)
crfree(tracecred);
@@ -893,10 +887,8 @@
}
}
mtx_unlock(&ktrace_mtx);
- mtx_lock(&Giant);
while (vrele_count-- > 0)
vrele(vp);
- mtx_unlock(&Giant);
}
/*
Index: uipc_usrreq.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.155
diff -u -r1.155 uipc_usrreq.c
--- uipc_usrreq.c 7 May 2005 00:41:35 -0000 1.155
+++ uipc_usrreq.c 17 Sep 2005 12:00:46 -0000
@@ -809,11 +809,8 @@
if (unp->unp_addr != NULL)
FREE(unp->unp_addr, M_SONAME);
uma_zfree(unp_zone, unp);
- if (vp) {
- mtx_lock(&Giant);
+ if (vp)
vrele(vp);
- mtx_unlock(&Giant);
- }
}
static int
Index: vfs_lookup.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_lookup.c,v
retrieving revision 1.82
diff -u -r1.82 vfs_lookup.c
--- vfs_lookup.c 15 Sep 2005 15:03:48 -0000 1.82
+++ vfs_lookup.c 17 Sep 2005 12:00:47 -0000
@@ -940,6 +940,7 @@
char *ptr, *buf, *cp;
size_t len, sz;
int error;
+ int vfslocked;
buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
*pathbuf = buf;
@@ -972,8 +973,7 @@
goto keeporig;
}
- /* XXX: VFS_LOCK_GIANT? */
- mtx_lock(&Giant);
+ vfslocked = VFS_LOCK_GIANT((struct mount *)NULL);
/*
* We know that there is a / somewhere in this pathname.
@@ -1024,8 +1024,7 @@
vrele(nd.ni_vp);
nd_failed:
- /* XXX: VFS_UNLOCK_GIANT? */
- mtx_unlock(&Giant);
+ VFS_UNLOCK_GIANT(vfslocked);
keeporig:
/* If there was an error, use the original path name. */
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list