From 37cfec7fef79ccd483161561cccdda547b0b5cd3 Mon Sep 17 00:00:00 2001 From: rwatson Date: Tue, 3 Feb 2004 04:55:24 +0000 Subject: Don't dec/inc the amountpipes counter every time we resize a pipe -- instead, just dec/inc in the ctor/dtor. For now, increment/decrement in two's, since we're now performing the operation once per pair, not once per pipe. Not really any measurable performance change in my micro-benchmarks, but doing less work is good, especially when it comes to atomic operations. Suggested by: alc --- sys/kern/sys_pipe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 0fc263c..3170847 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -255,6 +255,7 @@ pipe_zone_ctor(void *mem, int size, void *arg) */ pp->pp_label = NULL; + atomic_add_int(&amountpipes, 2); } static void @@ -265,6 +266,8 @@ pipe_zone_dtor(void *mem, int size, void *arg) KASSERT(size == sizeof(*pp), ("pipe_zone_dtor: wrong size")); pp = (struct pipepair *)mem; + + atomic_subtract_int(&amountpipes, 2); } static void @@ -428,7 +431,6 @@ pipespace(cpipe, size) cpipe->pipe_buffer.in = 0; cpipe->pipe_buffer.out = 0; cpipe->pipe_buffer.cnt = 0; - atomic_add_int(&amountpipes, 1); atomic_add_int(&amountpipekva, cpipe->pipe_buffer.size); return (0); } @@ -1410,7 +1412,6 @@ pipe_free_kmem(cpipe) if (cpipe->pipe_buffer.size > PIPE_SIZE) atomic_subtract_int(&nbigpipe, 1); atomic_subtract_int(&amountpipekva, cpipe->pipe_buffer.size); - atomic_subtract_int(&amountpipes, 1); vm_map_remove(pipe_map, (vm_offset_t)cpipe->pipe_buffer.buffer, (vm_offset_t)cpipe->pipe_buffer.buffer + cpipe->pipe_buffer.size); -- cgit v1.1