aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/oprofile/nmi_int.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/oprofile/nmi_int.c')
-rw-r--r--arch/x86/oprofile/nmi_int.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index b211d335e075..02b57b8d0e61 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -27,12 +27,6 @@
27#include "op_counter.h" 27#include "op_counter.h"
28#include "op_x86_model.h" 28#include "op_x86_model.h"
29 29
30
31#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
32DEFINE_PER_CPU(int, switch_index);
33#endif
34
35
36static struct op_x86_model_spec const *model; 30static struct op_x86_model_spec const *model;
37static DEFINE_PER_CPU(struct op_msrs, cpu_msrs); 31static DEFINE_PER_CPU(struct op_msrs, cpu_msrs);
38static DEFINE_PER_CPU(unsigned long, saved_lvtpc); 32static DEFINE_PER_CPU(unsigned long, saved_lvtpc);
@@ -103,6 +97,21 @@ static void nmi_cpu_save_registers(struct op_msrs *msrs)
103 } 97 }
104} 98}
105 99
100#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
101
102static DEFINE_PER_CPU(int, switch_index);
103
104inline int op_x86_phys_to_virt(int phys)
105{
106 return __get_cpu_var(switch_index) + phys;
107}
108
109#else
110
111inline int op_x86_phys_to_virt(int phys) { return phys; }
112
113#endif
114
106static void free_msrs(void) 115static void free_msrs(void)
107{ 116{
108 int i; 117 int i;
@@ -248,31 +257,25 @@ static int nmi_setup(void)
248 257
249static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs) 258static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs)
250{ 259{
251 unsigned int si = __get_cpu_var(switch_index);
252 struct op_msr *multiplex = msrs->multiplex; 260 struct op_msr *multiplex = msrs->multiplex;
253 unsigned int i; 261 int i;
254 262
255 for (i = 0; i < model->num_counters; ++i) { 263 for (i = 0; i < model->num_counters; ++i) {
256 int offset = i + si; 264 int virt = op_x86_phys_to_virt(i);
257 if (multiplex[offset].addr) { 265 if (multiplex[virt].addr)
258 rdmsrl(multiplex[offset].addr, 266 rdmsrl(multiplex[virt].addr, multiplex[virt].saved);
259 multiplex[offset].saved);
260 }
261 } 267 }
262} 268}
263 269
264static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs) 270static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
265{ 271{
266 unsigned int si = __get_cpu_var(switch_index);
267 struct op_msr *multiplex = msrs->multiplex; 272 struct op_msr *multiplex = msrs->multiplex;
268 unsigned int i; 273 int i;
269 274
270 for (i = 0; i < model->num_counters; ++i) { 275 for (i = 0; i < model->num_counters; ++i) {
271 int offset = i + si; 276 int virt = op_x86_phys_to_virt(i);
272 if (multiplex[offset].addr) { 277 if (multiplex[virt].addr)
273 wrmsrl(multiplex[offset].addr, 278 wrmsrl(multiplex[virt].addr, multiplex[virt].saved);
274 multiplex[offset].saved);
275 }
276 } 279 }
277} 280}
278 281