aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-10-02 05:17:09 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:13 -0400
commit22c935f47c03399c78e64c71b757eb36fa917ff6 (patch)
tree801968ba95a13b13d25b8c7202ee0efdc4e03ad9 /include
parentf6c7a1f34e92b0b561024ead9fa70623683025e4 (diff)
[PATCH] pid: implement access helpers for a tacks various process groups
In the last round of cleaning up the pid hash table a more general struct pid was introduced, that can be referenced counted. With the more general struct pid most if not all places where we store a pid_t we can now store a struct pid * and remove the need for a hash table lookup, and avoid any possible problems with pid roll over. Looking forward to the pid namespaces struct pid * gives us an absolute form a pid so we can compare and use them without caring which pid namespace we are in. This patchset introduces the infrastructure needed to use struct pid instead of pid_t, and then it goes on to convert two different kernel users that currently store a pid_t value. There are a lot more places to go but this is enough to get the basic idea. Before we can merge a pid namespace patch all of the kernel pid_t users need to be examined. Those that deal with user space processes need to be converted to using a struct pid *. Those that deal with kernel processes need to converted to using the kthread api. A rare few that only use their current processes pid values get to be left alone. This patch: task_session returns the struct pid of a tasks session. task_pgrp returns the struct pid of a tasks process group. task_tgid returns the struct pid of a tasks thread group. task_pid returns the struct pid of a tasks process id. These can be used to avoid unnecessary hash table lookups, and to implement safe pid comparisions in the face of a pid namespace. Signed-off-by: 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')
-rw-r--r--include/linux/sched.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index be658e33bd26..660b02f80523 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1020,6 +1020,26 @@ static inline pid_t process_group(struct task_struct *tsk)
1020 return tsk->signal->pgrp; 1020 return tsk->signal->pgrp;
1021} 1021}
1022 1022
1023static inline struct pid *task_pid(struct task_struct *task)
1024{
1025 return task->pids[PIDTYPE_PID].pid;
1026}
1027
1028static inline struct pid *task_tgid(struct task_struct *task)
1029{
1030 return task->group_leader->pids[PIDTYPE_PID].pid;
1031}
1032
1033static inline struct pid *task_pgrp(struct task_struct *task)
1034{
1035 return task->group_leader->pids[PIDTYPE_PGID].pid;
1036}
1037
1038static inline struct pid *task_session(struct task_struct *task)
1039{
1040 return task->group_leader->pids[PIDTYPE_SID].pid;
1041}
1042
1023/** 1043/**
1024 * pid_alive - check that a task structure is not stale 1044 * pid_alive - check that a task structure is not stale
1025 * @p: Task structure to be checked. 1045 * @p: Task structure to be checked.