diff options
author | Mike Rapoport <rppt@linux.vnet.ibm.com> | 2018-02-06 18:40:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-06 21:32:46 -0500 |
commit | 2ee0826085d1c0281cb60c1f4bc3e0c27efeedc3 (patch) | |
tree | bb2dc8915be7e4f0fea7438edf380d84b896f80a /kernel/pid.c | |
parent | eab216e9cc636c24cec06bdf57a80f4c26b34493 (diff) |
pids: introduce find_get_task_by_vpid() helper
There are several functions that do find_task_by_vpid() followed by
get_task_struct(). We can use a helper function instead.
Link: http://lkml.kernel.org/r/1509602027-11337-1-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 5d30c87e3c42..ed6c343fe50d 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -343,6 +343,19 @@ struct task_struct *find_task_by_vpid(pid_t vnr) | |||
343 | return find_task_by_pid_ns(vnr, task_active_pid_ns(current)); | 343 | return find_task_by_pid_ns(vnr, task_active_pid_ns(current)); |
344 | } | 344 | } |
345 | 345 | ||
346 | struct task_struct *find_get_task_by_vpid(pid_t nr) | ||
347 | { | ||
348 | struct task_struct *task; | ||
349 | |||
350 | rcu_read_lock(); | ||
351 | task = find_task_by_vpid(nr); | ||
352 | if (task) | ||
353 | get_task_struct(task); | ||
354 | rcu_read_unlock(); | ||
355 | |||
356 | return task; | ||
357 | } | ||
358 | |||
346 | struct pid *get_task_pid(struct task_struct *task, enum pid_type type) | 359 | struct pid *get_task_pid(struct task_struct *task, enum pid_type type) |
347 | { | 360 | { |
348 | struct pid *pid; | 361 | struct pid *pid; |