diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2004-10-19 18:31:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-10-19 18:31:47 -0700 |
commit | e45f49036ada350ab9936546b4d3a8d9bac4f106 (patch) | |
tree | 2c7a9c3e60f88a64d9bce6303fc0e807e0090a9d /kernel | |
parent | 6d338e926dd72fc697323d3271a4859fd15a54d2 (diff) | |
download | history-e45f49036ada350ab9936546b4d3a8d9bac4f106.tar.gz |
[PATCH] detach_pid(): restore optimization
Kirill's kernel/pid.c rework broke optimization logic in detach_pid(). Non
zero return from __detach_pid() was used to indicate, that this pid can
probably be freed. Current version always (modulo idle threads) return non
zero value, thus resulting in unneccesary pid_hash scanning.
Also, uninlining __detach_pid() reduces pid.o text size from 2492 to 1600
bytes.
Acked-By: Kirill Korotaev <dev@sw.ru>
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/pid.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 21024b7ae37c2f..284f97a1ffa5d6 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -163,15 +163,18 @@ int fastcall attach_pid(task_t *task, enum pid_type type, int nr) return 0; } -static inline int __detach_pid(task_t *task, enum pid_type type) +static fastcall int __detach_pid(task_t *task, enum pid_type type) { struct pid *pid, *pid_next; - int nr; + int nr = 0; pid = &task->pids[type]; if (!hlist_unhashed(&pid->pid_chain)) { hlist_del(&pid->pid_chain); - if (!list_empty(&pid->pid_list)) { + + if (list_empty(&pid->pid_list)) + nr = pid->nr; + else { pid_next = list_entry(pid->pid_list.next, struct pid, pid_list); /* insert next pid from pid_list to hash */ @@ -179,8 +182,8 @@ static inline int __detach_pid(task_t *task, enum pid_type type) &pid_hash[type][pid_hashfn(pid_next->nr)]); } } + list_del(&pid->pid_list); - nr = pid->nr; pid->nr = 0; return nr; |