47e65328a7
This patch kills PIDTYPE_TGID pid_type thus saving one hash table in kernel/pid.c and speeding up subthreads create/destroy a bit. It is also a preparation for the further tref/pids rework. This patch adds 'struct list_head thread_group' to 'struct task_struct' instead. We don't detach group leader from PIDTYPE_PID namespace until another thread inherits it's ->pid == ->tgid, so we are safe wrt premature free_pidmap(->tgid) call. Currently there are no users of find_task_by_pid_type(PIDTYPE_TGID). Should the need arise, we can use find_task_by_pid()->group_leader. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-By: Eric Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
#ifndef _LINUX_PID_H
|
|
#define _LINUX_PID_H
|
|
|
|
enum pid_type
|
|
{
|
|
PIDTYPE_PID,
|
|
PIDTYPE_PGID,
|
|
PIDTYPE_SID,
|
|
PIDTYPE_MAX
|
|
};
|
|
|
|
struct pid
|
|
{
|
|
/* Try to keep pid_chain in the same cacheline as nr for find_pid */
|
|
int nr;
|
|
struct hlist_node pid_chain;
|
|
/* list of pids with the same nr, only one of them is in the hash */
|
|
struct list_head pid_list;
|
|
};
|
|
|
|
#define pid_task(elem, type) \
|
|
list_entry(elem, struct task_struct, pids[type].pid_list)
|
|
|
|
/*
|
|
* attach_pid() and detach_pid() must be called with the tasklist_lock
|
|
* write-held.
|
|
*/
|
|
extern int FASTCALL(attach_pid(struct task_struct *task, enum pid_type type, int nr));
|
|
|
|
extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
|
|
|
|
/*
|
|
* look up a PID in the hash table. Must be called with the tasklist_lock
|
|
* held.
|
|
*/
|
|
extern struct pid *FASTCALL(find_pid(enum pid_type, int));
|
|
|
|
extern int alloc_pidmap(void);
|
|
extern void FASTCALL(free_pidmap(int));
|
|
|
|
#define do_each_task_pid(who, type, task) \
|
|
if ((task = find_task_by_pid_type(type, who))) { \
|
|
prefetch((task)->pids[type].pid_list.next); \
|
|
do {
|
|
|
|
#define while_each_task_pid(who, type, task) \
|
|
} while (task = pid_task((task)->pids[type].pid_list.next,\
|
|
type), \
|
|
prefetch((task)->pids[type].pid_list.next), \
|
|
hlist_unhashed(&(task)->pids[type].pid_chain)); \
|
|
} \
|
|
|
|
#endif /* _LINUX_PID_H */
|