]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/oprofile: introduce model specific init/exit functions
authorRobert Richter <robert.richter@amd.com>
Tue, 22 Jul 2008 19:08:48 +0000 (21:08 +0200)
committerIngo Molnar <mingo@elte.hu>
Sat, 26 Jul 2008 09:48:01 +0000 (11:48 +0200)
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>
arch/x86/oprofile/nmi_int.c
arch/x86/oprofile/op_model_athlon.c
arch/x86/oprofile/op_x86_model.h

index 33db99ab90c043bd5a1076dedc83726674c574d6..75e889156f23b36567375209cb1a8470286b2ca8 100644 (file)
@@ -1,10 +1,11 @@
 /**
  * @file nmi_int.c
  *
- * @remark Copyright 2002 OProfile authors
+ * @remark Copyright 2002-2008 OProfile authors
  * @remark Read the file COPYING
  *
  * @author John Levon <levon@movementarian.org>
+ * @author Robert Richter <robert.richter@amd.com>
  */
 
 #include <linux/init.h>
@@ -411,6 +412,7 @@ int __init op_nmi_init(struct oprofile_operations *ops)
        __u8 vendor = boot_cpu_data.x86_vendor;
        __u8 family = boot_cpu_data.x86;
        char *cpu_type;
+       int ret = 0;
 
        if (!cpu_has_apic)
                return -ENODEV;
@@ -466,6 +468,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
                return -ENODEV;
        }
 
+       if (model->init)
+               ret = model->init(ops);
+       if (ret)
+               return ret;
+
        init_sysfs();
        using_nmi = 1;
        ops->create_files = nmi_create_files;
@@ -482,4 +489,6 @@ void op_nmi_exit(void)
 {
        if (using_nmi)
                exit_sysfs();
+       if (model->exit)
+               model->exit();
 }
index 3d534879a9dcd82a2d43080d1224a45406e6ad60..dd8b1dcd163b863605b91821db79504d777d0c03 100644 (file)
@@ -1,14 +1,15 @@
 /*
- * @file op_model_athlon.h
+ * @file op_model_athlon.c
  * athlon / K7 / K8 / Family 10h model-specific MSR operations
  *
- * @remark Copyright 2002 OProfile authors
+ * @remark Copyright 2002-2008 OProfile authors
  * @remark Read the file COPYING
  *
  * @author John Levon
  * @author Philippe Elie
  * @author Graydon Hoare
- */
+ * @author Robert Richter <robert.richter@amd.com>
+*/
 
 #include <linux/oprofile.h>
 #include <asm/ptrace.h>
@@ -178,7 +179,18 @@ static void athlon_shutdown(struct op_msrs const * const msrs)
        }
 }
 
+static int op_amd_init(struct oprofile_operations *ops)
+{
+       return 0;
+}
+
+static void op_amd_exit(void)
+{
+}
+
 struct op_x86_model_spec const op_athlon_spec = {
+       .init = op_amd_init,
+       .exit = op_amd_exit,
        .num_counters = NUM_COUNTERS,
        .num_controls = NUM_CONTROLS,
        .fill_in_addresses = &athlon_fill_in_addresses,
index 45b605fa71d06f6064b7fb6f3d34a017106b3cb9..ee9ca96253f4d8132b6574e4b5b391fff5928b5d 100644 (file)
@@ -32,6 +32,8 @@ struct pt_regs;
  * various x86 CPU models' perfctr support.
  */
 struct op_x86_model_spec {
+       int (*init)(struct oprofile_operations *ops);
+       void (*exit)(void);
        unsigned int const num_counters;
        unsigned int const num_controls;
        void (*fill_in_addresses)(struct op_msrs * const msrs);