lkml.org 
[lkml]   [2010]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] perf: Wrap perf_lock_task_context using __cond_lock()
On Mon, Sep 27, 2010 at 07:39:53PM +0900, Namhyung Kim wrote:
> perf_lock_task_context() conditionally grabs ctx->lock in case of
> returning non-NULL. Rename and wrap it using __cond_lock to make
> sparse happy.
>
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> ---
> kernel/perf_event.c | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index db5b560..c058a42 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -151,7 +151,7 @@ static u64 primary_event_id(struct perf_event *event)
> * the context could get moved to another task.
> */
> static struct perf_event_context *
> -perf_lock_task_context(struct task_struct *task, unsigned long *flags)
> +__perf_lock_task_context(struct task_struct *task, unsigned long *flags)
> {
> struct perf_event_context *ctx;
>
> @@ -184,6 +184,14 @@ perf_lock_task_context(struct task_struct *task, unsigned long *flags)
> return ctx;
> }
>
> +static inline struct perf_event_context *
> +perf_lock_task_context(struct task_struct *task, unsigned long *flags)
> +{
> + struct perf_event_context *ctx;
> + __cond_lock(&ctx->lock, ctx = __perf_lock_task_context(task, flags));
> + return ctx;
> +}



That's a pity we need to make the code less readable just to make a tool
happy.

How do functions like mutex_lock_interruptible() that may
or may not lock? I don't see __cond_lock adds there.

Thanks.



\
 
 \ /
  Last update: 2010-09-27 20:11    [W:0.057 / U:7.072 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site