diff options
author | Robert Richter <robert.richter@amd.com> | 2008-07-22 15:08:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-26 05:48:01 -0400 |
commit | adf5ec0bca553b763a6b9baed2677a4c7470025b (patch) | |
tree | c3009400fcdd1d0a27ab96e8d9ed6a88535307d4 /arch/x86 | |
parent | 12f2b2610e812627acf338aaf043fef20bb726ca (diff) |
x86/oprofile: introduce model specific init/exit functions
This patch implements model specific OProfile init/exit functions for
x86 CPUs. Though there is more rework needed at the initialization
code, this new introduced functions allow it to keep model specific
code in the corresponding op_model_*.c files.
The function interface is the same as for oprofile_arch_init/exit().
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/oprofile/nmi_int.c | 11 | ||||
-rw-r--r-- | arch/x86/oprofile/op_model_athlon.c | 18 | ||||
-rw-r--r-- | arch/x86/oprofile/op_x86_model.h | 2 |
3 files changed, 27 insertions, 4 deletions
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c index 33db99ab90c0..75e889156f23 100644 --- a/arch/x86/oprofile/nmi_int.c +++ b/arch/x86/oprofile/nmi_int.c | |||
@@ -1,10 +1,11 @@ | |||
1 | /** | 1 | /** |
2 | * @file nmi_int.c | 2 | * @file nmi_int.c |
3 | * | 3 | * |
4 | * @remark Copyright 2002 OProfile authors | 4 | * @remark Copyright 2002-2008 OProfile authors |
5 | * @remark Read the file COPYING | 5 | * @remark Read the file COPYING |
6 | * | 6 | * |
7 | * @author John Levon <levon@movementarian.org> | 7 | * @author John Levon <levon@movementarian.org> |
8 | * @author Robert Richter <robert.richter@amd.com> | ||
8 | */ | 9 | */ |
9 | 10 | ||
10 | #include <linux/init.h> | 11 | #include <linux/init.h> |
@@ -411,6 +412,7 @@ int __init op_nmi_init(struct oprofile_operations *ops) | |||
411 | __u8 vendor = boot_cpu_data.x86_vendor; | 412 | __u8 vendor = boot_cpu_data.x86_vendor; |
412 | __u8 family = boot_cpu_data.x86; | 413 | __u8 family = boot_cpu_data.x86; |
413 | char *cpu_type; | 414 | char *cpu_type; |
415 | int ret = 0; | ||
414 | 416 | ||
415 | if (!cpu_has_apic) | 417 | if (!cpu_has_apic) |
416 | return -ENODEV; | 418 | return -ENODEV; |
@@ -466,6 +468,11 @@ int __init op_nmi_init(struct oprofile_operations *ops) | |||
466 | return -ENODEV; | 468 | return -ENODEV; |
467 | } | 469 | } |
468 | 470 | ||
471 | if (model->init) | ||
472 | ret = model->init(ops); | ||
473 | if (ret) | ||
474 | return ret; | ||
475 | |||
469 | init_sysfs(); | 476 | init_sysfs(); |
470 | using_nmi = 1; | 477 | using_nmi = 1; |
471 | ops->create_files = nmi_create_files; | 478 | ops->create_files = nmi_create_files; |
@@ -482,4 +489,6 @@ void op_nmi_exit(void) | |||
482 | { | 489 | { |
483 | if (using_nmi) | 490 | if (using_nmi) |
484 | exit_sysfs(); | 491 | exit_sysfs(); |
492 | if (model->exit) | ||
493 | model->exit(); | ||
485 | } | 494 | } |
diff --git a/arch/x86/oprofile/op_model_athlon.c b/arch/x86/oprofile/op_model_athlon.c index 3d534879a9dc..dd8b1dcd163b 100644 --- a/arch/x86/oprofile/op_model_athlon.c +++ b/arch/x86/oprofile/op_model_athlon.c | |||
@@ -1,14 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | * @file op_model_athlon.h | 2 | * @file op_model_athlon.c |
3 | * athlon / K7 / K8 / Family 10h model-specific MSR operations | 3 | * athlon / K7 / K8 / Family 10h model-specific MSR operations |
4 | * | 4 | * |
5 | * @remark Copyright 2002 OProfile authors | 5 | * @remark Copyright 2002-2008 OProfile authors |
6 | * @remark Read the file COPYING | 6 | * @remark Read the file COPYING |
7 | * | 7 | * |
8 | * @author John Levon | 8 | * @author John Levon |
9 | * @author Philippe Elie | 9 | * @author Philippe Elie |
10 | * @author Graydon Hoare | 10 | * @author Graydon Hoare |
11 | */ | 11 | * @author Robert Richter <robert.richter@amd.com> |
12 | */ | ||
12 | 13 | ||
13 | #include <linux/oprofile.h> | 14 | #include <linux/oprofile.h> |
14 | #include <asm/ptrace.h> | 15 | #include <asm/ptrace.h> |
@@ -178,7 +179,18 @@ static void athlon_shutdown(struct op_msrs const * const msrs) | |||
178 | } | 179 | } |
179 | } | 180 | } |
180 | 181 | ||
182 | static int op_amd_init(struct oprofile_operations *ops) | ||
183 | { | ||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | static void op_amd_exit(void) | ||
188 | { | ||
189 | } | ||
190 | |||
181 | struct op_x86_model_spec const op_athlon_spec = { | 191 | struct op_x86_model_spec const op_athlon_spec = { |
192 | .init = op_amd_init, | ||
193 | .exit = op_amd_exit, | ||
182 | .num_counters = NUM_COUNTERS, | 194 | .num_counters = NUM_COUNTERS, |
183 | .num_controls = NUM_CONTROLS, | 195 | .num_controls = NUM_CONTROLS, |
184 | .fill_in_addresses = &athlon_fill_in_addresses, | 196 | .fill_in_addresses = &athlon_fill_in_addresses, |
diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h index 45b605fa71d0..ee9ca96253f4 100644 --- a/arch/x86/oprofile/op_x86_model.h +++ b/arch/x86/oprofile/op_x86_model.h | |||
@@ -32,6 +32,8 @@ struct pt_regs; | |||
32 | * various x86 CPU models' perfctr support. | 32 | * various x86 CPU models' perfctr support. |
33 | */ | 33 | */ |
34 | struct op_x86_model_spec { | 34 | struct op_x86_model_spec { |
35 | int (*init)(struct oprofile_operations *ops); | ||
36 | void (*exit)(void); | ||
35 | unsigned int const num_counters; | 37 | unsigned int const num_counters; |
36 | unsigned int const num_controls; | 38 | unsigned int const num_controls; |
37 | void (*fill_in_addresses)(struct op_msrs * const msrs); | 39 | void (*fill_in_addresses)(struct op_msrs * const msrs); |