Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/sys_pipe.c
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | |||||
#define MINPIPESIZE (PIPE_SIZE/3) | #define MINPIPESIZE (PIPE_SIZE/3) | ||||
#define MAXPIPESIZE (2*PIPE_SIZE/3) | #define MAXPIPESIZE (2*PIPE_SIZE/3) | ||||
static long amountpipekva; | static long amountpipekva; | ||||
static int pipefragretry; | static int pipefragretry; | ||||
static int pipeallocfail; | static int pipeallocfail; | ||||
static int piperesizefail; | static int piperesizefail; | ||||
static int piperesizeallowed = 1; | static int piperesizeallowed = 1; | ||||
static long pipe_mindirect = PIPE_MINDIRECT; | |||||
SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, | SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, | ||||
&maxpipekva, 0, "Pipe KVA limit"); | &maxpipekva, 0, "Pipe KVA limit"); | ||||
SYSCTL_LONG(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD, | SYSCTL_LONG(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD, | ||||
&amountpipekva, 0, "Pipe KVA usage"); | &amountpipekva, 0, "Pipe KVA usage"); | ||||
SYSCTL_INT(_kern_ipc, OID_AUTO, pipefragretry, CTLFLAG_RD, | SYSCTL_INT(_kern_ipc, OID_AUTO, pipefragretry, CTLFLAG_RD, | ||||
&pipefragretry, 0, "Pipe allocation retries due to fragmentation"); | &pipefragretry, 0, "Pipe allocation retries due to fragmentation"); | ||||
SYSCTL_INT(_kern_ipc, OID_AUTO, pipeallocfail, CTLFLAG_RD, | SYSCTL_INT(_kern_ipc, OID_AUTO, pipeallocfail, CTLFLAG_RD, | ||||
Show All 39 Lines | pipe_zone = uma_zcreate("pipe", sizeof(struct pipepair), | ||||
UMA_ALIGN_PTR, 0); | UMA_ALIGN_PTR, 0); | ||||
KASSERT(pipe_zone != NULL, ("pipe_zone not initialized")); | KASSERT(pipe_zone != NULL, ("pipe_zone not initialized")); | ||||
new_unrhdr64(&pipeino_unr, 1); | new_unrhdr64(&pipeino_unr, 1); | ||||
pipedev_ino = devfs_alloc_cdp_inode(); | pipedev_ino = devfs_alloc_cdp_inode(); | ||||
KASSERT(pipedev_ino > 0, ("pipe dev inode not initialized")); | KASSERT(pipedev_ino > 0, ("pipe dev inode not initialized")); | ||||
} | } | ||||
static int | static int | ||||
sysctl_handle_pipe_mindirect(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
int error = 0; | |||||
long tmp_pipe_mindirect = pipe_mindirect; | |||||
error = sysctl_handle_long(oidp, &tmp_pipe_mindirect, arg2, req); | |||||
if (error != 0 || req->newptr == NULL) | |||||
jrtc27: style(9) is to not rely on implicit boolean conversions, ie != 0 and == NULL | |||||
return (error); | |||||
/* | |||||
* Don't allow pipe_mindirect to be set so low that we violate | |||||
* atomicity requirements. | |||||
*/ | |||||
if (tmp_pipe_mindirect <= PIPE_BUF) | |||||
return (EINVAL); | |||||
pipe_mindirect = tmp_pipe_mindirect; | |||||
return (0); | |||||
} | |||||
SYSCTL_OID(_kern_ipc, OID_AUTO, pipe_mindirect, CTLTYPE_LONG | CTLFLAG_RW, | |||||
&pipe_mindirect, 0, sysctl_handle_pipe_mindirect, "L", | |||||
"Minimum write size triggering VM optimization"); | |||||
static int | |||||
pipe_zone_ctor(void *mem, int size, void *arg, int flags) | pipe_zone_ctor(void *mem, int size, void *arg, int flags) | ||||
{ | { | ||||
struct pipepair *pp; | struct pipepair *pp; | ||||
struct pipe *rpipe, *wpipe; | struct pipe *rpipe, *wpipe; | ||||
KASSERT(size == sizeof(*pp), ("pipe_zone_ctor: wrong size")); | KASSERT(size == sizeof(*pp), ("pipe_zone_ctor: wrong size")); | ||||
pp = (struct pipepair *)mem; | pp = (struct pipepair *)mem; | ||||
▲ Show 20 Lines • Show All 860 Lines • ▼ Show 20 Lines | #ifndef PIPE_NODIRECT | ||||
* we do process-to-process copies directly. | * we do process-to-process copies directly. | ||||
* If the write is non-blocking, we don't use the | * If the write is non-blocking, we don't use the | ||||
* direct write mechanism. | * direct write mechanism. | ||||
* | * | ||||
* The direct write mechanism will detect the reader going | * The direct write mechanism will detect the reader going | ||||
* away on us. | * away on us. | ||||
*/ | */ | ||||
if (uio->uio_segflg == UIO_USERSPACE && | if (uio->uio_segflg == UIO_USERSPACE && | ||||
uio->uio_iov->iov_len >= PIPE_MINDIRECT && | uio->uio_iov->iov_len >= pipe_mindirect && | ||||
wpipe->pipe_buffer.size >= PIPE_MINDIRECT && | wpipe->pipe_buffer.size >= pipe_mindirect && | ||||
(fp->f_flag & FNONBLOCK) == 0) { | (fp->f_flag & FNONBLOCK) == 0) { | ||||
error = pipe_direct_write(wpipe, uio); | error = pipe_direct_write(wpipe, uio); | ||||
if (error != 0) | if (error != 0) | ||||
break; | break; | ||||
continue; | continue; | ||||
} | } | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 663 Lines • Show Last 20 Lines |
style(9) is to not rely on implicit boolean conversions, ie != 0 and == NULL