diff options
author | Davide Libenzi <davidel@xmailserver.org> | 2008-12-01 16:13:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-01 22:55:24 -0500 |
commit | 7ef9964e6d1b911b78709f144000aacadd0ebc21 (patch) | |
tree | 30667d0a2f8e53973ff48d2c02df48bbc6fe74aa /Documentation/filesystems | |
parent | b7d271df873c5121a4ca1c70dea126b5920ec2f1 (diff) |
epoll: introduce resource usage limits
It has been thought that the per-user file descriptors limit would also
limit the resources that a normal user can request via the epoll
interface. Vegard Nossum reported a very simple program (a modified
version attached) that can make a normal user to request a pretty large
amount of kernel memory, well within the its maximum number of fds. To
solve such problem, default limits are now imposed, and /proc based
configuration has been introduced. A new directory has been created,
named /proc/sys/fs/epoll/ and inside there, there are two configuration
points:
max_user_instances = Maximum number of devices - per user
max_user_watches = Maximum number of "watched" fds - per user
The current default for "max_user_watches" limits the memory used by epoll
to store "watches", to 1/32 of the amount of the low RAM. As example, a
256MB 32bit machine, will have "max_user_watches" set to roughly 90000.
That should be enough to not break existing heavy epoll users. The
default value for "max_user_instances" is set to 128, that should be
enough too.
This also changes the userspace, because a new error code can now come out
from EPOLL_CTL_ADD (-ENOSPC). The EMFILE from epoll_create() was already
listed, so that should be ok.
[akpm@linux-foundation.org: use get_current_user()]
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: <stable@kernel.org>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Reported-by: Vegard Nossum <vegardno@ifi.uio.no>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/filesystems')
-rw-r--r-- | Documentation/filesystems/proc.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index bcceb99b81dd..bb1b0dd3bfcb 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -44,6 +44,7 @@ Table of Contents | |||
44 | 2.14 /proc/<pid>/io - Display the IO accounting fields | 44 | 2.14 /proc/<pid>/io - Display the IO accounting fields |
45 | 2.15 /proc/<pid>/coredump_filter - Core dump filtering settings | 45 | 2.15 /proc/<pid>/coredump_filter - Core dump filtering settings |
46 | 2.16 /proc/<pid>/mountinfo - Information about mounts | 46 | 2.16 /proc/<pid>/mountinfo - Information about mounts |
47 | 2.17 /proc/sys/fs/epoll - Configuration options for the epoll interface | ||
47 | 48 | ||
48 | ------------------------------------------------------------------------------ | 49 | ------------------------------------------------------------------------------ |
49 | Preface | 50 | Preface |
@@ -2483,4 +2484,30 @@ For more information on mount propagation see: | |||
2483 | 2484 | ||
2484 | Documentation/filesystems/sharedsubtree.txt | 2485 | Documentation/filesystems/sharedsubtree.txt |
2485 | 2486 | ||
2487 | 2.17 /proc/sys/fs/epoll - Configuration options for the epoll interface | ||
2488 | -------------------------------------------------------- | ||
2489 | |||
2490 | This directory contains configuration options for the epoll(7) interface. | ||
2491 | |||
2492 | max_user_instances | ||
2493 | ------------------ | ||
2494 | |||
2495 | This is the maximum number of epoll file descriptors that a single user can | ||
2496 | have open at a given time. The default value is 128, and should be enough | ||
2497 | for normal users. | ||
2498 | |||
2499 | max_user_watches | ||
2500 | ---------------- | ||
2501 | |||
2502 | Every epoll file descriptor can store a number of files to be monitored | ||
2503 | for event readiness. Each one of these monitored files constitutes a "watch". | ||
2504 | This configuration option sets the maximum number of "watches" that are | ||
2505 | allowed for each user. | ||
2506 | Each "watch" costs roughly 90 bytes on a 32bit kernel, and roughly 160 bytes | ||
2507 | on a 64bit one. | ||
2508 | The current default value for max_user_watches is the 1/32 of the available | ||
2509 | low memory, divided for the "watch" cost in bytes. | ||
2510 | |||
2511 | |||
2486 | ------------------------------------------------------------------------------ | 2512 | ------------------------------------------------------------------------------ |
2513 | |||