aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/xen/xenoprof.h
blob: 7804e69329c2e017a43689c2be381c43bcc475b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/******************************************************************************
 * xenoprof.h
 * 
 * Xenoprof: Xenoprof enables performance profiling in Xen
 * 
 * Copyright (C) 2005 Hewlett-Packard Co.
 * written by Aravind Menon & Jose Renato Santos
 */

#ifndef __XEN_XENOPROF_H__
#define __XEN_XENOPROF_H__

#include <xen/inttypes.h>
#include <public/xenoprof.h>
#include <asm/xenoprof.h>

#define XENOPROF_DOMAIN_IGNORED    0
#define XENOPROF_DOMAIN_ACTIVE     1
#define XENOPROF_DOMAIN_PASSIVE    2

#define XENOPROF_IDLE              0
#define XENOPROF_INITIALIZED       1
#define XENOPROF_COUNTERS_RESERVED 2
#define XENOPROF_READY             3
#define XENOPROF_PROFILING         4

#ifndef CONFIG_COMPAT
typedef struct xenoprof_buf xenoprof_buf_t;
#else
#include <compat/xenoprof.h>
typedef union {
	struct xenoprof_buf native;
	struct compat_oprof_buf compat;
} xenoprof_buf_t;
#endif

struct xenoprof_vcpu {
    int event_size;
    xenoprof_buf_t *buffer;
};

struct xenoprof {
    char *rawbuf;
    int npages;
    int nbuf;
    int bufsize;
    int domain_type;
    int domain_ready;
    int is_primary;
#ifdef CONFIG_COMPAT
    int is_compat;
#endif
    struct xenoprof_vcpu *vcpu;
};

#ifndef CONFIG_COMPAT
#define XENOPROF_COMPAT(x) 0
#define xenoprof_buf(d, b, field) ((b)->field)
#else
#define XENOPROF_COMPAT(x) ((x)->is_compat)
#define xenoprof_buf(d, b, field) (*(!(d)->xenoprof->is_compat ? \
                                       &(b)->native.field : \
                                       &(b)->compat.field))
#endif

struct domain;
int is_active(struct domain *d);
int is_passive(struct domain *d);
void free_xenoprof_pages(struct domain *d);

int xenoprof_add_trace(struct vcpu *, uint64_t pc, int mode);

#define PMU_OWNER_NONE          0
#define PMU_OWNER_XENOPROF      1
#define PMU_OWNER_HVM           2
int acquire_pmu_ownship(int pmu_ownership);
void release_pmu_ownship(int pmu_ownership);

void xenoprof_log_event(struct vcpu *, const struct cpu_user_regs *,
                        uint64_t pc, int mode, int event);

#endif  /* __XEN__XENOPROF_H__ */