public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: eranian@google.com
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, paulus@samba.org,
	fweisbec@gmail.com, robert.richter@amd.com, davem@davemloft.net,
	perfmon2-devel@lists.sf.net
Subject: Re: [PATCH] perf_events: improve task_sched_in()
Date: Thu, 11 Mar 2010 09:35:16 +0100	[thread overview]
Message-ID: <1268296516.5279.912.camel@twins> (raw)
In-Reply-To: <1268288765-5326-1-git-send-email-eranian@google.com>

On Wed, 2010-03-10 at 22:26 -0800, eranian@google.com wrote:
> This patch is an optimization in perf_event_task_sched_in() to avoid scheduling
> the events twice in a row. Without it, the perf_disable()/perf_enable() pair
> is invoked twice, thereby pinned events counts while scheduling flexible events
> and we go throuh hw_perf_enable() twice. By encapsulating, the whole sequence
> into perf_disable()/perf_enable() we ensure, hw_perf_enable() is going to be
> invoked only once because of the refcount protection.

Agreed, this makes perfect sense.

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

> Signed-off-by: Stephane Eranian <eranian@google.com>
> --
>  perf_event.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -1382,6 +1382,8 @@ void perf_event_task_sched_in(struct task_struct *task)
>  	if (cpuctx->task_ctx == ctx)
>  		return;
>  
> +	perf_disable();
> +
>  	/*
>  	 * We want to keep the following priority order:
>  	 * cpu pinned (that don't need to move), task pinned,
> @@ -1394,6 +1396,8 @@ void perf_event_task_sched_in(struct task_struct *task)
>  	ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE);
>  
>  	cpuctx->task_ctx = ctx;
> +
> +	perf_enable();
>  }
>  
>  #define MAX_INTERRUPTS (~0ULL)


  reply	other threads:[~2010-03-11  8:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11  6:26 [PATCH] perf_events: improve task_sched_in() eranian
2010-03-11  8:35 ` Peter Zijlstra [this message]
2010-03-11 14:42 ` [tip:perf/core] perf_events: Improve task_sched_in() tip-bot for eranian@google.com

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=1268296516.5279.912.camel@twins \
    --to=peterz@infradead.org \
    --cc=davem@davemloft.net \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=perfmon2-devel@lists.sf.net \
    --cc=robert.richter@amd.com \
    /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