All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	oprofile-list <oprofile-list@lists.sourceforge.net>,
	Robert Richter <robert.richter@amd.com>,
	Naga Chumbalkar <nagananda.chumbalkar@hp.com>,
	Shashi Belur <shashi-kiran.belur@hp.com>,
	Tony Jones <tonyj@suse.de>
Subject: [PATCH 08/15] oprofile/x86: warn user if a counter is already active
Date: Fri, 26 Feb 2010 18:30:00 +0100	[thread overview]
Message-ID: <1267205407-6523-9-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1267205407-6523-1-git-send-email-robert.richter@amd.com>

This patch generates a warning if a counter is already active.

Implemented for AMD and P6 models. P4 is not supported.

Cc: Naga Chumbalkar <nagananda.chumbalkar@hp.com>
Cc: Shashi Belur <shashi-kiran.belur@hp.com>
Cc: Tony Jones <tonyj@suse.de>
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/oprofile/op_model_amd.c  |   11 ++++++++++-
 arch/x86/oprofile/op_model_ppro.c |   11 ++++++++++-
 arch/x86/oprofile/op_x86_model.h  |   11 +++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index a9d1947..ef9d735 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -194,9 +194,18 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
 
 	/* clear all counters */
 	for (i = 0; i < NUM_CONTROLS; ++i) {
-		if (unlikely(!msrs->controls[i].addr))
+		if (unlikely(!msrs->controls[i].addr)) {
+			if (counter_config[i].enabled && !smp_processor_id())
+				/*
+				 * counter is reserved, this is on all
+				 * cpus, so report only for cpu #0
+				 */
+				op_x86_warn_reserved(i);
 			continue;
+		}
 		rdmsrl(msrs->controls[i].addr, val);
+		if (val & ARCH_PERFMON_EVENTSEL0_ENABLE)
+			op_x86_warn_in_use(i);
 		val &= model->reserved;
 		wrmsrl(msrs->controls[i].addr, val);
 	}
diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
index 8eb0587..c344525 100644
--- a/arch/x86/oprofile/op_model_ppro.c
+++ b/arch/x86/oprofile/op_model_ppro.c
@@ -82,9 +82,18 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model,
 
 	/* clear all counters */
 	for (i = 0; i < num_counters; ++i) {
-		if (unlikely(!msrs->controls[i].addr))
+		if (unlikely(!msrs->controls[i].addr)) {
+			if (counter_config[i].enabled && !smp_processor_id())
+				/*
+				 * counter is reserved, this is on all
+				 * cpus, so report only for cpu #0
+				 */
+				op_x86_warn_reserved(i);
 			continue;
+		}
 		rdmsrl(msrs->controls[i].addr, val);
+		if (val & ARCH_PERFMON_EVENTSEL0_ENABLE)
+			op_x86_warn_in_use(i);
 		val &= model->reserved;
 		wrmsrl(msrs->controls[i].addr, val);
 	}
diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
index 7b8e75d..59fa2bd 100644
--- a/arch/x86/oprofile/op_x86_model.h
+++ b/arch/x86/oprofile/op_x86_model.h
@@ -57,6 +57,17 @@ struct op_x86_model_spec {
 
 struct op_counter_config;
 
+static inline void op_x86_warn_in_use(int counter)
+{
+	pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
+		   counter, smp_processor_id());
+}
+
+static inline void op_x86_warn_reserved(int counter)
+{
+	pr_warning("oprofile: counter #%d is already reserved\n", counter);
+}
+
 extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
 			   struct op_counter_config *counter_config);
 extern int op_x86_phys_to_virt(int phys);
-- 
1.6.6



  parent reply	other threads:[~2010-02-26 17:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-26 17:29 [PATCH 00/15] oprofile fixes and updates for v2.6.34 Robert Richter
2010-02-26 17:29 ` [PATCH 01/15] oprofile: remove tracing build dependency Robert Richter
2010-02-26 17:29 ` [PATCH 02/15] oprofile: remove EXPERIMENTAL from the config option description Robert Richter
2010-02-26 17:29 ` [PATCH 03/15] oprofile/x86: remove OPROFILE_IBS config option Robert Richter
2010-02-26 17:29 ` [PATCH 04/15] oprofile/x86: remove node check in AMD IBS initialization Robert Richter
2010-02-26 17:29 ` [PATCH 05/15] oprofile/x86: implement IBS cpuid feature detection Robert Richter
2010-02-26 17:29 ` [PATCH 06/15] oprofile/x86: implement lsfr pseudo-random number generator for IBS Robert Richter
2010-02-26 17:29 ` [PATCH 07/15] oprofile/x86: implement randomization for IBS periodic op counter Robert Richter
2010-02-26 17:30 ` Robert Richter [this message]
2010-02-26 17:30 ` [PATCH 09/15] oprofile/x86: add comment to counter-in-use warning Robert Richter
2010-02-26 17:30 ` [PATCH 10/15] oprofile/x86: fix perfctr nmi reservation for mulitplexing Robert Richter
2010-02-26 17:30 ` [PATCH 11/15] oprofile/x86: use kzalloc() instead of kmalloc() Robert Richter
2010-02-26 17:30 ` [PATCH 12/15] oprofile/x86: fix msr access to reserved counters Robert Richter
2010-02-26 17:30 ` [PATCH 13/15] perf, x86: make IBS macros available in perf_event.h Robert Richter
2010-02-26 17:30 ` [PATCH 14/15] perf, x86: add some IBS macros to perf_event.h Robert Richter
2010-02-26 17:30 ` [PATCH 15/15] perf, x86: rename macro in ARCH_PERFMON_EVENTSEL_ENABLE Robert Richter
2010-02-27  9:03 ` [PATCH 00/15] oprofile fixes and updates for v2.6.34 Ingo Molnar
2010-03-01 14:39   ` Robert Richter
2010-03-02 10:01     ` Ingo Molnar

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=1267205407-6523-9-git-send-email-robert.richter@amd.com \
    --to=robert.richter@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nagananda.chumbalkar@hp.com \
    --cc=oprofile-list@lists.sourceforge.net \
    --cc=shashi-kiran.belur@hp.com \
    --cc=tonyj@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.