If you need to store a persistent reference to a user space process use a
struct pid *. Not a task_struct reference.
References can potentially last for a long time after user space processes
have exited so holding a reference to a tiny struct pid is much cheaper
memory wise. In addition a struct pid is a drop in replacement for a
pid_t (except for the need for reference counting). A struct pid can
reference process groups, thread groups, and sessions not just individual
processes. Further a struct pid is immune from pid wrap around, removing
a whole class of theoretical problems from being issues in the kernel.