blob: 71e8a67337e23bfa0675a0c86aa768dea588baf1 [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);
Robert Richter8617f982010-02-26 17:20:55 +010043 int (*fill_in_addresses)(struct op_msrs * const msrs);
Robert Richteref8828d2009-05-25 19:31:44 +020044 void (*setup_ctrs)(struct op_x86_model_spec const *model,
45 struct op_msrs const * const msrs);
Robert Richter06552cc2009-05-28 02:12:36 +020046 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 Yeh4d4036e2009-07-08 13:49:38 +020051#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 Torvalds1da177e2005-04-16 15:20:36 -070055};
56
Robert Richter3370d352009-05-25 15:10:32 +020057struct op_counter_config;
58
Robert Richter98a2e732010-02-23 18:14:58 +010059static inline void op_x86_warn_in_use(int counter)
60{
Naga Chumbalkar8588d102010-02-23 18:14:58 +010061 /*
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 Richter98a2e732010-02-23 18:14:58 +010070 pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
71 counter, smp_processor_id());
72}
73
74static inline void op_x86_warn_reserved(int counter)
75{
76 pr_warning("oprofile: counter #%d is already reserved\n", counter);
77}
78
Robert Richter3370d352009-05-25 15:10:32 +020079extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
80 struct op_counter_config *counter_config);
Robert Richterd8471ad2009-07-16 13:04:43 +020081extern int op_x86_phys_to_virt(int phys);
Robert Richter61d149d2009-07-10 15:47:17 +020082extern int op_x86_virt_to_phys(int virt);
Robert Richter3370d352009-05-25 15:10:32 +020083
Robert Richter259a83a2009-07-09 15:12:35 +020084extern struct op_x86_model_spec op_ppro_spec;
85extern struct op_x86_model_spec op_p4_spec;
86extern struct op_x86_model_spec op_p4_ht2_spec;
87extern struct op_x86_model_spec op_amd_spec;
Andi Kleenb9917022008-08-18 14:50:31 +020088extern struct op_x86_model_spec op_arch_perfmon_spec;
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#endif /* OP_X86_MODEL_H */