History

tty: rework pty count limiting

After adding devpts multiple-insrances sysctl kernel.pty.max limit pty count for each devpts instance independently, while kernel.pty.nr shows total pty count. This patch restores sysctl kernel.pty.max as global limit (4096 by default), adds pty reseve for main devpts (mounted without "newinstance" argument), and new sysctl to tune it: kernel.pty.reserve (1024 by default) Also it adds devpts mount option "max=%d" to limit pty count for each devpts instance independently. (by default NR_UNIX98_PTY_MAX == 2^20) Thus devpts instances in containers cannot eat up all available pty even if we didn't set any limits, while with "max" argument we can adjust limits more precisely. Plus, now open("/dev/ptmx") return -ENOSPC in case lack of pty indexes, this is more informative than -EIO.

Konstantin Khlebnikov committed 14 years ago

Commit e9aba511 parent a4834c12 files · +31 −4Browse files

Showing the changes to include (1 of 2 files). Show all

Unified · Split

include/linux/tty.h+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 * hardcoded at present.)
5353 */
5454 #define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
55+#define NR_UNIX98_PTY_RESERVE 1024 /* Default reserve for main devpts */
5556 #define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
5657
5758 /*