x86/oprofile: moving arch_perfmon counter setup to op_x86_model_spec.init
The function arch_perfmon_init() in nmi_int.c is model specific. This patch moves it to op_model_ppro.c by using the init function pointer in struct op_x86_model_spec. Cc: Andi Kleen <ak@linux.intel.com> Signed-off-by: Robert Richter <robert.richter@amd.com>
This commit is contained in:
parent
849620fab4
commit
e419294ed3
3 changed files with 17 additions and 15 deletions
|
@ -427,7 +427,7 @@ static int __init ppro_init(char **cpu_type)
|
||||||
*cpu_type = "i386/core_2";
|
*cpu_type = "i386/core_2";
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 26:
|
||||||
arch_perfmon_setup_counters();
|
model = &op_arch_perfmon_spec;
|
||||||
*cpu_type = "i386/core_i7";
|
*cpu_type = "i386/core_i7";
|
||||||
break;
|
break;
|
||||||
case 28:
|
case 28:
|
||||||
|
@ -442,16 +442,6 @@ static int __init ppro_init(char **cpu_type)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init arch_perfmon_init(char **cpu_type)
|
|
||||||
{
|
|
||||||
if (!cpu_has_arch_perfmon)
|
|
||||||
return 0;
|
|
||||||
*cpu_type = "i386/arch_perfmon";
|
|
||||||
model = &op_arch_perfmon_spec;
|
|
||||||
arch_perfmon_setup_counters();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* in order to get sysfs right */
|
/* in order to get sysfs right */
|
||||||
static int using_nmi;
|
static int using_nmi;
|
||||||
|
|
||||||
|
@ -509,8 +499,15 @@ int __init op_nmi_init(struct oprofile_operations *ops)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cpu_type && !arch_perfmon_init(&cpu_type))
|
if (cpu_type)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!cpu_has_arch_perfmon)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
/* use arch perfmon as fallback */
|
||||||
|
cpu_type = "i386/arch_perfmon";
|
||||||
|
model = &op_arch_perfmon_spec;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -233,7 +233,7 @@ struct op_x86_model_spec const op_ppro_spec = {
|
||||||
* the specific CPU.
|
* the specific CPU.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void arch_perfmon_setup_counters(void)
|
static void arch_perfmon_setup_counters(void)
|
||||||
{
|
{
|
||||||
union cpuid10_eax eax;
|
union cpuid10_eax eax;
|
||||||
|
|
||||||
|
@ -253,7 +253,14 @@ void arch_perfmon_setup_counters(void)
|
||||||
op_arch_perfmon_spec.num_controls = num_counters;
|
op_arch_perfmon_spec.num_controls = num_counters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int arch_perfmon_init(struct oprofile_operations *ignore)
|
||||||
|
{
|
||||||
|
arch_perfmon_setup_counters();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct op_x86_model_spec op_arch_perfmon_spec = {
|
struct op_x86_model_spec op_arch_perfmon_spec = {
|
||||||
|
.init = &arch_perfmon_init,
|
||||||
/* num_counters/num_controls filled in at runtime */
|
/* num_counters/num_controls filled in at runtime */
|
||||||
.fill_in_addresses = &ppro_fill_in_addresses,
|
.fill_in_addresses = &ppro_fill_in_addresses,
|
||||||
/* user space does the cpuid check for available events */
|
/* user space does the cpuid check for available events */
|
||||||
|
|
|
@ -51,6 +51,4 @@ extern struct op_x86_model_spec const op_p4_ht2_spec;
|
||||||
extern struct op_x86_model_spec const op_amd_spec;
|
extern struct op_x86_model_spec const op_amd_spec;
|
||||||
extern struct op_x86_model_spec op_arch_perfmon_spec;
|
extern struct op_x86_model_spec op_arch_perfmon_spec;
|
||||||
|
|
||||||
extern void arch_perfmon_setup_counters(void);
|
|
||||||
|
|
||||||
#endif /* OP_X86_MODEL_H */
|
#endif /* OP_X86_MODEL_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue