oprofile/x86: fix perfctr nmi reservation for mulitplexing
authorRobert Richter <robert.richter@amd.com>
Thu, 25 Feb 2010 18:16:46 +0000 (19:16 +0100)
committerRobert Richter <robert.richter@amd.com>
Fri, 26 Feb 2010 14:19:03 +0000 (15:19 +0100)
Multiple virtual counters share one physical counter. The reservation
of virtual counters fails due to duplicate allocation of the same
counter. The counters are already reserved. Thus, virtual counter
reservation may removed at all. This also makes the code easier.

Cc: stable@kernel.org
Signed-off-by: Robert Richter <robert.richter@amd.com>
arch/x86/oprofile/nmi_int.c
arch/x86/oprofile/op_model_amd.c

index 3347f696edc77d4692f7b0b0fdb774677b573cfa..7170d1e2989628072c3b187afb334f477def3cd3 100644 (file)
@@ -179,7 +179,6 @@ static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
                if (counter_config[i].enabled) {
                        multiplex[i].saved = -(u64)counter_config[i].count;
                } else {
-                       multiplex[i].addr  = 0;
                        multiplex[i].saved = 0;
                }
        }
@@ -189,25 +188,27 @@ static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
 
 static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs)
 {
+       struct op_msr *counters = msrs->counters;
        struct op_msr *multiplex = msrs->multiplex;
        int i;
 
        for (i = 0; i < model->num_counters; ++i) {
                int virt = op_x86_phys_to_virt(i);
-               if (multiplex[virt].addr)
-                       rdmsrl(multiplex[virt].addr, multiplex[virt].saved);
+               if (counters[i].addr)
+                       rdmsrl(counters[i].addr, multiplex[virt].saved);
        }
 }
 
 static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
 {
+       struct op_msr *counters = msrs->counters;
        struct op_msr *multiplex = msrs->multiplex;
        int i;
 
        for (i = 0; i < model->num_counters; ++i) {
                int virt = op_x86_phys_to_virt(i);
-               if (multiplex[virt].addr)
-                       wrmsrl(multiplex[virt].addr, multiplex[virt].saved);
+               if (counters[i].addr)
+                       wrmsrl(counters[i].addr, multiplex[virt].saved);
        }
 }
 
index ef9d735dea35baf3bb4572ed1a26d94e19f52329..2aab018a7a56e793c21263ac54f5ec6e1c73a6c2 100644 (file)
@@ -118,19 +118,6 @@ static u32 get_ibs_caps(void)
 
 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
 
-static void op_mux_fill_in_addresses(struct op_msrs * const msrs)
-{
-       int i;
-
-       for (i = 0; i < NUM_VIRT_COUNTERS; i++) {
-               int hw_counter = op_x86_virt_to_phys(i);
-               if (reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
-                       msrs->multiplex[i].addr = MSR_K7_PERFCTR0 + hw_counter;
-               else
-                       msrs->multiplex[i].addr = 0;
-       }
-}
-
 static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
                               struct op_msrs const * const msrs)
 {
@@ -149,10 +136,6 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
        }
 }
 
-#else
-
-static inline void op_mux_fill_in_addresses(struct op_msrs * const msrs) { }
-
 #endif
 
 /* functions for op_amd_spec */
@@ -174,8 +157,6 @@ static void op_amd_fill_in_addresses(struct op_msrs * const msrs)
                else
                        msrs->controls[i].addr = 0;
        }
-
-       op_mux_fill_in_addresses(msrs);
 }
 
 static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,