* [PATCH] ptrace_get_task_struct: s/tasklist/rcu/, make it static
@ 2009-05-05 23:28 Oleg Nesterov
2009-05-06 1:56 ` Roland McGrath
2009-05-06 7:14 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2009-05-05 23:28 UTC (permalink / raw)
To: Andrew Morton; +Cc: Roland McGrath, linux-kernel
- 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>
---
include/linux/ptrace.h | 1 -
kernel/ptrace.c | 16 +++-------------
2 files changed, 3 insertions(+), 14 deletions(-)
--- PTRACE/include/linux/ptrace.h~4_GET 2009-04-06 00:03:41.000000000 +0200
+++ PTRACE/include/linux/ptrace.h 2009-05-06 01:09:58.000000000 +0200
@@ -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);
--- PTRACE/kernel/ptrace.c~4_GET 2009-05-06 00:16:17.000000000 +0200
+++ PTRACE/kernel/ptrace.c 2009-05-06 01:18:19.000000000 +0200
@@ -587,26 +587,16 @@ int ptrace_request(struct task_struct *c
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;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ptrace_get_task_struct: s/tasklist/rcu/, make it static
2009-05-05 23:28 [PATCH] ptrace_get_task_struct: s/tasklist/rcu/, make it static Oleg Nesterov
@ 2009-05-06 1:56 ` Roland McGrath
2009-05-06 7:14 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2009-05-06 1:56 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Andrew Morton, linux-kernel
Acked-by: Roland McGrath <roland@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ptrace_get_task_struct: s/tasklist/rcu/, make it static
2009-05-05 23:28 [PATCH] ptrace_get_task_struct: s/tasklist/rcu/, make it static Oleg Nesterov
2009-05-06 1:56 ` Roland McGrath
@ 2009-05-06 7:14 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2009-05-06 7:14 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Andrew Morton, Roland McGrath, linux-kernel
On Wed, May 06, 2009 at 01:28:20AM +0200, Oleg Nesterov wrote:
> - 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.
FYI, there are a couple of other functions in ptrace.c that can be
static now that everyone uses the common sys_ptrace implementation,
e.g. ptrace_traceme and ptrace_attach.
> - 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.
Yeah, when I added the helper it did those checks and it was non-static
for the various arch ptrace implementations. Now that it's a private
helper with just two callers not doing much anymore it's not needed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-06 7:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-05 23:28 [PATCH] ptrace_get_task_struct: s/tasklist/rcu/, make it static Oleg Nesterov
2009-05-06 1:56 ` Roland McGrath
2009-05-06 7:14 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox