But why do you dislike it? Yes, the implementation of pid_for_each_task()
is not simple. Partly because hlist_for_each_entry_rcu() is ugly and
imho should be fixed (see btw http://marc.info/?t=120879441200004).
But with this patch the callers become simpler, we can just do
pid_for_each_task(pid, type, task)
do_something(task);
instead of
do_each_pid_task(pid, type, task) {
do_something(task);
} while_each_pid_task(pid, type, task);
and we can use break/continue safely.
+#define pid_for_each_task(pid, type, p) \
+ for (p = (pid) ? (void*)(pid)->tasks[type].first : NULL; \
+ rcu_dereference(p)&& ({ \
+ prefetch(((struct hlist_node*)p)->next); \
+ p = hlist_entry((void*)p, typeof(*p), pids[type].node); \
+ 1; }); \
+ p = ((type) != PIDTYPE_PID) ? \
+ (void*)(p)->pids[type].node.next : NULL)
+
Really, is this too bad?