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
This commit is contained in:
rwatson 2004-07-23 14:11:04 +00:00
parent b844339aaf
commit 8db1fd099f

View File

@ -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;
{
@ -424,6 +425,23 @@ pipespace(cpipe, size)
return (0);
}
/*
* 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
*/
@ -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 */