~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/asm-ia64/linux-xen/asm/perfmon.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2001-2003 Hewlett-Packard Co
 
3
 *               Stephane Eranian <eranian@hpl.hp.com>
 
4
 */
 
5
 
 
6
#ifndef _ASM_IA64_PERFMON_H
 
7
#define _ASM_IA64_PERFMON_H
 
8
 
 
9
#ifdef XEN
 
10
#include <asm/config.h>
 
11
#ifndef pt_regs
 
12
#define pt_regs cpu_user_regs
 
13
#endif
 
14
struct cpu_user_regs;
 
15
#endif
 
16
 
 
17
/*
 
18
 * perfmon comamnds supported on all CPU models
 
19
 */
 
20
#define PFM_WRITE_PMCS          0x01
 
21
#define PFM_WRITE_PMDS          0x02
 
22
#define PFM_READ_PMDS           0x03
 
23
#define PFM_STOP                0x04
 
24
#define PFM_START               0x05
 
25
#define PFM_ENABLE              0x06 /* obsolete */
 
26
#define PFM_DISABLE             0x07 /* obsolete */
 
27
#define PFM_CREATE_CONTEXT      0x08
 
28
#define PFM_DESTROY_CONTEXT     0x09 /* obsolete use close() */
 
29
#define PFM_RESTART             0x0a
 
30
#define PFM_PROTECT_CONTEXT     0x0b /* obsolete */
 
31
#define PFM_GET_FEATURES        0x0c
 
32
#define PFM_DEBUG               0x0d
 
33
#define PFM_UNPROTECT_CONTEXT   0x0e /* obsolete */
 
34
#define PFM_GET_PMC_RESET_VAL   0x0f
 
35
#define PFM_LOAD_CONTEXT        0x10
 
36
#define PFM_UNLOAD_CONTEXT      0x11
 
37
 
 
38
/*
 
39
 * PMU model specific commands (may not be supported on all PMU models)
 
40
 */
 
41
#define PFM_WRITE_IBRS          0x20
 
42
#define PFM_WRITE_DBRS          0x21
 
43
 
 
44
/*
 
45
 * context flags
 
46
 */
 
47
#define PFM_FL_NOTIFY_BLOCK      0x01   /* block task on user level notifications */
 
48
#define PFM_FL_SYSTEM_WIDE       0x02   /* create a system wide context */
 
49
#define PFM_FL_OVFL_NO_MSG       0x80   /* do not post overflow/end messages for notification */
 
50
 
 
51
/*
 
52
 * event set flags
 
53
 */
 
54
#define PFM_SETFL_EXCL_IDLE      0x01   /* exclude idle task (syswide only) XXX: DO NOT USE YET */
 
55
 
 
56
/*
 
57
 * PMC flags
 
58
 */
 
59
#define PFM_REGFL_OVFL_NOTIFY   0x1     /* send notification on overflow */
 
60
#define PFM_REGFL_RANDOM        0x2     /* randomize sampling interval   */
 
61
 
 
62
/*
 
63
 * PMD/PMC/IBR/DBR return flags (ignored on input)
 
64
 *
 
65
 * Those flags are used on output and must be checked in case EAGAIN is returned
 
66
 * by any of the calls using a pfarg_reg_t or pfarg_dbreg_t structure.
 
67
 */
 
68
#define PFM_REG_RETFL_NOTAVAIL  (1UL<<31) /* set if register is implemented but not available */
 
69
#define PFM_REG_RETFL_EINVAL    (1UL<<30) /* set if register entry is invalid */
 
70
#define PFM_REG_RETFL_MASK      (PFM_REG_RETFL_NOTAVAIL|PFM_REG_RETFL_EINVAL)
 
71
 
 
72
#define PFM_REG_HAS_ERROR(flag) (((flag) & PFM_REG_RETFL_MASK) != 0)
 
73
 
 
74
typedef unsigned char pfm_uuid_t[16];   /* custom sampling buffer identifier type */
 
75
 
 
76
/*
 
77
 * Request structure used to define a context
 
78
 */
 
79
typedef struct {
 
80
        pfm_uuid_t     ctx_smpl_buf_id;  /* which buffer format to use (if needed) */
 
81
        unsigned long  ctx_flags;        /* noblock/block */
 
82
        unsigned short ctx_nextra_sets;  /* number of extra event sets (you always get 1) */
 
83
        unsigned short ctx_reserved1;    /* for future use */
 
84
        int            ctx_fd;           /* return arg: unique identification for context */
 
85
        void           *ctx_smpl_vaddr;  /* return arg: virtual address of sampling buffer, is used */
 
86
        unsigned long  ctx_reserved2[11];/* for future use */
 
87
} pfarg_context_t;
 
88
 
 
89
/*
 
90
 * Request structure used to write/read a PMC or PMD
 
91
 */
 
92
typedef struct {
 
93
        unsigned int    reg_num;           /* which register */
 
94
        unsigned short  reg_set;           /* event set for this register */
 
95
        unsigned short  reg_reserved1;     /* for future use */
 
96
 
 
97
        unsigned long   reg_value;         /* initial pmc/pmd value */
 
98
        unsigned long   reg_flags;         /* input: pmc/pmd flags, return: reg error */
 
99
 
 
100
        unsigned long   reg_long_reset;    /* reset after buffer overflow notification */
 
101
        unsigned long   reg_short_reset;   /* reset after counter overflow */
 
102
 
 
103
        unsigned long   reg_reset_pmds[4]; /* which other counters to reset on overflow */
 
104
        unsigned long   reg_random_seed;   /* seed value when randomization is used */
 
105
        unsigned long   reg_random_mask;   /* bitmask used to limit random value */
 
106
        unsigned long   reg_last_reset_val;/* return: PMD last reset value */
 
107
 
 
108
        unsigned long   reg_smpl_pmds[4];  /* which pmds are accessed when PMC overflows */
 
109
        unsigned long   reg_smpl_eventid;  /* opaque sampling event identifier */
 
110
 
 
111
        unsigned long   reg_reserved2[3];   /* for future use */
 
112
} pfarg_reg_t;
 
113
 
 
114
typedef struct {
 
115
        unsigned int    dbreg_num;              /* which debug register */
 
116
        unsigned short  dbreg_set;              /* event set for this register */
 
117
        unsigned short  dbreg_reserved1;        /* for future use */
 
118
        unsigned long   dbreg_value;            /* value for debug register */
 
119
        unsigned long   dbreg_flags;            /* return: dbreg error */
 
120
        unsigned long   dbreg_reserved2[1];     /* for future use */
 
121
} pfarg_dbreg_t;
 
122
 
 
123
typedef struct {
 
124
        unsigned int    ft_version;     /* perfmon: major [16-31], minor [0-15] */
 
125
        unsigned int    ft_reserved;    /* reserved for future use */
 
126
        unsigned long   reserved[4];    /* for future use */
 
127
} pfarg_features_t;
 
128
 
 
129
typedef struct {
 
130
        pid_t           load_pid;          /* process to load the context into */
 
131
        unsigned short  load_set;          /* first event set to load */
 
132
        unsigned short  load_reserved1;    /* for future use */
 
133
        unsigned long   load_reserved2[3]; /* for future use */
 
134
} pfarg_load_t;
 
135
 
 
136
typedef struct {
 
137
        int             msg_type;               /* generic message header */
 
138
        int             msg_ctx_fd;             /* generic message header */
 
139
        unsigned long   msg_ovfl_pmds[4];       /* which PMDs overflowed */
 
140
        unsigned short  msg_active_set;         /* active set at the time of overflow */
 
141
        unsigned short  msg_reserved1;          /* for future use */
 
142
        unsigned int    msg_reserved2;          /* for future use */
 
143
        unsigned long   msg_tstamp;             /* for perf tuning/debug */
 
144
} pfm_ovfl_msg_t;
 
145
 
 
146
typedef struct {
 
147
        int             msg_type;               /* generic message header */
 
148
        int             msg_ctx_fd;             /* generic message header */
 
149
        unsigned long   msg_tstamp;             /* for perf tuning */
 
150
} pfm_end_msg_t;
 
151
 
 
152
typedef struct {
 
153
        int             msg_type;               /* type of the message */
 
154
        int             msg_ctx_fd;             /* unique identifier for the context */
 
155
        unsigned long   msg_tstamp;             /* for perf tuning */
 
156
} pfm_gen_msg_t;
 
157
 
 
158
#define PFM_MSG_OVFL    1       /* an overflow happened */
 
159
#define PFM_MSG_END     2       /* task to which context was attached ended */
 
160
 
 
161
typedef union {
 
162
        pfm_ovfl_msg_t  pfm_ovfl_msg;
 
163
        pfm_end_msg_t   pfm_end_msg;
 
164
        pfm_gen_msg_t   pfm_gen_msg;
 
165
} pfm_msg_t;
 
166
 
 
167
/*
 
168
 * Define the version numbers for both perfmon as a whole and the sampling buffer format.
 
169
 */
 
170
#define PFM_VERSION_MAJ          2U
 
171
#define PFM_VERSION_MIN          0U
 
172
#define PFM_VERSION              (((PFM_VERSION_MAJ&0xffff)<<16)|(PFM_VERSION_MIN & 0xffff))
 
173
#define PFM_VERSION_MAJOR(x)     (((x)>>16) & 0xffff)
 
174
#define PFM_VERSION_MINOR(x)     ((x) & 0xffff)
 
175
 
 
176
 
 
177
/*
 
178
 * miscellaneous architected definitions
 
179
 */
 
180
#define PMU_FIRST_COUNTER       4       /* first counting monitor (PMC/PMD) */
 
181
#define PMU_MAX_PMCS            256     /* maximum architected number of PMC registers */
 
182
#define PMU_MAX_PMDS            256     /* maximum architected number of PMD registers */
 
183
 
 
184
#ifdef __KERNEL__
 
185
 
 
186
extern long perfmonctl(int fd, int cmd, void *arg, int narg);
 
187
 
 
188
typedef struct {
 
189
        void (*handler)(int irq, void *arg, struct pt_regs *regs);
 
190
} pfm_intr_handler_desc_t;
 
191
 
 
192
extern void pfm_save_regs (struct task_struct *);
 
193
extern void pfm_load_regs (struct task_struct *);
 
194
 
 
195
extern void pfm_exit_thread(struct task_struct *);
 
196
extern int  pfm_use_debug_registers(struct task_struct *);
 
197
extern int  pfm_release_debug_registers(struct task_struct *);
 
198
extern void pfm_syst_wide_update_task(struct task_struct *, unsigned long info, int is_ctxswin);
 
199
extern void pfm_inherit(struct task_struct *task, struct pt_regs *regs);
 
200
extern void pfm_init_percpu(void);
 
201
extern void pfm_handle_work(void);
 
202
extern int  pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *h);
 
203
extern int  pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *h);
 
204
 
 
205
 
 
206
 
 
207
/*
 
208
 * Reset PMD register flags
 
209
 */
 
210
#define PFM_PMD_SHORT_RESET     0
 
211
#define PFM_PMD_LONG_RESET      1
 
212
 
 
213
typedef union {
 
214
        unsigned int val;
 
215
        struct {
 
216
                unsigned int notify_user:1;     /* notify user program of overflow */
 
217
                unsigned int reset_ovfl_pmds:1; /* reset overflowed PMDs */
 
218
                unsigned int block_task:1;      /* block monitored task on kernel exit */
 
219
                unsigned int mask_monitoring:1; /* mask monitors via PMCx.plm */
 
220
                unsigned int reserved:28;       /* for future use */
 
221
        } bits;
 
222
} pfm_ovfl_ctrl_t;
 
223
 
 
224
typedef struct {
 
225
        unsigned char   ovfl_pmd;                       /* index of overflowed PMD  */
 
226
        unsigned char   ovfl_notify;                    /* =1 if monitor requested overflow notification */
 
227
        unsigned short  active_set;                     /* event set active at the time of the overflow */
 
228
        pfm_ovfl_ctrl_t ovfl_ctrl;                      /* return: perfmon controls to set by handler */
 
229
 
 
230
        unsigned long   pmd_last_reset;                 /* last reset value of of the PMD */
 
231
        unsigned long   smpl_pmds[4];                   /* bitmask of other PMD of interest on overflow */
 
232
        unsigned long   smpl_pmds_values[PMU_MAX_PMDS]; /* values for the other PMDs of interest */
 
233
        unsigned long   pmd_value;                      /* current 64-bit value of the PMD */
 
234
        unsigned long   pmd_eventid;                    /* eventid associated with PMD */
 
235
} pfm_ovfl_arg_t;
 
236
 
 
237
 
 
238
typedef struct {
 
239
        char            *fmt_name;
 
240
        pfm_uuid_t      fmt_uuid;
 
241
        size_t          fmt_arg_size;
 
242
        unsigned long   fmt_flags;
 
243
 
 
244
        int             (*fmt_validate)(struct task_struct *task, unsigned int flags, int cpu, void *arg);
 
245
        int             (*fmt_getsize)(struct task_struct *task, unsigned int flags, int cpu, void *arg, unsigned long *size);
 
246
        int             (*fmt_init)(struct task_struct *task, void *buf, unsigned int flags, int cpu, void *arg);
 
247
        int             (*fmt_handler)(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct pt_regs *regs, unsigned long stamp);
 
248
        int             (*fmt_restart)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs);
 
249
        int             (*fmt_restart_active)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs);
 
250
        int             (*fmt_exit)(struct task_struct *task, void *buf, struct pt_regs *regs);
 
251
 
 
252
        struct list_head fmt_list;
 
253
} pfm_buffer_fmt_t;
 
254
 
 
255
extern int pfm_register_buffer_fmt(pfm_buffer_fmt_t *fmt);
 
256
extern int pfm_unregister_buffer_fmt(pfm_uuid_t uuid);
 
257
 
 
258
/*
 
259
 * perfmon interface exported to modules
 
260
 */
 
261
extern int pfm_mod_read_pmds(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs);
 
262
extern int pfm_mod_write_pmcs(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs);
 
263
extern int pfm_mod_write_ibrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs);
 
264
extern int pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs);
 
265
 
 
266
/*
 
267
 * describe the content of the local_cpu_date->pfm_syst_info field
 
268
 */
 
269
#define PFM_CPUINFO_SYST_WIDE   0x1     /* if set a system wide session exists */
 
270
#define PFM_CPUINFO_DCR_PP      0x2     /* if set the system wide session has started */
 
271
#define PFM_CPUINFO_EXCL_IDLE   0x4     /* the system wide session excludes the idle task */
 
272
 
 
273
/*
 
274
 * sysctl control structure. visible to sampling formats
 
275
 */
 
276
typedef struct {
 
277
        int     debug;          /* turn on/off debugging via syslog */
 
278
        int     debug_ovfl;     /* turn on/off debug printk in overflow handler */
 
279
        int     fastctxsw;      /* turn on/off fast (unsecure) ctxsw */
 
280
        int     expert_mode;    /* turn on/off value checking */
 
281
} pfm_sysctl_t;
 
282
extern pfm_sysctl_t pfm_sysctl;
 
283
 
 
284
 
 
285
#endif /* __KERNEL__ */
 
286
 
 
287
#endif /* _ASM_IA64_PERFMON_H */