summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-07-23 14:11:04 +0000
committerrwatson <rwatson@FreeBSD.org>2004-07-23 14:11:04 +0000
commit882656d16c73f00727eb12c05f01ab01e471d8b1 (patch)
tree973f5e66bd2f89a5955fe2f0d899748ae35a4339 /sys/kern/sys_pipe.c
parent3654de90d4d4834214e36df0573e0872900e114c (diff)
downloadFreeBSD-src-882656d16c73f00727eb12c05f01ab01e471d8b1.zip
FreeBSD-src-882656d16c73f00727eb12c05f01ab01e471d8b1.tar.gz
Don't perform pipe endpoint locking during pipe_create(), as the pipe
can't yet be referenced by other threads. In microbenchmarks, this appears to reduce the cost of pipe();close();close() on UP by 10%, and SMP by 7%. The vast majority of the cost of allocating a pipe remains VM magic. Suggested by: silby
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index fa578e8..03f88e1 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -180,6 +180,7 @@ static int pipe_direct_write(struct pipe *wpipe, struct uio *uio);
static void pipe_clone_write_buffer(struct pipe *wpipe);
#endif
static int pipespace(struct pipe *cpipe, int size);
+static int pipespace_new(struct pipe *cpipe, int size);
static void pipe_zone_ctor(void *mem, int size, void *arg);
static void pipe_zone_dtor(void *mem, int size, void *arg);
@@ -383,7 +384,7 @@ pipe(td, uap)
* If it fails it will return ENOMEM.
*/
static int
-pipespace(cpipe, size)
+pipespace_new(cpipe, size)
struct pipe *cpipe;
int size;
{
@@ -425,6 +426,23 @@ pipespace(cpipe, size)
}
/*
+ * Wrapper for pipespace_new() that performs locking assertions.
+ */
+static int
+pipespace(cpipe, size)
+ struct pipe *cpipe;
+ int size;
+{
+
+ /*
+ * XXXRW: Seems like we should really assert PIPE_LOCKFL on the
+ * pipe_state here.
+ */
+
+ return (pipespace_new(cpipe, size));
+}
+
+/*
* lock a pipe for I/O, blocking other access
*/
static __inline int
@@ -488,9 +506,6 @@ pipe_create(pipe)
{
int error;
- PIPE_LOCK(pipe);
- pipelock(pipe, 0);
- PIPE_UNLOCK(pipe);
/*
* Reduce to 1/4th pipe size if we're over our global max.
*/
@@ -498,13 +513,7 @@ pipe_create(pipe)
error = pipespace(pipe, SMALL_PIPE_SIZE);
else
error = pipespace(pipe, PIPE_SIZE);
- PIPE_LOCK(pipe);
- pipeunlock(pipe);
- PIPE_UNLOCK(pipe);
- if (error)
- return (error);
-
- return (0);
+ return (error);
}
/* ARGSUSED */
OpenPOWER on IntegriCloud