public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] perf: Wrap perf_lock_task_context using __cond_lock()
Date: Thu, 30 Sep 2010 13:38:49 +0200	[thread overview]
Message-ID: <1285846729.2144.16.camel@laptop> (raw)
In-Reply-To: <1285583997-1262-2-git-send-email-namhyung@gmail.com>

On Mon, 2010-09-27 at 19:39 +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;
> +}
> +
>  /*
>   * Get the context for a task and increment its pin_count so it
>   * can't get swapped to another task.  This also increments its

This is a rather ugly annotation... why can't sparse use something like
the regular __acquire() function annotation but instead all it
__cond_acquire() ?



  parent reply	other threads:[~2010-09-30 11:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-27 10:39 [PATCH 0/5] perf cleanups Namhyung Kim
2010-09-27 10:39 ` [PATCH 1/5] perf: Wrap perf_lock_task_context using __cond_lock() Namhyung Kim
2010-09-27 13:46   ` Frederic Weisbecker
2010-09-27 14:40     ` Namhyung Kim
2010-09-30 11:38   ` Peter Zijlstra [this message]
2010-09-27 10:39 ` [PATCH 2/5] perf: Annotate lock context on perf_output_begin/end() Namhyung Kim
2010-09-27 10:39 ` [PATCH 3/5] perf: Remove 'extern' on hw_perf_event_init() definition Namhyung Kim
2010-09-27 10:39 ` [PATCH 4/5] perf: Make perf_event_wakeup() static Namhyung Kim
2010-09-27 10:39 ` [PATCH 5/5] perf: Declare hw_perf_{dis,en}able() in perf_event.h Namhyung Kim
2010-09-30 11:22   ` Peter Zijlstra
2010-09-30 15:05     ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285846729.2144.16.camel@laptop \
    --to=peterz@infradead.org \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox