diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-10-02 13:17:22 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 18:57:15 +0400 |
commit | d387cae075b0aec479adbdfb71df39f7de8e9adb (patch) | |
tree | fe5c9a3b105f3edf4049c16dda4085c5f356fafe /include/linux/pid.h | |
parent | c88be3eb2e01bbb21c9ccdc3805f0d3546c1898c (diff) | |
download | linux-d387cae075b0aec479adbdfb71df39f7de8e9adb.tar.xz |
[PATCH] pid: simplify pid iterators
I think it is hardly possible to read the current do_each_task_pid(). The
new version is much simpler and makes the code smaller.
Only the do_each_task_pid change is tested, the do_each_pid_task isn't.
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>
Diffstat (limited to 'include/linux/pid.h')
-rw-r--r-- | include/linux/pid.h | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h index dba1b2d677a3..7e39767b4c60 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -102,42 +102,29 @@ static inline pid_t pid_nr(struct pid *pid) return nr; } -#define pid_next(task, type) \ - ((task)->pids[(type)].node.next) -#define pid_next_task(task, type) \ - hlist_entry(pid_next(task, type), struct task_struct, \ - pids[(type)].node) - - -/* We could use hlist_for_each_entry_rcu here but it takes more arguments - * than the do_each_task_pid/while_each_task_pid. So we roll our own - * to preserve the existing interface. - */ -#define do_each_task_pid(who, type, task) \ - if ((task = find_task_by_pid_type(type, who))) { \ - prefetch(pid_next(task, type)); \ - do { - -#define while_each_task_pid(who, type, task) \ - } while (pid_next(task, type) && ({ \ - task = pid_next_task(task, type); \ - rcu_dereference(task); \ - prefetch(pid_next(task, type)); \ - 1; }) ); \ - } - -#define do_each_pid_task(pid, type, task) \ - if ((task = pid_task(pid, type))) { \ - prefetch(pid_next(task, type)); \ - do { - -#define while_each_pid_task(pid, type, task) \ - } while (pid_next(task, type) && ({ \ - task = pid_next_task(task, type); \ - rcu_dereference(task); \ - prefetch(pid_next(task, type)); \ - 1; }) ); \ - } +#define do_each_task_pid(who, type, task) \ + do { \ + struct hlist_node *pos___; \ + struct pid *pid___ = find_pid(who); \ + if (pid___ != NULL) \ + hlist_for_each_entry_rcu((task), pos___, \ + &pid___->tasks[type], pids[type].node) { + +#define while_each_task_pid(who, type, task) \ + } \ + } while (0) + + +#define do_each_pid_task(pid, type, task) \ + do { \ + struct hlist_node *pos___; \ + if (pid != NULL) \ + hlist_for_each_entry_rcu((task), pos___, \ + &pid->tasks[type], pids[type].node) { + +#define while_each_pid_task(pid, type, task) \ + } \ + } while (0) #endif /* _LINUX_PID_H */ |