x86/oprofile: Fix initialization of switch_index
Variable switch_index must be initialized for each cpu. This patch fixes the initialization by moving it to the per-cpu init function nmi_cpu_setup(). Signed-off-by: Robert Richter <robert.richter@amd.com>
This commit is contained in:
parent
82a225283f
commit
6bfccd099c
@ -160,7 +160,7 @@ static int allocate_msrs(void)
|
|||||||
|
|
||||||
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
|
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
|
||||||
|
|
||||||
static void nmi_setup_cpu_mux(struct op_msrs const * const msrs)
|
static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct op_msr *multiplex = msrs->multiplex;
|
struct op_msr *multiplex = msrs->multiplex;
|
||||||
@ -173,8 +173,15 @@ static void nmi_setup_cpu_mux(struct op_msrs const * const msrs)
|
|||||||
multiplex[i].saved = 0;
|
multiplex[i].saved = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
per_cpu(switch_index, cpu) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs) { }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void nmi_cpu_setup(void *dummy)
|
static void nmi_cpu_setup(void *dummy)
|
||||||
@ -184,9 +191,7 @@ static void nmi_cpu_setup(void *dummy)
|
|||||||
nmi_cpu_save_registers(msrs);
|
nmi_cpu_save_registers(msrs);
|
||||||
spin_lock(&oprofilefs_lock);
|
spin_lock(&oprofilefs_lock);
|
||||||
model->setup_ctrs(model, msrs);
|
model->setup_ctrs(model, msrs);
|
||||||
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
|
nmi_cpu_setup_mux(cpu, msrs);
|
||||||
nmi_setup_cpu_mux(msrs);
|
|
||||||
#endif
|
|
||||||
spin_unlock(&oprofilefs_lock);
|
spin_unlock(&oprofilefs_lock);
|
||||||
per_cpu(saved_lvtpc, cpu) = apic_read(APIC_LVTPC);
|
per_cpu(saved_lvtpc, cpu) = apic_read(APIC_LVTPC);
|
||||||
apic_write(APIC_LVTPC, APIC_DM_NMI);
|
apic_write(APIC_LVTPC, APIC_DM_NMI);
|
||||||
@ -662,9 +667,6 @@ int __init op_nmi_init(struct oprofile_operations *ops)
|
|||||||
register_cpu_notifier(&oprofile_cpu_nb);
|
register_cpu_notifier(&oprofile_cpu_nb);
|
||||||
#endif
|
#endif
|
||||||
/* default values, can be overwritten by model */
|
/* default values, can be overwritten by model */
|
||||||
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
|
|
||||||
__raw_get_cpu_var(switch_index) = 0;
|
|
||||||
#endif
|
|
||||||
ops->create_files = nmi_create_files;
|
ops->create_files = nmi_create_files;
|
||||||
ops->setup = nmi_setup;
|
ops->setup = nmi_setup;
|
||||||
ops->shutdown = nmi_shutdown;
|
ops->shutdown = nmi_shutdown;
|
||||||
|
Loading…
Reference in New Issue
Block a user