aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/internal.h
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-06-26 03:25:55 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 12:58:25 -0400
commit99f895518368252ba862cc15ce4eb98ebbe1bec6 (patch)
treea9dcc01963221d1fd6a7e357b95d361ebfe91c6d /fs/proc/internal.h
parent8578cea7509cbdec25b31d08b48a92fcc3b1a9e3 (diff)
[PATCH] proc: don't lock task_structs indefinitely
Every inode in /proc holds a reference to a struct task_struct. If a directory or file is opened and remains open after the the task exits this pinning continues. With 8K stacks on a 32bit machine the amount pinned per file descriptor is about 10K. Normally I would figure a reasonable per user process limit is about 100 processes. With 80 processes, with a 1000 file descriptors each I can trigger the 00M killer on a 32bit kernel, because I have pinned about 800MB of useless data. This patch replaces the struct task_struct pointer with a pointer to a struct task_ref which has a struct task_struct pointer. The so the pinning of dead tasks does not happen. The code now has to contend with the fact that the task may now exit at any time. Which is a little but not muh more complicated. With this change it takes about 1000 processes each opening up 1000 file descriptors before I can trigger the OOM killer. Much better. [mlp@google.com: task_mmu small fixes] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: Paul Jackson <pj@sgi.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Albert Cahalan <acahalan@gmail.com> Signed-off-by: Prasanna Meda <mlp@google.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/proc/internal.h')
-rw-r--r--fs/proc/internal.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 548e7447ea47..37f1648adc23 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/proc_fs.h> 12#include <linux/proc_fs.h>
13#include <linux/task_ref.h>
13 14
14struct vmalloc_info { 15struct vmalloc_info {
15 unsigned long used; 16 unsigned long used;
@@ -41,13 +42,23 @@ extern struct file_operations proc_maps_operations;
41extern struct file_operations proc_numa_maps_operations; 42extern struct file_operations proc_numa_maps_operations;
42extern struct file_operations proc_smaps_operations; 43extern struct file_operations proc_smaps_operations;
43 44
45extern struct file_operations proc_maps_operations;
46extern struct file_operations proc_numa_maps_operations;
47extern struct file_operations proc_smaps_operations;
48
49
44void free_proc_entry(struct proc_dir_entry *de); 50void free_proc_entry(struct proc_dir_entry *de);
45 51
46int proc_init_inodecache(void); 52int proc_init_inodecache(void);
47 53
48static inline struct task_struct *proc_task(struct inode *inode) 54static inline struct task_ref *proc_tref(struct inode *inode)
55{
56 return PROC_I(inode)->tref;
57}
58
59static inline struct task_struct *get_proc_task(struct inode *inode)
49{ 60{
50 return PROC_I(inode)->task; 61 return get_tref_task(proc_tref(inode));
51} 62}
52 63
53static inline int proc_fd(struct inode *inode) 64static inline int proc_fd(struct inode *inode)