blob: ff82a755edd4ad206b3153374371d84a1d77f43a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
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 Richter3370d352009-05-25 15:10:32 +02009 * @author Robert Richter <robert.richter@amd.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
12#ifndef OP_X86_MODEL_H
13#define OP_X86_MODEL_H
14
Robert Richter3370d352009-05-25 15:10:32 +020015#include <asm/types.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020016#include <asm/perf_event.h>
Robert Richterec064c02009-05-25 15:05:50 +020017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018struct op_msr {
Robert Richter95e74e62009-06-03 19:09:27 +020019 unsigned long addr;
20 u64 saved;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021};
22
23struct op_msrs {
Robert Richter25ad29132008-09-05 17:12:36 +020024 struct op_msr *counters;
25 struct op_msr *controls;
Jason Yeh4d4036e2009-07-08 13:49:38 +020026 struct op_msr *multiplex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027};
28
29struct pt_regs;
30
Robert Richter3370d352009-05-25 15:10:32 +020031struct oprofile_operations;
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033/* The model vtable abstracts the differences between
Simon Arlott27b46d72007-10-20 01:13:56 +020034 * various x86 CPU models' perfctr support.
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 */
36struct op_x86_model_spec {
Robert Richter06552cc2009-05-28 02:12:36 +020037 unsigned int num_counters;
38 unsigned int num_controls;
Jason Yeh4d4036e2009-07-08 13:49:38 +020039 unsigned int num_virt_counters;
Robert Richter3370d352009-05-25 15:10:32 +020040 u64 reserved;
41 u16 event_mask;
Robert Richter06552cc2009-05-28 02:12:36 +020042 int (*init)(struct oprofile_operations *ops);
43 void (*exit)(void);
44 void (*fill_in_addresses)(struct op_msrs * const msrs);
Robert Richteref8828d2009-05-25 19:31:44 +020045 void (*setup_ctrs)(struct op_x86_model_spec const *model,
46 struct op_msrs const * const msrs);
Robert Richter06552cc2009-05-28 02:12:36 +020047 int (*check_ctrs)(struct pt_regs * const regs,
48 struct op_msrs const * const msrs);
49 void (*start)(struct op_msrs const * const msrs);
50 void (*stop)(struct op_msrs const * const msrs);
51 void (*shutdown)(struct op_msrs const * const msrs);
Jason Yeh4d4036e2009-07-08 13:49:38 +020052#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
53 void (*switch_ctrl)(struct op_x86_model_spec const *model,
54 struct op_msrs const * const msrs);
55#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070056};
57
Robert Richter3370d352009-05-25 15:10:32 +020058struct op_counter_config;
59
Robert Richter98a2e732010-02-23 18:14:58 +010060static inline void op_x86_warn_in_use(int counter)
61{
Naga Chumbalkar8588d102010-02-23 18:14:58 +010062 /*
63 * The warning indicates an already running counter. If
64 * oprofile doesn't collect data, then try using a different
65 * performance counter on your platform to monitor the desired
66 * event. Delete counter #%d from the desired event by editing
67 * the /usr/share/oprofile/%s/<cpu>/events file. If the event
68 * cannot be monitored by any other counter, contact your
69 * hardware or BIOS vendor.
70 */
Robert Richter98a2e732010-02-23 18:14:58 +010071 pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
72 counter, smp_processor_id());
73}
74
75static inline void op_x86_warn_reserved(int counter)
76{
77 pr_warning("oprofile: counter #%d is already reserved\n", counter);
78}
79
Robert Richter3370d352009-05-25 15:10:32 +020080extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
81 struct op_counter_config *counter_config);
Robert Richterd8471ad2009-07-16 13:04:43 +020082extern int op_x86_phys_to_virt(int phys);
Robert Richter61d149d2009-07-10 15:47:17 +020083extern int op_x86_virt_to_phys(int virt);
Robert Richter3370d352009-05-25 15:10:32 +020084
Robert Richter259a83a2009-07-09 15:12:35 +020085extern struct op_x86_model_spec op_ppro_spec;
86extern struct op_x86_model_spec op_p4_spec;
87extern struct op_x86_model_spec op_p4_ht2_spec;
88extern struct op_x86_model_spec op_amd_spec;
Andi Kleenb9917022008-08-18 14:50:31 +020089extern struct op_x86_model_spec op_arch_perfmon_spec;
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#endif /* OP_X86_MODEL_H */