mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	Zhang Yanmin <yanmin_zhang@linux.intel.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 3/5] perf: New PERF_EVENT_STATE_PAUSED event state
Date: Thu, 10 Jun 2010 05:49:18 +0200	[thread overview]
Message-ID: <1276141760-11590-4-git-send-regression-fweisbec@gmail.com> (raw)
In-Reply-To: <1276141760-11590-1-git-send-regression-fweisbec@gmail.com>

This brings a new PERF_EVENT_STATE_PAUSED state. It means the events
is enabled but we don't want it to run, it must be in the same state
than after a pmu->stop() call. So the event has been reserved and
allocated and it is ready to start after a pmu->start() call.

It is deemed for hardware events when we want them to be reserved on
the cpu and ready to be started anytime. This is going to be useful
for the new context exclusion that will follow.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Zhang Yanmin <yanmin_zhang@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/cpu/perf_event.c |    6 ++++--
 include/linux/perf_event.h       |    3 ++-
 kernel/perf_event.c              |    7 ++++---
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index f2da20f..9b0e52f 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -839,7 +839,8 @@ void hw_perf_enable(void)
 			    match_prev_assignment(hwc, cpuc, i))
 				continue;
 
-			x86_pmu_stop(event);
+			if (event->state != PERF_EVENT_STATE_PAUSED)
+				x86_pmu_stop(event);
 		}
 
 		for (i = 0; i < cpuc->n_events; i++) {
@@ -851,7 +852,8 @@ void hw_perf_enable(void)
 			else if (i < n_running)
 				continue;
 
-			x86_pmu_start(event);
+			if (event->state != PERF_EVENT_STATE_PAUSED)
+				x86_pmu_start(event);
 		}
 		cpuc->n_added = 0;
 		perf_events_lapic_init();
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 63b5aa5..48b3157 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -598,7 +598,8 @@ enum perf_event_active_state {
 	PERF_EVENT_STATE_ERROR		= -2,
 	PERF_EVENT_STATE_OFF		= -1,
 	PERF_EVENT_STATE_INACTIVE	=  0,
-	PERF_EVENT_STATE_ACTIVE		=  1,
+	PERF_EVENT_STATE_PAUSED		=  1,
+	PERF_EVENT_STATE_ACTIVE		=  2,
 };
 
 struct file;
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 2d818bc..7c6502a 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1541,20 +1541,21 @@ static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
 	hwc->sample_period = sample_period;
 
 	if (local64_read(&hwc->period_left) > 8*sample_period) {
-		bool software_event = is_software_event(event);
+		bool reprogram = !is_software_event(event) &&
+				 event->state != PERF_EVENT_STATE_PAUSED;
 
 		/*
 		 * Only hardware events need their irq period to be
 		 * reprogrammed
 		 */
-		if (!software_event) {
+		if (reprogram) {
 			perf_disable();
 			perf_event_stop(event);
 		}
 
 		local64_set(&hwc->period_left, 0);
 
-		if (!software_event) {
+		if (reprogram) {
 			perf_event_start(event);
 			perf_enable();
 		}
-- 
1.6.2.3


  parent reply	other threads:[~2010-06-10  3:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-10  3:49 [PATCH 0/5] perf events finer grained context instrumentation / context exclusion Frederic Weisbecker
2010-06-10  3:49 ` [PATCH 1/5] perf: Provide a proper stop action for software events Frederic Weisbecker
2010-06-10 10:46   ` Peter Zijlstra
2010-06-10 11:10     ` Peter Zijlstra
2010-06-10 16:12       ` Frederic Weisbecker
2010-06-10 16:16         ` Peter Zijlstra
2010-06-10 16:29           ` Frederic Weisbecker
2010-06-10 16:38             ` Peter Zijlstra
2010-06-10 17:04               ` Frederic Weisbecker
2010-06-10 19:54           ` Frederic Weisbecker
2010-06-10 12:06     ` Ingo Molnar
2010-06-10  3:49 ` [PATCH 2/5] perf: Support disable() after stop() on " Frederic Weisbecker
2010-06-10 10:50   ` Peter Zijlstra
2010-06-10 16:31     ` Frederic Weisbecker
2010-06-10  3:49 ` Frederic Weisbecker [this message]
2010-06-10 10:55   ` [PATCH 3/5] perf: New PERF_EVENT_STATE_PAUSED event state Peter Zijlstra
2010-06-10 16:26     ` Frederic Weisbecker
2010-06-10  3:49 ` [PATCH 4/5] perf: Introduce task, softirq and hardirq contexts exclusion Frederic Weisbecker
2010-06-10 11:01   ` Peter Zijlstra
2010-06-10 16:24     ` Frederic Weisbecker
2010-06-10  3:49 ` [PATCH 5/5] perf: Support for task/softirq/hardirq exclusion on tools Frederic Weisbecker
2010-06-10  6:26 ` [PATCH 0/5] perf events finer grained context instrumentation / context exclusion Ingo Molnar
2010-06-10  7:15   ` Frederic Weisbecker
2010-06-10  7:31   ` Frederic Weisbecker
2010-06-10 10:16     ` Ingo Molnar
2010-06-10 17:03       ` Frederic Weisbecker

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=1276141760-11590-4-git-send-regression-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=eranian@google.com \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    --cc=yanmin_zhang@linux.intel.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

all inboxes | Powered by JetHome®