]> err.no Git - linux-2.6/commitdiff
Deprecate find_task_by_pid()
authorPavel Emelyanov <xemul@openvz.org>
Wed, 30 Apr 2008 07:54:24 +0000 (00:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Apr 2008 15:29:48 +0000 (08:29 -0700)
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>
Documentation/feature-removal-schedule.txt
include/linux/sched.h
init/main.c
kernel/kthread.c
kernel/pid.c

index 599fe55bf2970bb56b512f77d8ce5170d1e0199d..3c35d452b1a968439cdbb2b270bcaa75b26b762d 100644 (file)
@@ -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.
index 86e60796db623486868e4b04cc8b0992456a272b..03c238088aee57a26fbbcd110cf10e901e918fb9 100644 (file)
@@ -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);
index 1f4406477f83b88831389fd364a0acfdf50aa14e..dff253cfcd9fdafd4548fc8f7f4d9d4055c8732d 100644 (file)
@@ -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();
 
        /*
index ac72eea48339cc672cea19962a95e246f87abb83..bd1b9ea024e1238cb230c159c426f3a4f0c8981e 100644 (file)
@@ -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.
index b322cdf401bf217da625524e66f8efd1a3ff3ef1..a9ae9f7fb229fd5b34d6d963d080f5c047714708 100644 (file)
@@ -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,