aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2008-10-12 15:12:34 -0400
committerRobert Richter <robert.richter@amd.com>2009-06-10 16:09:24 -0400
commite419294ed3c98cccc145202e4fe165bfd8099d63 (patch)
tree24eced48e81cc31765ac1a3a87eb75bed583e1fc
parent849620fab413355eff48232eac5a8c53c57615c5 (diff)
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>
-rw-r--r--arch/x86/oprofile/nmi_int.c21
-rw-r--r--arch/x86/oprofile/op_model_ppro.c9
-rw-r--r--arch/x86/oprofile/op_x86_model.h2
3 files changed, 17 insertions, 15 deletions
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 3b285e656e27..dd8515301fbf 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -427,7 +427,7 @@ static int __init ppro_init(char **cpu_type)
427 *cpu_type = "i386/core_2"; 427 *cpu_type = "i386/core_2";
428 break; 428 break;
429 case 26: 429 case 26:
430 arch_perfmon_setup_counters(); 430 model = &op_arch_perfmon_spec;
431 *cpu_type = "i386/core_i7"; 431 *cpu_type = "i386/core_i7";
432 break; 432 break;
433 case 28: 433 case 28:
@@ -442,16 +442,6 @@ static int __init ppro_init(char **cpu_type)
442 return 1; 442 return 1;
443} 443}
444 444
445static int __init arch_perfmon_init(char **cpu_type)
446{
447 if (!cpu_has_arch_perfmon)
448 return 0;
449 *cpu_type = "i386/arch_perfmon";
450 model = &op_arch_perfmon_spec;
451 arch_perfmon_setup_counters();
452 return 1;
453}
454
455/* in order to get sysfs right */ 445/* in order to get sysfs right */
456static int using_nmi; 446static int using_nmi;
457 447
@@ -509,8 +499,15 @@ int __init op_nmi_init(struct oprofile_operations *ops)
509 break; 499 break;
510 } 500 }
511 501
512 if (!cpu_type && !arch_perfmon_init(&cpu_type)) 502 if (cpu_type)
503 break;
504
505 if (!cpu_has_arch_perfmon)
513 return -ENODEV; 506 return -ENODEV;
507
508 /* use arch perfmon as fallback */
509 cpu_type = "i386/arch_perfmon";
510 model = &op_arch_perfmon_spec;
514 break; 511 break;
515 512
516 default: 513 default:
diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
index 2a123990a84c..ae5811966883 100644
--- a/arch/x86/oprofile/op_model_ppro.c
+++ b/arch/x86/oprofile/op_model_ppro.c
@@ -233,7 +233,7 @@ struct op_x86_model_spec const op_ppro_spec = {
233 * the specific CPU. 233 * the specific CPU.
234 */ 234 */
235 235
236void arch_perfmon_setup_counters(void) 236static void arch_perfmon_setup_counters(void)
237{ 237{
238 union cpuid10_eax eax; 238 union cpuid10_eax eax;
239 239
@@ -253,7 +253,14 @@ void arch_perfmon_setup_counters(void)
253 op_arch_perfmon_spec.num_controls = num_counters; 253 op_arch_perfmon_spec.num_controls = num_counters;
254} 254}
255 255
256static int arch_perfmon_init(struct oprofile_operations *ignore)
257{
258 arch_perfmon_setup_counters();
259 return 0;
260}
261
256struct op_x86_model_spec op_arch_perfmon_spec = { 262struct op_x86_model_spec op_arch_perfmon_spec = {
263 .init = &arch_perfmon_init,
257 /* num_counters/num_controls filled in at runtime */ 264 /* num_counters/num_controls filled in at runtime */
258 .fill_in_addresses = &ppro_fill_in_addresses, 265 .fill_in_addresses = &ppro_fill_in_addresses,
259 /* user space does the cpuid check for available events */ 266 /* user space does the cpuid check for available events */
diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
index 2317149c94f0..ed27783bb0d4 100644
--- a/arch/x86/oprofile/op_x86_model.h
+++ b/arch/x86/oprofile/op_x86_model.h
@@ -51,6 +51,4 @@ extern struct op_x86_model_spec const op_p4_ht2_spec;
51extern struct op_x86_model_spec const op_amd_spec; 51extern struct op_x86_model_spec const op_amd_spec;
52extern struct op_x86_model_spec op_arch_perfmon_spec; 52extern struct op_x86_model_spec op_arch_perfmon_spec;
53 53
54extern void arch_perfmon_setup_counters(void);
55
56#endif /* OP_X86_MODEL_H */ 54#endif /* OP_X86_MODEL_H */