lkml.org 
[lkml]   [2009]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 4/12 v2] ptrace: introduce the empty "struct ptrace_context"
On 05/28, Roland McGrath wrote:
>
> > + task_lock(tsk);
> > + if (likely(!tsk->ptrace_ctx))
> > + tsk->ptrace_ctx = ptrace_ctx;
> > + else
> > + kfree(ptrace_ctx);
> > + task_unlock(tsk);
>
> I don't think it's kosher call kfree with task_lock() held.

Yes, it always makes sense to move as much as possible outside of
spin_lock/etc, but

> The kfree case is a very unlikely path,

Exactly, this kfree() "never" runs under task_lock(), but the code
looks a bit simpler and shorter.

> so it can be:
>
> task_lock(tsk);
> if (likely(!tsk->ptrace_ctx)) {
> tsk->ptrace_ctx = ptrace_ctx;
> task_unlock(tsk);
> return 0;
> }
>
> task_unlock(tsk);
> kfree(ptrace_ctx);

OK, will change.

Oleg.



\
 
 \ /
  Last update: 2009-05-29 14:01    [from the cache]
©2003-2011 Jasper Spaans