Commit 5cd204550b1a006f2b0c986b0e0f53220ebfd391
Committed by
Linus Torvalds
1 parent
cb41d6d068
Exists in
master
and in
4 other branches
Deprecate find_task_by_pid()
There are some places that are known to operate on tasks' global pids only: * the rest_init() call (called on boot) * the kgdb's getthread * the create_kthread() (since the kthread is run in init ns) So use the find_task_by_pid_ns(..., &init_pid_ns) there and schedule the find_task_by_pid for removal. [sukadev@us.ibm.com: Fix warning in kernel/pid.c] Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 5 changed files with 24 additions and 9 deletions Side-by-side Diff
Documentation/feature-removal-schedule.txt
... | ... | @@ -138,6 +138,24 @@ |
138 | 138 | |
139 | 139 | --------------------------- |
140 | 140 | |
141 | +What: find_task_by_pid | |
142 | +When: 2.6.26 | |
143 | +Why: With pid namespaces, calling this funciton will return the | |
144 | + wrong task when called from inside a namespace. | |
145 | + | |
146 | + The best way to save a task pid and find a task by this | |
147 | + pid later, is to find this task's struct pid pointer (or get | |
148 | + it directly from the task) and call pid_task() later. | |
149 | + | |
150 | + If someone really needs to get a task by its pid_t, then | |
151 | + he most likely needs the find_task_by_vpid() to get the | |
152 | + task from the same namespace as the current task is in, but | |
153 | + this may be not so in general. | |
154 | + | |
155 | +Who: Pavel Emelyanov <xemul@openvz.org> | |
156 | + | |
157 | +--------------------------- | |
158 | + | |
141 | 159 | What: ACPI procfs interface |
142 | 160 | When: July 2008 |
143 | 161 | Why: ACPI sysfs conversion should be finished by January 2008. |
include/linux/sched.h
... | ... | @@ -1677,7 +1677,10 @@ |
1677 | 1677 | extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, |
1678 | 1678 | struct pid_namespace *ns); |
1679 | 1679 | |
1680 | -extern struct task_struct *find_task_by_pid(pid_t nr); | |
1680 | +static inline struct task_struct *__deprecated find_task_by_pid(pid_t nr) | |
1681 | +{ | |
1682 | + return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns); | |
1683 | +} | |
1681 | 1684 | extern struct task_struct *find_task_by_vpid(pid_t nr); |
1682 | 1685 | extern struct task_struct *find_task_by_pid_ns(pid_t nr, |
1683 | 1686 | struct pid_namespace *ns); |
init/main.c
... | ... | @@ -459,7 +459,7 @@ |
459 | 459 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); |
460 | 460 | numa_default_policy(); |
461 | 461 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); |
462 | - kthreadd_task = find_task_by_pid(pid); | |
462 | + kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); | |
463 | 463 | unlock_kernel(); |
464 | 464 | |
465 | 465 | /* |
kernel/kthread.c
... | ... | @@ -98,7 +98,7 @@ |
98 | 98 | struct sched_param param = { .sched_priority = 0 }; |
99 | 99 | wait_for_completion(&create->started); |
100 | 100 | read_lock(&tasklist_lock); |
101 | - create->result = find_task_by_pid(pid); | |
101 | + create->result = find_task_by_pid_ns(pid, &init_pid_ns); | |
102 | 102 | read_unlock(&tasklist_lock); |
103 | 103 | /* |
104 | 104 | * root may have changed our (kthreadd's) priority or CPU mask. |
kernel/pid.c
... | ... | @@ -381,12 +381,6 @@ |
381 | 381 | |
382 | 382 | EXPORT_SYMBOL(find_task_by_pid_type_ns); |
383 | 383 | |
384 | -struct task_struct *find_task_by_pid(pid_t nr) | |
385 | -{ | |
386 | - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns); | |
387 | -} | |
388 | -EXPORT_SYMBOL(find_task_by_pid); | |
389 | - | |
390 | 384 | struct task_struct *find_task_by_vpid(pid_t vnr) |
391 | 385 | { |
392 | 386 | return find_task_by_pid_type_ns(PIDTYPE_PID, vnr, |