summaryrefslogtreecommitdiffstats
path: root/sys/sys/pipe.h
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-02-01 05:56:51 +0000
committerrwatson <rwatson@FreeBSD.org>2004-02-01 05:56:51 +0000
commitb8e797cfe04273fadc8e4c77b305325e0f1549f3 (patch)
tree02367146686e83fbaea5ff9d00e36f8d0cf2b688 /sys/sys/pipe.h
parent75249cf38e5ac423561abeb1906852c0579f9e3c (diff)
downloadFreeBSD-src-b8e797cfe04273fadc8e4c77b305325e0f1549f3.zip
FreeBSD-src-b8e797cfe04273fadc8e4c77b305325e0f1549f3.tar.gz
Coalesce pipe allocations and frees. Previously, the pipe code
would allocate two 'struct pipe's from the pipe zone, and malloc a mutex. - Create a new "struct pipepair" object holding the two 'struct pipe' instances, struct mutex, and struct label reference. Pipe structures now have a back-pointer to the pipe pair, and a 'pipe_present' flag to indicate whether the half has been closed. - Perform mutex init/destroy in zone init/destroy, avoiding reallocating the mutex for each pipe. Perform most pipe structure setup in zone constructor. - VM memory mappings for pageable buffers are still done outside of the UMA zone. - Change MAC API to speak 'struct pipepair' instead of 'struct pipe', update many policies. MAC labels are also handled outside of the UMA zone for now. Label-only policy modules don't have to be recompiled, but if a module is recompiled, its pipe entry points will need to be updated. If a module actually reached into the pipe structures (unlikely), that would also need to be modified. These changes substantially simplify failure handling in the pipe code as there are many fewer possible failure modes. On half-close, pipes no longer free the 'struct pipe' for the closed half until a full-close takes place. However, VM mapped buffers are still released on half-close. Some code refactoring is now possible to clean up some of the back references, etc; this patch attempts not to change the structure of most of the pipe implementation, only allocation/free code paths, so as to avoid introducing bugs (hopefully). This cuts about 8%-9% off the cost of sequential pipe allocation and free in system call tests on UP and SMP in my micro-benchmarks. May or may not make a difference in macro-benchmarks, but doing less work is good. Reviewed by: juli, tjr Testing help: dwhite, fenestro, scottl, et al
Diffstat (limited to 'sys/sys/pipe.h')
-rw-r--r--sys/sys/pipe.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h
index bdb9104..84464bd 100644
--- a/sys/sys/pipe.h
+++ b/sys/sys/pipe.h
@@ -113,13 +113,24 @@ struct pipe {
struct timespec pipe_ctime; /* time of status change */
struct sigio *pipe_sigio; /* information for async I/O */
struct pipe *pipe_peer; /* link with other direction */
+ struct pipepair *pipe_pair; /* container structure pointer */
u_int pipe_state; /* pipe status info */
int pipe_busy; /* busy flag, mostly to handle rundown sanely */
- struct label *pipe_label; /* pipe MAC label - shared */
- struct mtx *pipe_mtxp; /* shared mutex between both pipes */
+ int pipe_present; /* still present? */
};
-#define PIPE_MTX(pipe) (pipe)->pipe_mtxp
+/*
+ * Container structure to hold the two pipe endpoints, mutex, and label
+ * pointer.
+ */
+struct pipepair {
+ struct pipe pp_rpipe;
+ struct pipe pp_wpipe;
+ struct mtx pp_mtx;
+ struct label *pp_label;
+};
+
+#define PIPE_MTX(pipe) (&(pipe)->pipe_pair->pp_mtx)
#define PIPE_LOCK(pipe) mtx_lock(PIPE_MTX(pipe))
#define PIPE_UNLOCK(pipe) mtx_unlock(PIPE_MTX(pipe))
#define PIPE_LOCK_ASSERT(pipe, type) mtx_assert(PIPE_MTX(pipe), (type))
OpenPOWER on IntegriCloud