Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95248
b: refs/heads/master
c: 5cd2045
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and Linus Torvalds committed Apr 30, 2008
1 parent c8c26d2 commit 18f7610
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb41d6d068716b2b3666925da34d3d7e658bf4f3
refs/heads/master: 5cd204550b1a006f2b0c986b0e0f53220ebfd391
18 changes: 18 additions & 0 deletions trunk/Documentation/feature-removal-schedule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ Who: Kay Sievers <kay.sievers@suse.de>

---------------------------

What: find_task_by_pid
When: 2.6.26
Why: With pid namespaces, calling this funciton will return the
wrong task when called from inside a namespace.

The best way to save a task pid and find a task by this
pid later, is to find this task's struct pid pointer (or get
it directly from the task) and call pid_task() later.

If someone really needs to get a task by its pid_t, then
he most likely needs the find_task_by_vpid() to get the
task from the same namespace as the current task is in, but
this may be not so in general.

Who: Pavel Emelyanov <xemul@openvz.org>

---------------------------

What: ACPI procfs interface
When: July 2008
Why: ACPI sysfs conversion should be finished by January 2008.
Expand Down
5 changes: 4 additions & 1 deletion trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,10 @@ extern struct pid_namespace init_pid_ns;
extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
struct pid_namespace *ns);

extern struct task_struct *find_task_by_pid(pid_t nr);
static inline struct task_struct *__deprecated find_task_by_pid(pid_t nr)
{
return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
}
extern struct task_struct *find_task_by_vpid(pid_t nr);
extern struct task_struct *find_task_by_pid_ns(pid_t nr,
struct pid_namespace *ns);
Expand Down
2 changes: 1 addition & 1 deletion trunk/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static void noinline __init_refok rest_init(void)
kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
numa_default_policy();
pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
kthreadd_task = find_task_by_pid(pid);
kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
unlock_kernel();

/*
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void create_kthread(struct kthread_create_info *create)
struct sched_param param = { .sched_priority = 0 };
wait_for_completion(&create->started);
read_lock(&tasklist_lock);
create->result = find_task_by_pid(pid);
create->result = find_task_by_pid_ns(pid, &init_pid_ns);
read_unlock(&tasklist_lock);
/*
* root may have changed our (kthreadd's) priority or CPU mask.
Expand Down
6 changes: 0 additions & 6 deletions trunk/kernel/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,6 @@ struct task_struct *find_task_by_pid_type_ns(int type, int nr,

EXPORT_SYMBOL(find_task_by_pid_type_ns);

struct task_struct *find_task_by_pid(pid_t nr)
{
return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
}
EXPORT_SYMBOL(find_task_by_pid);

struct task_struct *find_task_by_vpid(pid_t vnr)
{
return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
Expand Down

0 comments on commit 18f7610

Please sign in to comment.