Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file op_x86_model.h |
| 3 | * interface to x86 model-specific MSR operations |
| 4 | * |
| 5 | * @remark Copyright 2002 OProfile authors |
| 6 | * @remark Read the file COPYING |
| 7 | * |
| 8 | * @author Graydon Hoare |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 9 | * @author Robert Richter <robert.richter@amd.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef OP_X86_MODEL_H |
| 13 | #define OP_X86_MODEL_H |
| 14 | |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 15 | #include <asm/types.h> |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 16 | #include <asm/perf_event.h> |
Robert Richter | ec064c0 | 2009-05-25 15:05:50 +0200 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | struct op_msr { |
Robert Richter | 95e74e6 | 2009-06-03 19:09:27 +0200 | [diff] [blame] | 19 | unsigned long addr; |
| 20 | u64 saved; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | struct op_msrs { |
Robert Richter | 25ad2913 | 2008-09-05 17:12:36 +0200 | [diff] [blame] | 24 | struct op_msr *counters; |
| 25 | struct op_msr *controls; |
Jason Yeh | 4d4036e | 2009-07-08 13:49:38 +0200 | [diff] [blame] | 26 | struct op_msr *multiplex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | struct pt_regs; |
| 30 | |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 31 | struct oprofile_operations; |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | /* The model vtable abstracts the differences between |
Simon Arlott | 27b46d7 | 2007-10-20 01:13:56 +0200 | [diff] [blame] | 34 | * various x86 CPU models' perfctr support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | */ |
| 36 | struct op_x86_model_spec { |
Robert Richter | 06552cc | 2009-05-28 02:12:36 +0200 | [diff] [blame] | 37 | unsigned int num_counters; |
| 38 | unsigned int num_controls; |
Jason Yeh | 4d4036e | 2009-07-08 13:49:38 +0200 | [diff] [blame] | 39 | unsigned int num_virt_counters; |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 40 | u64 reserved; |
| 41 | u16 event_mask; |
Robert Richter | 06552cc | 2009-05-28 02:12:36 +0200 | [diff] [blame] | 42 | int (*init)(struct oprofile_operations *ops); |
Robert Richter | 8617f98 | 2010-02-26 17:20:55 +0100 | [diff] [blame] | 43 | int (*fill_in_addresses)(struct op_msrs * const msrs); |
Robert Richter | ef8828d | 2009-05-25 19:31:44 +0200 | [diff] [blame] | 44 | void (*setup_ctrs)(struct op_x86_model_spec const *model, |
| 45 | struct op_msrs const * const msrs); |
Robert Richter | 06552cc | 2009-05-28 02:12:36 +0200 | [diff] [blame] | 46 | int (*check_ctrs)(struct pt_regs * const regs, |
| 47 | struct op_msrs const * const msrs); |
| 48 | void (*start)(struct op_msrs const * const msrs); |
| 49 | void (*stop)(struct op_msrs const * const msrs); |
| 50 | void (*shutdown)(struct op_msrs const * const msrs); |
Jason Yeh | 4d4036e | 2009-07-08 13:49:38 +0200 | [diff] [blame] | 51 | #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX |
| 52 | void (*switch_ctrl)(struct op_x86_model_spec const *model, |
| 53 | struct op_msrs const * const msrs); |
| 54 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 57 | struct op_counter_config; |
| 58 | |
Robert Richter | 98a2e73 | 2010-02-23 18:14:58 +0100 | [diff] [blame] | 59 | static inline void op_x86_warn_in_use(int counter) |
| 60 | { |
Naga Chumbalkar | 8588d10 | 2010-02-23 18:14:58 +0100 | [diff] [blame] | 61 | /* |
| 62 | * The warning indicates an already running counter. If |
| 63 | * oprofile doesn't collect data, then try using a different |
| 64 | * performance counter on your platform to monitor the desired |
| 65 | * event. Delete counter #%d from the desired event by editing |
| 66 | * the /usr/share/oprofile/%s/<cpu>/events file. If the event |
| 67 | * cannot be monitored by any other counter, contact your |
| 68 | * hardware or BIOS vendor. |
| 69 | */ |
Robert Richter | 98a2e73 | 2010-02-23 18:14:58 +0100 | [diff] [blame] | 70 | pr_warning("oprofile: counter #%d on cpu #%d may already be used\n", |
| 71 | counter, smp_processor_id()); |
| 72 | } |
| 73 | |
| 74 | static inline void op_x86_warn_reserved(int counter) |
| 75 | { |
| 76 | pr_warning("oprofile: counter #%d is already reserved\n", counter); |
| 77 | } |
| 78 | |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 79 | extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model, |
| 80 | struct op_counter_config *counter_config); |
Robert Richter | d8471ad | 2009-07-16 13:04:43 +0200 | [diff] [blame] | 81 | extern int op_x86_phys_to_virt(int phys); |
Robert Richter | 61d149d | 2009-07-10 15:47:17 +0200 | [diff] [blame] | 82 | extern int op_x86_virt_to_phys(int virt); |
Robert Richter | 3370d35 | 2009-05-25 15:10:32 +0200 | [diff] [blame] | 83 | |
Robert Richter | 259a83a | 2009-07-09 15:12:35 +0200 | [diff] [blame] | 84 | extern struct op_x86_model_spec op_ppro_spec; |
| 85 | extern struct op_x86_model_spec op_p4_spec; |
| 86 | extern struct op_x86_model_spec op_p4_ht2_spec; |
| 87 | extern struct op_x86_model_spec op_amd_spec; |
Andi Kleen | b991702 | 2008-08-18 14:50:31 +0200 | [diff] [blame] | 88 | extern struct op_x86_model_spec op_arch_perfmon_spec; |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #endif /* OP_X86_MODEL_H */ |