lkml.org 
[lkml]   [2011]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 5/8] introduce find_get_task_by_vpid()
Introduce the new helper, find_get_task_by_vpid(), which simply
does find_task_by_vpid() + get_task_struct() under rcu_read_lock().

It has several potential users which currently do this by hand,
and we are going to add clone_vfork_restart() which needs it too.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

include/linux/sched.h | 1 +
kernel/pid.c | 13 +++++++++++++
2 files changed, 14 insertions(+)

--- 3.1/include/linux/sched.h~5_find_get_task 2011-07-26 20:35:55.000000000 +0200
+++ 3.1/include/linux/sched.h 2011-07-26 20:36:10.000000000 +0200
@@ -2107,6 +2107,7 @@ extern struct pid_namespace init_pid_ns;
*/

extern struct task_struct *find_task_by_vpid(pid_t nr);
+extern struct task_struct *find_get_task_by_vpid(pid_t vnr);
extern struct task_struct *find_task_by_pid_ns(pid_t nr,
struct pid_namespace *ns);

--- 3.1/kernel/pid.c~5_find_get_task 2011-07-26 15:50:15.000000000 +0200
+++ 3.1/kernel/pid.c 2011-07-26 20:33:18.000000000 +0200
@@ -427,6 +427,19 @@ struct task_struct *find_task_by_vpid(pi
return find_task_by_pid_ns(vnr, current->nsproxy->pid_ns);
}

+struct task_struct *find_get_task_by_vpid(pid_t vnr)
+{
+ struct task_struct *task;
+
+ rcu_read_lock();
+ task = find_task_by_vpid(vnr);
+ if (task)
+ get_task_struct(task);
+ rcu_read_unlock();
+
+ return task;
+}
+
struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
{
struct pid *pid;


\
 
 \ /
  Last update: 2011-07-27 18:39    [W:0.437 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site