ptrace_get_task_struct: s/tasklist/rcu/, make it static

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, June 18, 2009 - 2:59 pm

Gitweb:     http://git.kernel.org/linus/8053bdd5ce15dcf043d41a4dd6cac4a5567effdc
Commit:     8053bdd5ce15dcf043d41a4dd6cac4a5567effdc
Parent:     4b105cbbaf7c06e01c27391957dc3c446328d087
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Wed Jun 17 16:27:34 2009 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Thu Jun 18 13:03:51 2009 -0700

    ptrace_get_task_struct: s/tasklist/rcu/, make it static
    
    - Use rcu_read_lock() instead of tasklist_lock to find/get the task
      in ptrace_get_task_struct().
    
    - Make it static, it has no callers outside of ptrace.c.
    
    - The comment doesn't match the reality, this helper does not do
      any checks. Beacuse it is really trivial and static I removed the
      whole comment.
    
    Signed-off-by: Oleg Nesterov <oleg@redhat.com>
    Acked-by: Roland McGrath <roland@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 include/linux/ptrace.h |    1 -
 kernel/ptrace.c        |   16 +++-------------
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 59e133d..7456d7d 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -81,7 +81,6 @@
 
 
 extern long arch_ptrace(struct task_struct *child, long request, long addr, long data);
-extern struct task_struct *ptrace_get_task_struct(pid_t pid);
 extern int ptrace_traceme(void);
 extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
 extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 38fdfea..a64fe75 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -581,26 +581,16 @@ int ptrace_request(struct task_struct *child, long request,
 	return ret;
 }
 
-/**
- * ptrace_get_task_struct  --  grab a task struct reference for ptrace
- * @pid:       process id to grab a task_struct reference of
- *
- * This function is a helper for ptrace implementations.  It checks
- * permissions and then grabs a task struct for use of the actual
- * ptrace implementation.
- *
- * Returns the task_struct for @pid or an ERR_PTR() on failure.
- */
-struct task_struct *ptrace_get_task_struct(pid_t pid)
+static struct task_struct *ptrace_get_task_struct(pid_t pid)
 {
 	struct task_struct *child;
 
-	read_lock(&tasklist_lock);
+	rcu_read_lock();
 	child = find_task_by_vpid(pid);
 	if (child)
 		get_task_struct(child);
+	rcu_read_unlock();
 
-	read_unlock(&tasklist_lock);
 	if (!child)
 		return ERR_PTR(-ESRCH);
 	return child;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ptrace_get_task_struct: s/tasklist/rcu/, make it static, Linux Kernel Mailing ..., (Thu Jun 18, 2:59 pm)