pids: Move the pgrp and session pid pointers from task_struct to signal_struct
To access these fields the code always has to go to group leader so going to signal struct is no loss and is actually a fundamental simplification. This saves a little bit of memory by only allocating the pid pointer array once instead of once for every thread, and even better this removes a few potential races caused by the fact that group_leader can be changed by de_thread, while signal_struct can not. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
@@ -775,7 +775,8 @@ struct task_struct {
|
||||
struct list_head ptrace_entry;
|
||||
|
||||
/* PID/PID hash table linkage. */
|
||||
struct pid_link pids[PIDTYPE_MAX];
|
||||
struct pid *thread_pid;
|
||||
struct hlist_node pid_links[PIDTYPE_MAX];
|
||||
struct list_head thread_group;
|
||||
struct list_head thread_node;
|
||||
|
||||
@@ -1199,22 +1200,7 @@ struct task_struct {
|
||||
|
||||
static inline struct pid *task_pid(struct task_struct *task)
|
||||
{
|
||||
return task->pids[PIDTYPE_PID].pid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Without tasklist or RCU lock it is not safe to dereference
|
||||
* the result of task_pgrp/task_session even if task == current,
|
||||
* we can race with another thread doing sys_setsid/sys_setpgid.
|
||||
*/
|
||||
static inline struct pid *task_pgrp(struct task_struct *task)
|
||||
{
|
||||
return task->group_leader->pids[PIDTYPE_PGID].pid;
|
||||
}
|
||||
|
||||
static inline struct pid *task_session(struct task_struct *task)
|
||||
{
|
||||
return task->group_leader->pids[PIDTYPE_SID].pid;
|
||||
return task->thread_pid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1263,7 +1249,7 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk)
|
||||
*/
|
||||
static inline int pid_alive(const struct task_struct *p)
|
||||
{
|
||||
return p->pids[PIDTYPE_PID].pid != NULL;
|
||||
return p->thread_pid != NULL;
|
||||
}
|
||||
|
||||
static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
|
||||
|
Reference in New Issue
Block a user