summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-02-03 04:55:24 +0000
committerrwatson <rwatson@FreeBSD.org>2004-02-03 04:55:24 +0000
commit37cfec7fef79ccd483161561cccdda547b0b5cd3 (patch)
tree5e048c8e8b10f39eaa5673b38b920ef9511ed3c0 /sys/kern
parent8ec8ff7672ef4b6b99e145cdd609754f9c4cbb17 (diff)
downloadFreeBSD-src-37cfec7fef79ccd483161561cccdda547b0b5cd3.zip
FreeBSD-src-37cfec7fef79ccd483161561cccdda547b0b5cd3.tar.gz
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
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_pipe.c5
1 files changed, 3 insertions, 2 deletions
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);
OpenPOWER on IntegriCloud