Skip to content

Commit

Permalink
Merge pull request #68 from soramichi/fix_counter_name
Browse files Browse the repository at this point in the history
add missing "_PERF_" to some counter names
  • Loading branch information
andikleen committed Feb 18, 2017
2 parents 5be725d + 99b7265 commit d748b4c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions simple-pebs/simple-pebs.c
Expand Up @@ -59,9 +59,9 @@
#define MSR_IA32_EVNTSEL0 0x00000186

#define MSR_IA32_PERF_CABABILITIES 0x00000345
#define MSR_IA32_GLOBAL_STATUS 0x0000038e
#define MSR_IA32_GLOBAL_CTRL 0x0000038f
#define MSR_IA32_GLOBAL_OVF_CTRL 0x00000390
#define MSR_IA32_PERF_GLOBAL_STATUS 0x0000038e
#define MSR_IA32_PERF_GLOBAL_CTRL 0x0000038f
#define MSR_IA32_PERF_GLOBAL_OVF_CTRL 0x00000390
#define MSR_IA32_PEBS_ENABLE 0x000003f1
#define MSR_IA32_DS_AREA 0x00000600

Expand Down Expand Up @@ -242,23 +242,23 @@ static void status_dump(char *where)
{
#if 0
u64 val, val2;
rdmsrl(MSR_IA32_GLOBAL_STATUS, val);
rdmsrl(MSR_IA32_GLOBAL_CTRL, val2);
rdmsrl(MSR_IA32_PERF_GLOBAL_STATUS, val);
rdmsrl(MSR_IA32_PERF_GLOBAL_CTRL, val2);
pr_debug("%d: %s: status %llx ctrl %llx counter %llx\n", smp_processor_id(), where, val, val2, __builtin_ia32_rdpmc(0));
#endif
}

static void start_stop_cpu(void *arg)
{
wrmsrl(MSR_IA32_GLOBAL_CTRL, arg ? 1 : 0);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, arg ? 1 : 0);
status_dump("stop");
}

static void reset_buffer_cpu(void *arg)
{
wrmsrl(MSR_IA32_GLOBAL_CTRL, 0);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 0);
__this_cpu_write(out_buffer, __this_cpu_read(out_buffer_base));
wrmsrl(MSR_IA32_GLOBAL_CTRL, 1);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 1);
}

static DEFINE_MUTEX(reset_mutex);
Expand Down Expand Up @@ -437,10 +437,10 @@ void simple_pebs_pmi(void)
status_dump("pmi1");

/* disable PMU */
wrmsrl(MSR_IA32_GLOBAL_CTRL, 0);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 0);

/* global status ack */
wrmsrl(MSR_IA32_GLOBAL_OVF_CTRL, 1ULL << 62);
wrmsrl(MSR_IA32_PERF_GLOBAL_OVF_CTRL, 1ULL << 62);

wrmsrl(MSR_IA32_PERFCTR0, -PERIOD); /* ? sign extension on width ? */

Expand Down Expand Up @@ -487,7 +487,7 @@ void simple_pebs_pmi(void)
if ((void *)outbu - (void *)outbu_start >= OUT_BUFFER_SIZE/2) {
wake_up(this_cpu_ptr(&simple_pebs_wait));
} else
wrmsrl(MSR_IA32_GLOBAL_CTRL, 1);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 1);

status_dump("pmi3");
}
Expand Down Expand Up @@ -569,7 +569,7 @@ static void simple_pebs_cpu_init(void *arg)
/* Initialize PMU */

/* First disable PMU to avoid races */
wrmsrl(MSR_IA32_GLOBAL_CTRL, 0);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 0);

wrmsrl(MSR_IA32_PERFCTR0, -PERIOD); /* ? sign extension on width ? */
wrmsrl(MSR_IA32_EVNTSEL0,
Expand All @@ -578,14 +578,14 @@ static void simple_pebs_cpu_init(void *arg)
/* Enable PEBS for counter 0 */
wrmsrl(MSR_IA32_PEBS_ENABLE, 1);

wrmsrl(MSR_IA32_GLOBAL_CTRL, 1);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 1);
__this_cpu_write(cpu_initialized, 1);
}

static void simple_pebs_cpu_reset(void *arg)
{
if (__this_cpu_read(cpu_initialized)) {
wrmsrl(MSR_IA32_GLOBAL_CTRL, 0);
wrmsrl(MSR_IA32_PERF_GLOBAL_CTRL, 0);
wrmsrl(MSR_IA32_PEBS_ENABLE, 0);
wrmsrl(MSR_IA32_EVNTSEL0, 0);
wrmsrl(MSR_IA32_PERFCTR0, 0);
Expand Down

0 comments on commit d748b4c

Please sign in to comment.