diff options
Diffstat (limited to 'fs/eventpoll.c')
-rw-r--r-- | fs/eventpoll.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 96355d505347..011b9b8c90c6 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -234,8 +234,6 @@ struct ep_pqueue { | |||
234 | /* | 234 | /* |
235 | * Configuration options available inside /proc/sys/fs/epoll/ | 235 | * Configuration options available inside /proc/sys/fs/epoll/ |
236 | */ | 236 | */ |
237 | /* Maximum number of epoll devices, per user */ | ||
238 | static int max_user_instances __read_mostly; | ||
239 | /* Maximum number of epoll watched descriptors, per user */ | 237 | /* Maximum number of epoll watched descriptors, per user */ |
240 | static int max_user_watches __read_mostly; | 238 | static int max_user_watches __read_mostly; |
241 | 239 | ||
@@ -261,14 +259,6 @@ static int zero; | |||
261 | 259 | ||
262 | ctl_table epoll_table[] = { | 260 | ctl_table epoll_table[] = { |
263 | { | 261 | { |
264 | .procname = "max_user_instances", | ||
265 | .data = &max_user_instances, | ||
266 | .maxlen = sizeof(int), | ||
267 | .mode = 0644, | ||
268 | .proc_handler = &proc_dointvec_minmax, | ||
269 | .extra1 = &zero, | ||
270 | }, | ||
271 | { | ||
272 | .procname = "max_user_watches", | 262 | .procname = "max_user_watches", |
273 | .data = &max_user_watches, | 263 | .data = &max_user_watches, |
274 | .maxlen = sizeof(int), | 264 | .maxlen = sizeof(int), |
@@ -491,7 +481,6 @@ static void ep_free(struct eventpoll *ep) | |||
491 | 481 | ||
492 | mutex_unlock(&epmutex); | 482 | mutex_unlock(&epmutex); |
493 | mutex_destroy(&ep->mtx); | 483 | mutex_destroy(&ep->mtx); |
494 | atomic_dec(&ep->user->epoll_devs); | ||
495 | free_uid(ep->user); | 484 | free_uid(ep->user); |
496 | kfree(ep); | 485 | kfree(ep); |
497 | } | 486 | } |
@@ -581,10 +570,6 @@ static int ep_alloc(struct eventpoll **pep) | |||
581 | struct eventpoll *ep; | 570 | struct eventpoll *ep; |
582 | 571 | ||
583 | user = get_current_user(); | 572 | user = get_current_user(); |
584 | error = -EMFILE; | ||
585 | if (unlikely(atomic_read(&user->epoll_devs) >= | ||
586 | max_user_instances)) | ||
587 | goto free_uid; | ||
588 | error = -ENOMEM; | 573 | error = -ENOMEM; |
589 | ep = kzalloc(sizeof(*ep), GFP_KERNEL); | 574 | ep = kzalloc(sizeof(*ep), GFP_KERNEL); |
590 | if (unlikely(!ep)) | 575 | if (unlikely(!ep)) |
@@ -1110,7 +1095,7 @@ retry: | |||
1110 | /* | 1095 | /* |
1111 | * Open an eventpoll file descriptor. | 1096 | * Open an eventpoll file descriptor. |
1112 | */ | 1097 | */ |
1113 | asmlinkage long sys_epoll_create1(int flags) | 1098 | SYSCALL_DEFINE1(epoll_create1, int, flags) |
1114 | { | 1099 | { |
1115 | int error, fd = -1; | 1100 | int error, fd = -1; |
1116 | struct eventpoll *ep; | 1101 | struct eventpoll *ep; |
@@ -1141,7 +1126,6 @@ asmlinkage long sys_epoll_create1(int flags) | |||
1141 | flags & O_CLOEXEC); | 1126 | flags & O_CLOEXEC); |
1142 | if (fd < 0) | 1127 | if (fd < 0) |
1143 | ep_free(ep); | 1128 | ep_free(ep); |
1144 | atomic_inc(&ep->user->epoll_devs); | ||
1145 | 1129 | ||
1146 | error_return: | 1130 | error_return: |
1147 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", | 1131 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", |
@@ -1150,7 +1134,7 @@ error_return: | |||
1150 | return fd; | 1134 | return fd; |
1151 | } | 1135 | } |
1152 | 1136 | ||
1153 | asmlinkage long sys_epoll_create(int size) | 1137 | SYSCALL_DEFINE1(epoll_create, int, size) |
1154 | { | 1138 | { |
1155 | if (size < 0) | 1139 | if (size < 0) |
1156 | return -EINVAL; | 1140 | return -EINVAL; |
@@ -1163,8 +1147,8 @@ asmlinkage long sys_epoll_create(int size) | |||
1163 | * the eventpoll file that enables the insertion/removal/change of | 1147 | * the eventpoll file that enables the insertion/removal/change of |
1164 | * file descriptors inside the interest set. | 1148 | * file descriptors inside the interest set. |
1165 | */ | 1149 | */ |
1166 | asmlinkage long sys_epoll_ctl(int epfd, int op, int fd, | 1150 | SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, |
1167 | struct epoll_event __user *event) | 1151 | struct epoll_event __user *, event) |
1168 | { | 1152 | { |
1169 | int error; | 1153 | int error; |
1170 | struct file *file, *tfile; | 1154 | struct file *file, *tfile; |
@@ -1261,8 +1245,8 @@ error_return: | |||
1261 | * Implement the event wait interface for the eventpoll file. It is the kernel | 1245 | * Implement the event wait interface for the eventpoll file. It is the kernel |
1262 | * part of the user space epoll_wait(2). | 1246 | * part of the user space epoll_wait(2). |
1263 | */ | 1247 | */ |
1264 | asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events, | 1248 | SYSCALL_DEFINE4(epoll_wait, int, epfd, struct epoll_event __user *, events, |
1265 | int maxevents, int timeout) | 1249 | int, maxevents, int, timeout) |
1266 | { | 1250 | { |
1267 | int error; | 1251 | int error; |
1268 | struct file *file; | 1252 | struct file *file; |
@@ -1319,9 +1303,9 @@ error_return: | |||
1319 | * Implement the event wait interface for the eventpoll file. It is the kernel | 1303 | * Implement the event wait interface for the eventpoll file. It is the kernel |
1320 | * part of the user space epoll_pwait(2). | 1304 | * part of the user space epoll_pwait(2). |
1321 | */ | 1305 | */ |
1322 | asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events, | 1306 | SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, |
1323 | int maxevents, int timeout, const sigset_t __user *sigmask, | 1307 | int, maxevents, int, timeout, const sigset_t __user *, sigmask, |
1324 | size_t sigsetsize) | 1308 | size_t, sigsetsize) |
1325 | { | 1309 | { |
1326 | int error; | 1310 | int error; |
1327 | sigset_t ksigmask, sigsaved; | 1311 | sigset_t ksigmask, sigsaved; |
@@ -1366,8 +1350,10 @@ static int __init eventpoll_init(void) | |||
1366 | struct sysinfo si; | 1350 | struct sysinfo si; |
1367 | 1351 | ||
1368 | si_meminfo(&si); | 1352 | si_meminfo(&si); |
1369 | max_user_instances = 128; | 1353 | /* |
1370 | max_user_watches = (((si.totalram - si.totalhigh) / 32) << PAGE_SHIFT) / | 1354 | * Allows top 4% of lomem to be allocated for epoll watches (per user). |
1355 | */ | ||
1356 | max_user_watches = (((si.totalram - si.totalhigh) / 25) << PAGE_SHIFT) / | ||
1371 | EP_ITEM_COST; | 1357 | EP_ITEM_COST; |
1372 | 1358 | ||
1373 | /* Initialize the structure used to perform safe poll wait head wake ups */ | 1359 | /* Initialize the structure used to perform safe poll wait head wake ups */ |