Re: [patch] pipe: add support for shrinking and growing pipes

From: Michael Kerrisk
Date: Sat Jun 19 2010 - 01:46:24 EST


Hello Jens,

I've tested this F_SETPIPE_SZ code as it appears in 2.6.35-rc3, and
things seem to work as advertised, if the text below is the correct
advertisement. Could you please review the following man-pages text,
and let me know if it's okay.

fcntl.2:
F_SETPIPE_SZ (long; since Linux 2.6.35)
Change the capacity of the pipe referred to by
fd to be at least arg bytes. An unprivileged
process can adjust the pipe capacity to any
value between the system page size and the limit
defined in /proc/sys/fs/pipe-size-max (see
proc(5)). Attempts to set the pipe capacity
below the page size are silently rounded up to
the page size. Attempts by an unprivileged pro-
cess to set the pipe capacity above the limit in
/proc/sys/fs/pipe-size-max yield the error
EPERM; a privileged process (CAP_SYS_RESOURCE)
can override the limit. When allocating the
buffer for the pipe, the kernel may use a capac-
ity larger than arg, if that is convenient for
the implementation. The F_GETPIPE_SZ operation
returns the actual size used. Attempting to set
the pipe capacity smaller than the amount of
buffer space currently used to store data pro-
duces the error EBUSY.

F_GETPIPE_SZ (void; since Linux 2.6.35)
Return (as the function result) the capacity of
the pipe referred to by fd.

And in proc.5:
/proc/sys/fs/pipe-max-size (since Linux 2.6.35)
The value in this file defines an upper limit
for raising the capacity of a pipe using the
fcntl(2) F_SETPIPE_SZ operation. This limit
applies only to unprivileged processes. The
default value for this file is 1,048,576. The
value assigned to this file may be rounded
upward, to reflect the value actually employed
for a convenient implementation. To determine
the rounded-up value, display the contents of
this file after assigning a value to it. The
minimum value that can be assigned to this file
is the system page size.

Cheers,

Michael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/