[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110727163329.GE23793@redhat.com>
Date: Wed, 27 Jul 2011 18:33:29 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Roland McGrath <roland@...k.frob.com>,
Tejun Heo <tj@...nel.org>
Cc: Denys Vlasenko <dvlasenk@...hat.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Matt Fleming <matt.fleming@...ux.intel.com>,
linux-kernel@...r.kernel.org
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@...hat.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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists