summaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-11-19 06:30:25 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-11-19 06:30:25 +0000
commit89744405e64b2116fbdd7d0e866a34731c96e4d5 (patch)
tree28f63053df17fc5af704822a00dace1f8b1051cf /sys/sys
parenta90c7d9aa82430454b3194d6750e0c0c748ac6dc (diff)
downloadsrc-test2-89744405e64b2116fbdd7d0e866a34731c96e4d5.tar.gz
src-test2-89744405e64b2116fbdd7d0e866a34731c96e4d5.zip
pipe: allow for lockless pipe_stat
pipes get stated all thet time and this avoidably contributed to contention. The pipe lock is only held to accomodate MAC and to check the type. Since normally there is no probe for pipe stat depessimize this by having the flag. The pipe_state field gets modified with locks held all the time and it's not feasible to convert them to use atomic store. Move the type flag away to a separate variable as a simple cleanup and to provide stable field to read. Use short for both fields to avoid growing the struct. While here short-circuit MAC for pipe_poll as well.
Notes
Notes: svn path=/head/; revision=367833
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/pipe.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h
index 2f1568ab6637..8bdfae8b2308 100644
--- a/sys/sys/pipe.h
+++ b/sys/sys/pipe.h
@@ -95,7 +95,11 @@ struct pipemapping {
#define PIPE_LWANT 0x200 /* Process wants exclusive access to pointers/data. */
#define PIPE_DIRECTW 0x400 /* Pipe direct write active. */
#define PIPE_DIRECTOK 0x800 /* Direct mode ok. */
-#define PIPE_NAMED 0x1000 /* Is a named pipe. */
+
+/*
+ * Bits in pipe_type.
+ */
+#define PIPE_TYPE_NAMED 0x001 /* Is a named pipe. */
/*
* Per-pipe data structure.
@@ -111,7 +115,8 @@ struct pipe {
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 */
+ u_short pipe_state; /* pipe status info */
+ u_short pipe_type; /* pipe type info */
int pipe_busy; /* busy flag, mostly to handle rundown sanely */
int pipe_present; /* still present? */
int pipe_wgen; /* writer generation for named pipe */