Skip to content

Commit

Permalink
Merge branch 'oprofile-for-linus' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/tip/linux-2.6-tip

* 'oprofile-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  oprofile: select RING_BUFFER
  ring_buffer: adding EXPORT_SYMBOLs
  oprofile: fix lost sample counter
  oprofile: remove nr_available_slots()
  oprofile: port to the new ring_buffer
  ring_buffer: add remaining cpu functions to ring_buffer.h
  oprofile: moving cpu_buffer_reset() to cpu_buffer.h
  oprofile: adding cpu_buffer_entries()
  oprofile: adding cpu_buffer_write_commit()
  oprofile: adding cpu buffer r/w access functions
  ftrace: remove unused function arg in trace_iterator_increment()
  ring_buffer: update description for ring_buffer_alloc()
  oprofile: set values to default when creating oprofilefs
  oprofile: implement switch/case in buffer_sync.c
  x86/oprofile: cleanup IBS init/exit functions in op_model_amd.c
  x86/oprofile: reordering IBS code in op_model_amd.c
  oprofile: fix typo
  oprofile: whitspace changes only
  oprofile: update comment for oprofile_add_sample()
  oprofile: comment cleanup
  • Loading branch information
torvalds committed Dec 31, 2008
2 parents db5e53f + d69d59f commit 526ea06
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 228 deletions.
2 changes: 2 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ config OPROFILE
tristate "OProfile system profiling (EXPERIMENTAL)"
depends on PROFILING
depends on HAVE_OPROFILE
select TRACING
select RING_BUFFER
help
OProfile is a profiling system capable of profiling the
whole system, include the kernel, kernel modules, libraries,
Expand Down
89 changes: 46 additions & 43 deletions arch/x86/oprofile/op_model_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ static unsigned long reset_value[NUM_COUNTERS];
#define IBS_FETCH_BEGIN 3
#define IBS_OP_BEGIN 4

/* The function interface needs to be fixed, something like add
data. Should then be added to linux/oprofile.h. */
/*
* The function interface needs to be fixed, something like add
* data. Should then be added to linux/oprofile.h.
*/
extern void
oprofile_add_ibs_sample(struct pt_regs *const regs,
unsigned int *const ibs_sample, int ibs_code);
oprofile_add_ibs_sample(struct pt_regs * const regs,
unsigned int * const ibs_sample, int ibs_code);

struct ibs_fetch_sample {
/* MSRC001_1031 IBS Fetch Linear Address Register */
Expand Down Expand Up @@ -104,11 +106,6 @@ struct ibs_op_sample {
unsigned int ibs_dc_phys_high;
};

/*
* unitialize the APIC for the IBS interrupts if needed on AMD Family10h+
*/
static void clear_ibs_nmi(void);

static int ibs_allowed; /* AMD Family10h and later */

struct op_ibs_config {
Expand Down Expand Up @@ -223,7 +220,7 @@ op_amd_handle_ibs(struct pt_regs * const regs,
(unsigned int *)&ibs_fetch,
IBS_FETCH_BEGIN);

/*reenable the IRQ */
/* reenable the IRQ */
rdmsr(MSR_AMD64_IBSFETCHCTL, low, high);
high &= ~IBS_FETCH_HIGH_VALID_BIT;
high |= IBS_FETCH_HIGH_ENABLE;
Expand Down Expand Up @@ -331,8 +328,10 @@ static void op_amd_stop(struct op_msrs const * const msrs)
unsigned int low, high;
int i;

/* Subtle: stop on all counters to avoid race with
* setting our pm callback */
/*
* Subtle: stop on all counters to avoid race with setting our
* pm callback
*/
for (i = 0 ; i < NUM_COUNTERS ; ++i) {
if (!reset_value[i])
continue;
Expand All @@ -343,13 +342,15 @@ static void op_amd_stop(struct op_msrs const * const msrs)

#ifdef CONFIG_OPROFILE_IBS
if (ibs_allowed && ibs_config.fetch_enabled) {
low = 0; /* clear max count and enable */
/* clear max count and enable */
low = 0;
high = 0;
wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
}

if (ibs_allowed && ibs_config.op_enabled) {
low = 0; /* clear max count and enable */
/* clear max count and enable */
low = 0;
high = 0;
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
}
Expand All @@ -370,18 +371,7 @@ static void op_amd_shutdown(struct op_msrs const * const msrs)
}
}

#ifndef CONFIG_OPROFILE_IBS

/* no IBS support */

static int op_amd_init(struct oprofile_operations *ops)
{
return 0;
}

static void op_amd_exit(void) {}

#else
#ifdef CONFIG_OPROFILE_IBS

static u8 ibs_eilvt_off;

Expand All @@ -395,7 +385,7 @@ static inline void apic_clear_ibs_nmi_per_cpu(void *arg)
setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_FIX, 1);
}

static int pfm_amd64_setup_eilvt(void)
static int init_ibs_nmi(void)
{
#define IBSCTL_LVTOFFSETVAL (1 << 8)
#define IBSCTL 0x1cc
Expand Down Expand Up @@ -443,33 +433,35 @@ static int pfm_amd64_setup_eilvt(void)
return 0;
}

/*
* initialize the APIC for the IBS interrupts
* if available (AMD Family10h rev B0 and later)
*/
static void setup_ibs(void)
/* uninitialize the APIC for the IBS interrupts if needed */
static void clear_ibs_nmi(void)
{
if (ibs_allowed)
on_each_cpu(apic_clear_ibs_nmi_per_cpu, NULL, 1);
}

/* initialize the APIC for the IBS interrupts if available */
static void ibs_init(void)
{
ibs_allowed = boot_cpu_has(X86_FEATURE_IBS);

if (!ibs_allowed)
return;

if (pfm_amd64_setup_eilvt()) {
if (init_ibs_nmi()) {
ibs_allowed = 0;
return;
}

printk(KERN_INFO "oprofile: AMD IBS detected\n");
}


/*
* unitialize the APIC for the IBS interrupts if needed on AMD Family10h
* rev B0 and later */
static void clear_ibs_nmi(void)
static void ibs_exit(void)
{
if (ibs_allowed)
on_each_cpu(apic_clear_ibs_nmi_per_cpu, NULL, 1);
if (!ibs_allowed)
return;

clear_ibs_nmi();
}

static int (*create_arch_files)(struct super_block *sb, struct dentry *root);
Expand Down Expand Up @@ -519,18 +511,29 @@ static int setup_ibs_files(struct super_block *sb, struct dentry *root)

static int op_amd_init(struct oprofile_operations *ops)
{
setup_ibs();
ibs_init();
create_arch_files = ops->create_files;
ops->create_files = setup_ibs_files;
return 0;
}

static void op_amd_exit(void)
{
clear_ibs_nmi();
ibs_exit();
}

#endif
#else

/* no IBS support */

static int op_amd_init(struct oprofile_operations *ops)
{
return 0;
}

static void op_amd_exit(void) {}

#endif /* CONFIG_OPROFILE_IBS */

struct op_x86_model_spec const op_amd_spec = {
.init = op_amd_init,
Expand Down
Loading

0 comments on commit 526ea06

Please sign in to comment.