On 04/13, Christoph Hellwig wrote:
>
> This is prtty ugly. Can't we just have a
>
> #define for_each_task_pid(task, pid, type, pos) \
> hlist_for_each_entry_rcu((task), (pos), \
> (&(pid))->tasks[type], pids[type].node) {
>
> and move the find_pid to the caller? That would make the code a whole lot
> more readable.
How about this? :)
Oleg.
--- MM/include/linux/pid.h~ 2006-03-23 22:48:10.000000000 +0300
+++ MM/include/linux/pid.h 2006-04-14 01:49:08.000000000 +0400
@@ -98,22 +98,22 @@ extern void FASTCALL(free_pid(struct pid
hlist_entry(pid_next(task, type), struct task_struct, \
pids[(type)].node)
+#define for_each_task_pid(who, type, t) \
+ for ((t) = ({ \
+ struct pid *pid___ = find_pid(who); \
+ pid___ \
+ ? hlist_entry((&pid___->tasks[type])->first, typeof(*(t)), pids[type].node) \
+ : hlist_entry(NULL, typeof(*(t)), pids[type].node); \
+ }); \
+ rcu_dereference(t) != hlist_entry(NULL, typeof(*(t)), pids[type].node) \
+ && ({ prefetch((t)->pids[type].node.next); 1; }); \
+ (t) = hlist_entry((t)->pids[type].node.next, typeof(*(t)), 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 {
+/* obsolete */
+#define do_each_task_pid(who, type, task) \
+ do for_each_task_pid(who, type, task)
-#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 while_each_task_pid(who, type, task) \
+ while (0)
#endif /* _LINUX_PID_H */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]