pid: Implement PIDTYPE_TGID

Everywhere except in the pid array we distinguish between a tasks pid and
a tasks tgid (thread group id).  Even in the enumeration we want that
distinction sometimes so we have added __PIDTYPE_TGID.  With leader_pid
we almost have an implementation of PIDTYPE_TGID in struct signal_struct.

Add PIDTYPE_TGID as a first class member of the pid_type enumeration and
into the pids array.  Then remove the __PIDTYPE_TGID special case and the
leader_pid in signal_struct.

The net size increase is just an extra pointer added to struct pid and
an extra pair of pointers of an hlist_node added to task_struct.

The effect on code maintenance is the removal of a number of special
cases today and the potential to remove many more special cases as
PIDTYPE_TGID gets used to it's fullest.  The long term potential
is allowing zombie thread group leaders to exit, which will remove
a lot more special cases in the code.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
Eric W. Biederman 2017-06-04 04:32:13 -05:00
parent 2c4704756c
commit 6883f81aac
14 changed files with 19 additions and 19 deletions

View file

@ -147,7 +147,6 @@ struct signal_struct {
#endif
/* PID/PID hash table linkage. */
struct pid *leader_pid;
struct pid *pids[PIDTYPE_MAX];
#ifdef CONFIG_NO_HZ_FULL
@ -571,7 +570,7 @@ struct pid *task_pid_type(struct task_struct *task, enum pid_type type)
static inline struct pid *task_tgid(struct task_struct *task)
{
return task->signal->leader_pid;
return task->signal->pids[PIDTYPE_TGID];
}
/*
@ -607,7 +606,7 @@ static inline bool thread_group_leader(struct task_struct *p)
*/
static inline bool has_group_leader_pid(struct task_struct *p)
{
return task_pid(p) == p->signal->leader_pid;
return task_pid(p) == task_tgid(p);
}
static inline