summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAlexander Viro <viro@math.psu.edu>2002-04-21 23:03:37 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-04-21 23:03:37 -0700
commit0030633355db2bba32d97655df73b04215018ab9 (patch)
treeb5f226845875c106f4da600ee01fa08dbdd778d9 /kernel
parent981936da6234efee942e2b79f93f5c4be57a4ed4 (diff)
[PATCH] (3/5) sane procfs/dcache interaction
- sane dentry retention. Namely, we don't kill /proc/<pid> dentries at the first opportunity (as the current tree does). Instead we do the following: * ->d_delete() kills it only if process is already dead. * all ->lookup() in proc/base.c end with checking if process is still alive and unhash if it isn't. * proc_pid_lookup() (lookup for /proc/<pid>) caches reference to dentry in task_struct. It's _not_ counted in ->d_count. * ->d_iput() resets said reference to NULL. * release_task() (burying a zombie) checks if there is a cached reference and if there is - shrinks the subtree. * tasklist_lock is used for exclusion. That way we are guaranteed that after release_task() all dentries in /proc/<pid> will go away as soon as possible; OTOH, before release_task() we have normal retention policy - they go away under memory pressure with the same rules as for dentries on any other fs.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c15
-rw-r--r--kernel/fork.c1
2 files changed, 16 insertions, 0 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 58b05e3ef9f8..e3fdd078f449 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -29,13 +29,28 @@ int getrusage(struct task_struct *, int, struct rusage *);
static inline void __unhash_process(struct task_struct *p)
{
+ struct dentry *proc_dentry;
write_lock_irq(&tasklist_lock);
nr_threads--;
unhash_pid(p);
REMOVE_LINKS(p);
list_del(&p->thread_group);
p->pid = 0;
+ proc_dentry = p->proc_dentry;
+ if (unlikely(proc_dentry)) {
+ spin_lock(&dcache_lock);
+ if (!list_empty(&proc_dentry->d_hash)) {
+ dget_locked(proc_dentry);
+ list_del_init(&proc_dentry->d_hash);
+ } else
+ proc_dentry = NULL;
+ spin_unlock(&dcache_lock);
+ }
write_unlock_irq(&tasklist_lock);
+ if (unlikely(proc_dentry)) {
+ shrink_dcache_parent(proc_dentry);
+ dput(proc_dentry);
+ }
}
static void release_task(struct task_struct * p)
diff --git a/kernel/fork.c b/kernel/fork.c
index d7a274cbec95..380c1bafe75c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -665,6 +665,7 @@ int do_fork(unsigned long clone_flags, unsigned long stack_start,
copy_flags(clone_flags, p);
p->pid = get_pid(clone_flags);
+ p->proc_dentry = NULL;
INIT_LIST_HEAD(&p->run_list);