From: Eric W. Biederman pid 0 is never exported to userspace, so hashing it servers no useful purpose. Explicitly not hashing pid 0 allows struct pid to be marked as not hashed, and it allows us to avoid checks if for pid 0 when searching for processes to signal if pid 0 does not have a special meaning. Signed-off-by: Eric W. Biederman Signed-off-by: Andrew Morton --- kernel/pid.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff -puN kernel/pid.c~pid-dont-hash-pid-0 kernel/pid.c --- devel/kernel/pid.c~pid-dont-hash-pid-0 2006-01-29 00:37:45.000000000 -0800 +++ devel-akpm/kernel/pid.c 2006-01-29 00:37:45.000000000 -0800 @@ -148,6 +148,9 @@ int fastcall attach_pid(task_t *task, en { struct pid *pid, *task_pid; + if (!nr) + goto out; + task_pid = &task->pids[type]; pid = find_pid(type, nr); task_pid->nr = nr; @@ -159,7 +162,7 @@ int fastcall attach_pid(task_t *task, en INIT_HLIST_NODE(&task_pid->pid_chain); list_add_tail_rcu(&task_pid->pid_list, &pid->pid_list); } - + out: return 0; } @@ -169,6 +172,9 @@ static fastcall int __detach_pid(task_t int nr = 0; pid = &task->pids[type]; + if (!pid->nr) + goto out; + if (!hlist_unhashed(&pid->pid_chain)) { if (list_empty(&pid->pid_list)) { @@ -185,7 +191,7 @@ static fastcall int __detach_pid(task_t list_del_rcu(&pid->pid_list); pid->nr = 0; - + out: return nr; } _