mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
[PATCH] pidhash: don't count idle threads
fork_idle() does unhash_process() just after copy_process(). Contrary, boot_cpu's idle thread explicitely registers itself for each pid_type with nr = 0. copy_process() already checks p->pid != 0 before process_counts++, I think we can just skip attach_pid() calls and job control inits for idle threads and kill unhash_process(). We don't need to cleanup ->proc_dentry in fork_idle() because with this patch idle threads are never hashed in kernel/pid.c:pid_hash[]. We don't need to hash pid == 0 in pidmap_init(). free_pidmap() is never called with pid == 0 arg, so it will never be reused. So it is still possible to use pid == 0 in any PIDTYPE_xxx namespace from kernel/pid.c's POV. However with this patch we don't hash pid == 0 for PIDTYPE_PID case. We still have have PIDTYPE_PGID/PIDTYPE_SID entries with pid == 0: /sbin/init and kernel threads which don't call daemonize(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
c97d98931a
commit
73b9ebfe12
5 changed files with 18 additions and 44 deletions
|
@ -1181,25 +1181,26 @@ static task_t *copy_process(unsigned long clone_flags,
|
|||
*/
|
||||
p->ioprio = current->ioprio;
|
||||
|
||||
add_parent(p);
|
||||
if (unlikely(p->ptrace & PT_PTRACED))
|
||||
__ptrace_link(p, current->parent);
|
||||
if (likely(p->pid)) {
|
||||
add_parent(p);
|
||||
if (unlikely(p->ptrace & PT_PTRACED))
|
||||
__ptrace_link(p, current->parent);
|
||||
|
||||
if (thread_group_leader(p)) {
|
||||
p->signal->tty = current->signal->tty;
|
||||
p->signal->pgrp = process_group(current);
|
||||
p->signal->session = current->signal->session;
|
||||
attach_pid(p, PIDTYPE_PGID, process_group(p));
|
||||
attach_pid(p, PIDTYPE_SID, p->signal->session);
|
||||
if (thread_group_leader(p)) {
|
||||
p->signal->tty = current->signal->tty;
|
||||
p->signal->pgrp = process_group(current);
|
||||
p->signal->session = current->signal->session;
|
||||
attach_pid(p, PIDTYPE_PGID, process_group(p));
|
||||
attach_pid(p, PIDTYPE_SID, p->signal->session);
|
||||
|
||||
list_add_tail(&p->tasks, &init_task.tasks);
|
||||
if (p->pid)
|
||||
list_add_tail(&p->tasks, &init_task.tasks);
|
||||
__get_cpu_var(process_counts)++;
|
||||
}
|
||||
attach_pid(p, PIDTYPE_TGID, p->tgid);
|
||||
attach_pid(p, PIDTYPE_PID, p->pid);
|
||||
nr_threads++;
|
||||
}
|
||||
attach_pid(p, PIDTYPE_TGID, p->tgid);
|
||||
attach_pid(p, PIDTYPE_PID, p->pid);
|
||||
|
||||
nr_threads++;
|
||||
total_forks++;
|
||||
spin_unlock(¤t->sighand->siglock);
|
||||
write_unlock_irq(&tasklist_lock);
|
||||
|
@ -1263,7 +1264,7 @@ task_t * __devinit fork_idle(int cpu)
|
|||
if (!task)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
init_idle(task, cpu);
|
||||
unhash_process(task);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue