xenoprof.h revision 181624
1/******************************************************************************
2 * xenoprof.h
3 *
4 * Interface for enabling system wide profiling based on hardware performance
5 * counters
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 *
25 * Copyright (C) 2005 Hewlett-Packard Co.
26 * Written by Aravind Menon & Jose Renato Santos
27 */
28
29#ifndef __XEN_PUBLIC_XENOPROF_H__
30#define __XEN_PUBLIC_XENOPROF_H__
31
32#include "xen.h"
33
34/*
35 * Commands to HYPERVISOR_xenoprof_op().
36 */
37#define XENOPROF_init                0
38#define XENOPROF_reset_active_list   1
39#define XENOPROF_reset_passive_list  2
40#define XENOPROF_set_active          3
41#define XENOPROF_set_passive         4
42#define XENOPROF_reserve_counters    5
43#define XENOPROF_counter             6
44#define XENOPROF_setup_events        7
45#define XENOPROF_enable_virq         8
46#define XENOPROF_start               9
47#define XENOPROF_stop               10
48#define XENOPROF_disable_virq       11
49#define XENOPROF_release_counters   12
50#define XENOPROF_shutdown           13
51#define XENOPROF_get_buffer         14
52#define XENOPROF_set_backtrace      15
53#define XENOPROF_last_op            15
54
55#define MAX_OPROF_EVENTS    32
56#define MAX_OPROF_DOMAINS   25
57#define XENOPROF_CPU_TYPE_SIZE 64
58
59/* Xenoprof performance events (not Xen events) */
60struct event_log {
61    uint64_t eip;
62    uint8_t mode;
63    uint8_t event;
64};
65
66/* PC value that indicates a special code */
67#define XENOPROF_ESCAPE_CODE ~0UL
68/* Transient events for the xenoprof->oprofile cpu buf */
69#define XENOPROF_TRACE_BEGIN 1
70
71/* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
72struct xenoprof_buf {
73    uint32_t event_head;
74    uint32_t event_tail;
75    uint32_t event_size;
76    uint32_t vcpu_id;
77    uint64_t xen_samples;
78    uint64_t kernel_samples;
79    uint64_t user_samples;
80    uint64_t lost_samples;
81    struct event_log event_log[1];
82};
83#ifndef __XEN__
84typedef struct xenoprof_buf xenoprof_buf_t;
85DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
86#endif
87
88struct xenoprof_init {
89    int32_t  num_events;
90    int32_t  is_primary;
91    char cpu_type[XENOPROF_CPU_TYPE_SIZE];
92};
93typedef struct xenoprof_init xenoprof_init_t;
94DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
95
96struct xenoprof_get_buffer {
97    int32_t  max_samples;
98    int32_t  nbuf;
99    int32_t  bufsize;
100    uint64_t buf_gmaddr;
101};
102typedef struct xenoprof_get_buffer xenoprof_get_buffer_t;
103DEFINE_XEN_GUEST_HANDLE(xenoprof_get_buffer_t);
104
105struct xenoprof_counter {
106    uint32_t ind;
107    uint64_t count;
108    uint32_t enabled;
109    uint32_t event;
110    uint32_t hypervisor;
111    uint32_t kernel;
112    uint32_t user;
113    uint64_t unit_mask;
114};
115typedef struct xenoprof_counter xenoprof_counter_t;
116DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
117
118typedef struct xenoprof_passive {
119    uint16_t domain_id;
120    int32_t  max_samples;
121    int32_t  nbuf;
122    int32_t  bufsize;
123    uint64_t buf_gmaddr;
124} xenoprof_passive_t;
125DEFINE_XEN_GUEST_HANDLE(xenoprof_passive_t);
126
127
128#endif /* __XEN_PUBLIC_XENOPROF_H__ */
129
130/*
131 * Local variables:
132 * mode: C
133 * c-set-style: "BSD"
134 * c-basic-offset: 4
135 * tab-width: 4
136 * indent-tabs-mode: nil
137 * End:
138 */
139