Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158236
b: refs/heads/master
c: b28d1b9
h: refs/heads/master
v: v3
  • Loading branch information
Robert Richter committed Jul 20, 2009
1 parent b680674 commit a744d60
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 75 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d0f585dd20010f8479e56b5c6f391ef18e26877e
refs/heads/master: b28d1b923ab52d535c0719155dccf3b3d98bab9f
144 changes: 70 additions & 74 deletions trunk/arch/x86/oprofile/nmi_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,29 @@ static void nmi_cpu_save_registers(struct op_msrs *msrs)
}
}

static void nmi_cpu_start(void *dummy)
{
struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
model->start(msrs);
}

static int nmi_start(void)
{
on_each_cpu(nmi_cpu_start, NULL, 1);
return 0;
}

static void nmi_cpu_stop(void *dummy)
{
struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
model->stop(msrs);
}

static void nmi_stop(void)
{
on_each_cpu(nmi_cpu_stop, NULL, 1);
}

#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX

static DEFINE_PER_CPU(int, switch_index);
Expand Down Expand Up @@ -171,6 +194,53 @@ static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
}
}

static void nmi_cpu_switch(void *dummy)
{
int cpu = smp_processor_id();
int si = per_cpu(switch_index, cpu);
struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);

nmi_cpu_stop(NULL);
nmi_cpu_save_mpx_registers(msrs);

/* move to next set */
si += model->num_counters;
if ((si > model->num_virt_counters) || (counter_config[si].count == 0))
per_cpu(switch_index, cpu) = 0;
else
per_cpu(switch_index, cpu) = si;

model->switch_ctrl(model, msrs);
nmi_cpu_restore_mpx_registers(msrs);

nmi_cpu_start(NULL);
}


/*
* Quick check to see if multiplexing is necessary.
* The check should be sufficient since counters are used
* in ordre.
*/
static int nmi_multiplex_on(void)
{
return counter_config[model->num_counters].count ? 0 : -EINVAL;
}

static int nmi_switch_event(void)
{
if (!model->switch_ctrl)
return -ENOSYS; /* not implemented */
if (nmi_multiplex_on() < 0)
return -EINVAL; /* not necessary */

on_each_cpu(nmi_cpu_switch, NULL, 1);

atomic_inc(&multiplex_counter);

return 0;
}

#else

inline int op_x86_phys_to_virt(int phys) { return phys; }
Expand Down Expand Up @@ -325,29 +395,6 @@ static void nmi_shutdown(void)
put_cpu_var(cpu_msrs);
}

static void nmi_cpu_start(void *dummy)
{
struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
model->start(msrs);
}

static int nmi_start(void)
{
on_each_cpu(nmi_cpu_start, NULL, 1);
return 0;
}

static void nmi_cpu_stop(void *dummy)
{
struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
model->stop(msrs);
}

static void nmi_stop(void)
{
on_each_cpu(nmi_cpu_stop, NULL, 1);
}

static int nmi_create_files(struct super_block *sb, struct dentry *root)
{
unsigned int i;
Expand Down Expand Up @@ -379,57 +426,6 @@ static int nmi_create_files(struct super_block *sb, struct dentry *root)
return 0;
}

#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX

static void nmi_cpu_switch(void *dummy)
{
int cpu = smp_processor_id();
int si = per_cpu(switch_index, cpu);
struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);

nmi_cpu_stop(NULL);
nmi_cpu_save_mpx_registers(msrs);

/* move to next set */
si += model->num_counters;
if ((si > model->num_virt_counters) || (counter_config[si].count == 0))
per_cpu(switch_index, cpu) = 0;
else
per_cpu(switch_index, cpu) = si;

model->switch_ctrl(model, msrs);
nmi_cpu_restore_mpx_registers(msrs);

nmi_cpu_start(NULL);
}


/*
* Quick check to see if multiplexing is necessary.
* The check should be sufficient since counters are used
* in ordre.
*/
static int nmi_multiplex_on(void)
{
return counter_config[model->num_counters].count ? 0 : -EINVAL;
}

static int nmi_switch_event(void)
{
if (!model->switch_ctrl)
return -ENOSYS; /* not implemented */
if (nmi_multiplex_on() < 0)
return -EINVAL; /* not necessary */

on_each_cpu(nmi_cpu_switch, NULL, 1);

atomic_inc(&multiplex_counter);

return 0;
}

#endif

#ifdef CONFIG_SMP
static int oprofile_cpu_notifier(struct notifier_block *b, unsigned long action,
void *data)
Expand Down

0 comments on commit a744d60

Please sign in to comment.