public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: eranian@google.com
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@elte.hu, paulus@samba.org,
	fweisbec@gmail.com, robert.richter@amd.com, davem@davemloft.net,
	perfmon2-devel@lists.sf.net
Subject: [PATCH] perf_events: improve task_sched_in()
Date: Wed, 10 Mar 2010 22:26:05 -0800	[thread overview]
Message-ID: <1268288765-5326-1-git-send-email-eranian@google.com> (raw)

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.

	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  6:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11  6:26 eranian [this message]
2010-03-11  8:35 ` [PATCH] perf_events: improve task_sched_in() Peter Zijlstra
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=1268288765-5326-1-git-send-email-eranian@google.com \
    --to=eranian@google.com \
    --cc=davem@davemloft.net \
    --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=peterz@infradead.org \
    --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