Commit 61d149d5 authored by Robert Richter's avatar Robert Richter

x86/oprofile: Implement op_x86_virt_to_phys()

This patch implements a common x86 function to convert virtual counter
numbers to physical.
Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
parent 1b294f59
...@@ -129,6 +129,11 @@ inline int op_x86_phys_to_virt(int phys) ...@@ -129,6 +129,11 @@ inline int op_x86_phys_to_virt(int phys)
return __get_cpu_var(switch_index) + phys; return __get_cpu_var(switch_index) + phys;
} }
inline int op_x86_virt_to_phys(int virt)
{
return virt % model->num_counters;
}
static void nmi_shutdown_mux(void) static void nmi_shutdown_mux(void)
{ {
int i; int i;
...@@ -270,6 +275,7 @@ static void mux_clone(int cpu) ...@@ -270,6 +275,7 @@ static void mux_clone(int cpu)
#else #else
inline int op_x86_phys_to_virt(int phys) { return phys; } inline int op_x86_phys_to_virt(int phys) { return phys; }
inline int op_x86_virt_to_phys(int virt) { return virt; }
static inline void nmi_shutdown_mux(void) { } static inline void nmi_shutdown_mux(void) { }
static inline int nmi_setup_mux(void) { return 1; } static inline int nmi_setup_mux(void) { return 1; }
static inline void static inline void
......
...@@ -81,7 +81,7 @@ static void op_mux_fill_in_addresses(struct op_msrs * const msrs) ...@@ -81,7 +81,7 @@ static void op_mux_fill_in_addresses(struct op_msrs * const msrs)
int i; int i;
for (i = 0; i < NUM_VIRT_COUNTERS; i++) { for (i = 0; i < NUM_VIRT_COUNTERS; i++) {
int hw_counter = i % NUM_COUNTERS; int hw_counter = op_x86_virt_to_phys(i);
if (reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i)) if (reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
msrs->multiplex[i].addr = MSR_K7_PERFCTR0 + hw_counter; msrs->multiplex[i].addr = MSR_K7_PERFCTR0 + hw_counter;
else else
......
...@@ -60,6 +60,7 @@ struct op_counter_config; ...@@ -60,6 +60,7 @@ struct op_counter_config;
extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model, extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
struct op_counter_config *counter_config); struct op_counter_config *counter_config);
extern int op_x86_phys_to_virt(int phys); extern int op_x86_phys_to_virt(int phys);
extern int op_x86_virt_to_phys(int virt);
extern struct op_x86_model_spec op_ppro_spec; extern struct op_x86_model_spec op_ppro_spec;
extern struct op_x86_model_spec op_p4_spec; extern struct op_x86_model_spec op_p4_spec;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment