summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2003-08-04 21:28:57 +0000
committerdwmalone <dwmalone@FreeBSD.org>2003-08-04 21:28:57 +0000
commitcb188056e62a5c06bc394877c8f8de9d7aaab12a (patch)
treec9a9c08ec8d172189d451bf5f992b882c5108b89 /sys
parent86595fbca8000280383d4bc1addea14e37231afe (diff)
downloadFreeBSD-src-cb188056e62a5c06bc394877c8f8de9d7aaab12a.zip
FreeBSD-src-cb188056e62a5c06bc394877c8f8de9d7aaab12a.tar.gz
Do some minor Giant pushdown made possible by copyin, fget, fdrop,
malloc and mbuf allocation all not requiring Giant. 1) ostat, fstat and nfstat don't need Giant until they call fo_stat. 2) accept can copyin the address length without grabbing Giant. 3) sendit doesn't need Giant, so don't bother grabbing it until kern_sendit. 4) move Giant grabbing from each indivitual recv* syscall to recvit.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_descrip.c12
-rw-r--r--sys/kern/uipc_syscalls.c21
2 files changed, 14 insertions, 19 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index be1a30f..c2a6eea 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -900,17 +900,17 @@ ofstat(td, uap)
struct ostat oub;
int error;
- mtx_lock(&Giant);
if ((error = fget(td, uap->fd, &fp)) != 0)
goto done2;
+ mtx_lock(&Giant);
error = fo_stat(fp, &ub, td->td_ucred, td);
+ mtx_unlock(&Giant);
if (error == 0) {
cvtstat(&ub, &oub);
error = copyout(&oub, uap->sb, sizeof(oub));
}
fdrop(fp, td);
done2:
- mtx_unlock(&Giant);
return (error);
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
@@ -937,15 +937,15 @@ fstat(td, uap)
struct stat ub;
int error;
- mtx_lock(&Giant);
if ((error = fget(td, uap->fd, &fp)) != 0)
goto done2;
+ mtx_lock(&Giant);
error = fo_stat(fp, &ub, td->td_ucred, td);
+ mtx_unlock(&Giant);
if (error == 0)
error = copyout(&ub, uap->sb, sizeof(ub));
fdrop(fp, td);
done2:
- mtx_unlock(&Giant);
return (error);
}
@@ -972,17 +972,17 @@ nfstat(td, uap)
struct nstat nub;
int error;
- mtx_lock(&Giant);
if ((error = fget(td, uap->fd, &fp)) != 0)
goto done2;
+ mtx_lock(&Giant);
error = fo_stat(fp, &ub, td->td_ucred, td);
+ mtx_unlock(&Giant);
if (error == 0) {
cvtnstat(&ub, &nub);
error = copyout(&nub, uap->sb, sizeof(nub));
}
fdrop(fp, td);
done2:
- mtx_unlock(&Giant);
return (error);
}
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 06b88d3..9bd2638 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -261,17 +261,17 @@ accept1(td, uap, compat)
pid_t pgid;
int tmp;
- mtx_lock(&Giant);
fdp = td->td_proc->p_fd;
if (uap->name) {
error = copyin(uap->anamelen, &namelen, sizeof (namelen));
if(error)
- goto done2;
+ goto done3;
if (namelen < 0) {
error = EINVAL;
- goto done2;
+ goto done3;
}
}
+ mtx_lock(&Giant);
error = fgetsock(td, uap->s, &head, &fflag);
if (error)
goto done2;
@@ -419,6 +419,7 @@ done:
fputsock(head);
done2:
mtx_unlock(&Giant);
+done3:
return (error);
}
@@ -625,7 +626,6 @@ sendit(td, s, mp, flags)
struct sockaddr *to;
int error;
- mtx_lock(&Giant);
if (mp->msg_name != NULL) {
error = getsockaddr(&to, mp->msg_name, mp->msg_namelen);
if (error) {
@@ -674,7 +674,6 @@ sendit(td, s, mp, flags)
bad:
if (to)
FREE(to, M_SONAME);
- mtx_unlock(&Giant);
return (error);
}
@@ -697,6 +696,7 @@ kern_sendit(td, s, mp, flags, control)
int iovlen;
#endif
+ mtx_lock(&Giant);
if ((error = fgetsock(td, s, &so, NULL)) != 0)
goto bad2;
@@ -757,6 +757,7 @@ kern_sendit(td, s, mp, flags, control)
bad:
fputsock(so);
bad2:
+ mtx_unlock(&Giant);
return (error);
}
@@ -935,6 +936,7 @@ recvit(td, s, mp, namelenp)
int iovlen;
#endif
+ mtx_lock(&Giant);
if ((error = fgetsock(td, s, &so, NULL)) != 0)
return (error);
@@ -1065,6 +1067,7 @@ recvit(td, s, mp, namelenp)
}
out:
fputsock(so);
+ mtx_unlock(&Giant);
if (fromsa)
FREE(fromsa, M_SONAME);
if (control)
@@ -1091,7 +1094,6 @@ recvfrom(td, uap)
struct iovec aiov;
int error;
- mtx_lock(&Giant);
if (uap->fromlenaddr) {
error = copyin(uap->fromlenaddr,
&msg.msg_namelen, sizeof (msg.msg_namelen));
@@ -1109,7 +1111,6 @@ recvfrom(td, uap)
msg.msg_flags = uap->flags;
error = recvit(td, uap->s, &msg, uap->fromlenaddr);
done2:
- mtx_unlock(&Giant);
return(error);
}
@@ -1147,7 +1148,6 @@ orecv(td, uap)
struct iovec aiov;
int error;
- mtx_lock(&Giant);
msg.msg_name = 0;
msg.msg_namelen = 0;
msg.msg_iov = &aiov;
@@ -1157,7 +1157,6 @@ orecv(td, uap)
msg.msg_control = 0;
msg.msg_flags = uap->flags;
error = recvit(td, uap->s, &msg, NULL);
- mtx_unlock(&Giant);
return (error);
}
@@ -1185,7 +1184,6 @@ orecvmsg(td, uap)
if (error)
return (error);
- mtx_lock(&Giant);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) {
error = EMSGSIZE;
@@ -1212,7 +1210,6 @@ done:
if (iov != aiov)
FREE(iov, M_IOV);
done2:
- mtx_unlock(&Giant);
return (error);
}
#endif
@@ -1233,7 +1230,6 @@ recvmsg(td, uap)
struct iovec aiov[UIO_SMALLIOV], *uiov, *iov;
register int error;
- mtx_lock(&Giant);
error = copyin(uap->msg, &msg, sizeof (msg));
if (error)
goto done2;
@@ -1268,7 +1264,6 @@ done:
if (iov != aiov)
FREE(iov, M_IOV);
done2:
- mtx_unlock(&Giant);
return (error);
}
OpenPOWER on IntegriCloud