aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/pid.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/pid.c')
-rw-r--r--kernel/pid.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/kernel/pid.c b/kernel/pid.c
index eeb836b65ca4..8387e8c68193 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -218,14 +218,11 @@ struct pid * fastcall find_pid(int nr)
218 return NULL; 218 return NULL;
219} 219}
220 220
221int fastcall attach_pid(task_t *task, enum pid_type type, int nr) 221int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr)
222{ 222{
223 struct pid_link *link; 223 struct pid_link *link;
224 struct pid *pid; 224 struct pid *pid;
225 225
226 WARN_ON(!task->pid); /* to be removed soon */
227 WARN_ON(!nr); /* to be removed soon */
228
229 link = &task->pids[type]; 226 link = &task->pids[type];
230 link->pid = pid = find_pid(nr); 227 link->pid = pid = find_pid(nr);
231 hlist_add_head_rcu(&link->node, &pid->tasks[type]); 228 hlist_add_head_rcu(&link->node, &pid->tasks[type]);
@@ -233,7 +230,7 @@ int fastcall attach_pid(task_t *task, enum pid_type type, int nr)
233 return 0; 230 return 0;
234} 231}
235 232
236void fastcall detach_pid(task_t *task, enum pid_type type) 233void fastcall detach_pid(struct task_struct *task, enum pid_type type)
237{ 234{
238 struct pid_link *link; 235 struct pid_link *link;
239 struct pid *pid; 236 struct pid *pid;
@@ -252,6 +249,15 @@ void fastcall detach_pid(task_t *task, enum pid_type type)
252 free_pid(pid); 249 free_pid(pid);
253} 250}
254 251
252/* transfer_pid is an optimization of attach_pid(new), detach_pid(old) */
253void fastcall transfer_pid(struct task_struct *old, struct task_struct *new,
254 enum pid_type type)
255{
256 new->pids[type].pid = old->pids[type].pid;
257 hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node);
258 old->pids[type].pid = NULL;
259}
260
255struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type) 261struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
256{ 262{
257 struct task_struct *result = NULL; 263 struct task_struct *result = NULL;
@@ -267,7 +273,7 @@ struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
267/* 273/*
268 * Must be called under rcu_read_lock() or with tasklist_lock read-held. 274 * Must be called under rcu_read_lock() or with tasklist_lock read-held.
269 */ 275 */
270task_t *find_task_by_pid_type(int type, int nr) 276struct task_struct *find_task_by_pid_type(int type, int nr)
271{ 277{
272 return pid_task(find_pid(nr), type); 278 return pid_task(find_pid(nr), type);
273} 279}