From: Robert Richter <robert.richter@amd.com>
To: Barry Kasindorf <barry.kasindorf@amd.com>, Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>,
oprofile-list <oprofile-list@lists.sourceforge.net>,
LKML <linux-kernel@vger.kernel.org>,
Robert Richter <robert.richter@amd.com>
Subject: [PATCH 22/24] x86/oprofile: Add CONFIG_OPROFILE_IBS option
Date: Tue, 22 Jul 2008 21:09:06 +0200 [thread overview]
Message-ID: <1216753748-11261-23-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1216753748-11261-1-git-send-email-robert.richter@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/Kconfig | 14 ++++++++++++++
arch/x86/oprofile/op_model_athlon.c | 33 +++++++++++++++++++++++----------
drivers/oprofile/buffer_sync.c | 6 ++++++
drivers/oprofile/cpu_buffer.c | 4 ++++
4 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index ad89a33..62be4e2 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -13,6 +13,20 @@ config OPROFILE
If unsure, say N.
+config OPROFILE_IBS
+ bool "OProfile AMD IBS support (EXPERIMENTAL)"
+ default n
+ depends on OPROFILE && SMP && X86
+ help
+ Instruction-Based Sampling (IBS) is a new profiling
+ technique that provides rich, precise program performance
+ information. IBS is introduced by AMD Family10h processors
+ (AMD Opteron Quad-Core processor âBarcelonaâ) to overcome
+ the limitations of conventional performance counter
+ sampling.
+
+ If unsure, say N.
+
config HAVE_OPROFILE
def_bool n
diff --git a/arch/x86/oprofile/op_model_athlon.c b/arch/x86/oprofile/op_model_athlon.c
index 9c8c8c5..fb6015c 100644
--- a/arch/x86/oprofile/op_model_athlon.c
+++ b/arch/x86/oprofile/op_model_athlon.c
@@ -47,6 +47,10 @@
#define CTRL_SET_HOST_ONLY(val, h) (val |= ((h & 1) << 9))
#define CTRL_SET_GUEST_ONLY(val, h) (val |= ((h & 1) << 8))
+static unsigned long reset_value[NUM_COUNTERS];
+
+#ifdef CONFIG_OPROFILE_IBS
+
/* IbsFetchCtl bits/masks */
#define IBS_FETCH_HIGH_VALID_BIT (1UL << 17) /* bit 49 */
#define IBS_FETCH_HIGH_ENABLE (1UL << 16) /* bit 48 */
@@ -104,7 +108,6 @@ struct ibs_op_sample {
*/
static void clear_ibs_nmi(void);
-static unsigned long reset_value[NUM_COUNTERS];
static int ibs_allowed; /* AMD Family10h and later */
struct op_ibs_config {
@@ -118,6 +121,8 @@ struct op_ibs_config {
static struct op_ibs_config ibs_config;
+#endif
+
/* functions for op_amd_spec */
static void op_amd_fill_in_addresses(struct op_msrs * const msrs)
@@ -188,6 +193,8 @@ static void op_amd_setup_ctrs(struct op_msrs const * const msrs)
}
}
+#ifdef CONFIG_OPROFILE_IBS
+
static inline int
op_amd_handle_ibs(struct pt_regs * const regs,
struct op_msrs const * const msrs)
@@ -261,6 +268,8 @@ op_amd_handle_ibs(struct pt_regs * const regs,
return 1;
}
+#endif
+
static int op_amd_check_ctrs(struct pt_regs * const regs,
struct op_msrs const * const msrs)
{
@@ -277,7 +286,9 @@ static int op_amd_check_ctrs(struct pt_regs * const regs,
}
}
+#ifdef CONFIG_OPROFILE_IBS
op_amd_handle_ibs(regs, msrs);
+#endif
/* See op_model_ppro.c */
return 1;
@@ -294,6 +305,8 @@ static void op_amd_start(struct op_msrs const * const msrs)
CTRL_WRITE(low, high, msrs, i);
}
}
+
+#ifdef CONFIG_OPROFILE_IBS
if (ibs_allowed && ibs_config.fetch_enabled) {
low = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF;
high = IBS_FETCH_HIGH_ENABLE;
@@ -305,6 +318,7 @@ static void op_amd_start(struct op_msrs const * const msrs)
high = 0;
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
}
+#endif
}
@@ -323,6 +337,7 @@ static void op_amd_stop(struct op_msrs const * const msrs)
CTRL_WRITE(low, high, msrs, i);
}
+#ifdef CONFIG_OPROFILE_IBS
if (ibs_allowed && ibs_config.fetch_enabled) {
low = 0; /* clear max count and enable */
high = 0;
@@ -334,6 +349,7 @@ static void op_amd_stop(struct op_msrs const * const msrs)
high = 0;
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
}
+#endif
}
static void op_amd_shutdown(struct op_msrs const * const msrs)
@@ -350,17 +366,10 @@ static void op_amd_shutdown(struct op_msrs const * const msrs)
}
}
-#ifndef CONFIG_SMP
+#ifndef CONFIG_OPROFILE_IBS
/* no IBS support */
-static void setup_ibs(void)
-{
- ibs_allowed = 0;
-}
-
-static void clear_ibs_nmi(void) {}
-
static int op_amd_init(struct oprofile_operations *ops)
{
return 0;
@@ -441,8 +450,12 @@ static void setup_ibs(void)
if (!ibs_allowed)
return;
- if (pfm_amd64_setup_eilvt())
+ if (pfm_amd64_setup_eilvt()) {
ibs_allowed = 0;
+ return;
+ }
+
+ printk(KERN_INFO "oprofile: AMD IBS detected\n");
}
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index e1782d2..ed98227 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -328,6 +328,8 @@ static void add_trace_begin(void)
add_event_entry(TRACE_BEGIN_CODE);
}
+#ifdef CONFIG_OPROFILE_IBS
+
#define IBS_FETCH_CODE_SIZE 2
#define IBS_OP_CODE_SIZE 5
#define IBS_EIP(offset) \
@@ -390,6 +392,8 @@ static void add_ibs_begin(struct oprofile_cpu_buffer *cpu_buf, int code,
}
}
+#endif
+
static void add_sample_entry(unsigned long offset, unsigned long event)
{
add_event_entry(offset);
@@ -586,6 +590,7 @@ void sync_buffer(int cpu)
} else if (s->event == CPU_TRACE_BEGIN) {
state = sb_bt_start;
add_trace_begin();
+#ifdef CONFIG_OPROFILE_IBS
} else if (s->event == IBS_FETCH_BEGIN) {
state = sb_bt_start;
add_ibs_begin(cpu_buf,
@@ -594,6 +599,7 @@ void sync_buffer(int cpu)
state = sb_bt_start;
add_ibs_begin(cpu_buf,
IBS_OP_CODE, in_kernel, mm);
+#endif
} else {
struct mm_struct *oldmm = mm;
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index c9ac4e1..aba905b 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -253,6 +253,8 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
oprofile_add_ext_sample(pc, regs, event, is_kernel);
}
+#ifdef CONFIG_OPROFILE_IBS
+
#define MAX_IBS_SAMPLE_SIZE 14
static int log_ibs_sample(struct oprofile_cpu_buffer *cpu_buf,
unsigned long pc, int is_kernel, unsigned int *ibs, int ibs_code)
@@ -318,6 +320,8 @@ void oprofile_add_ibs_sample(struct pt_regs *const regs,
oprofile_ops.backtrace(regs, backtrace_depth);
}
+#endif
+
void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
{
struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
--
1.5.5.4
next prev parent reply other threads:[~2008-07-22 19:26 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-22 19:08 [PATCH 0/24] oprofile: Add IBS support for AMD CPUs Robert Richter
2008-07-22 19:08 ` [PATCH 01/24] x86: Add PCI IDs for AMD Barcelona PCI devices Robert Richter
2008-07-22 19:08 ` [PATCH 02/24] x86: apic_*.c: Add description to AMD's extended LVT functions Robert Richter
2008-07-22 19:08 ` [PATCH 03/24] oprofile: Add support for AMD Family 11h Robert Richter
2008-07-26 17:32 ` Daniel K.
2008-07-28 15:35 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 04/24] x86/oprofile: Introduce model specific init/exit functions Robert Richter
2008-07-22 19:08 ` [PATCH 05/24] x86/oprofile: Minor changes in op_model_athlon.c Robert Richter
2008-07-22 19:08 ` [PATCH 06/24] x86/oprofile: Renaming athlon_*() into op_amd_*() Robert Richter
2008-07-26 9:55 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 07/24] drivers/oprofile: Coding style fixes in buffer_sync.c Robert Richter
2008-07-22 19:08 ` [PATCH 08/24] OProfile: Moving increment_tail() " Robert Richter
2008-07-26 9:56 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 09/24] OProfile: Add IBS code macros Robert Richter
2008-07-22 19:08 ` [PATCH 10/24] x86/oprofile: Add IBS support for AMD CPUs, IBS buffer handling routines Robert Richter
2008-07-23 19:20 ` Maynard Johnson
2008-07-23 19:46 ` Robert Richter
2008-07-23 20:01 ` Carl Love
2008-07-23 20:19 ` Robert Richter
2008-07-26 9:58 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 11/24] x86/oprofile: Add IBS support for AMD CPUs, model specific code Robert Richter
2008-07-24 14:15 ` Maynard Johnson
2008-07-24 14:36 ` Robert Richter
2008-07-24 14:39 ` Robert Richter
2008-07-26 10:03 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 12/24] x86/oprofile: Separating the IBS handler Robert Richter
2008-07-22 19:08 ` [PATCH 13/24] OProfile: Change IBS interrupt initialization Robert Richter
2008-07-26 10:05 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 14/24] OProfile: Fix build error in op_model_athlon.c Robert Richter
2008-07-26 10:05 ` Ingo Molnar
2008-07-22 19:08 ` [PATCH 15/24] OProfile: on_each_cpu(): kill unused retry parameter Robert Richter
2008-07-22 19:09 ` [PATCH 16/24] OProfile: Fix setup_ibs_files() function interface Robert Richter
2008-07-22 19:09 ` [PATCH 17/24] OProfile: Enable IBS for AMD CPUs Robert Richter
2008-07-26 10:09 ` Ingo Molnar
2008-07-22 19:09 ` [PATCH 18/24] OProfile: Fix IBS build error for UP Robert Richter
2008-07-22 19:09 ` [PATCH 19/24] x86/oprofile: Macro definition cleanup in op_model_athlon.c Robert Richter
2008-07-22 19:09 ` [PATCH 20/24] x86/oprofile: op_model_athlon.c: Fix counter reset when reenabling IBS OP Robert Richter
2008-07-22 19:09 ` [PATCH 21/24] x86: apic: Export symbols for extended interrupt LVT functions Robert Richter
2008-07-22 19:53 ` Arjan van de Ven
2008-07-23 13:28 ` [PATCH] x86: apic: Changing export symbols to *_GPL Robert Richter
2008-07-23 19:29 ` linux-os (Dick Johnson)
2008-07-23 20:01 ` Robert Richter
2008-07-24 8:16 ` Stefan Richter
2008-07-22 19:09 ` Robert Richter [this message]
2008-07-26 10:15 ` [PATCH 22/24] x86/oprofile: Add CONFIG_OPROFILE_IBS option Ingo Molnar
2008-07-22 19:09 ` [PATCH 23/24] oprofile: Fix printk in cpu_buffer.c Robert Richter
2008-07-22 19:09 ` [PATCH 24/24] x86/oprofile: Reanaming op_model_athlon.c to op_model_amd.c Robert Richter
2008-07-26 10:17 ` Ingo Molnar
2008-07-23 12:24 ` [PATCH 0/24] oprofile: Add IBS support for AMD CPUs Maynard Johnson
2008-07-26 9:52 ` Ingo Molnar
2008-07-28 14:02 ` Robert Richter
2008-07-31 10:32 ` 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=1216753748-11261-23-git-send-email-robert.richter@amd.com \
--to=robert.richter@amd.com \
--cc=barry.kasindorf@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oprofile-list@lists.sourceforge.net \
--cc=tglx@linutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome