apply zhaolei updates
[lttv.git] / trunk / lttv / doc / developer / xen-port.txt
1
2
3 Xen port notes
4
5 Mathieu Desnoyers, April 2006
6
7 Useful files :
8
9 common/trace.c
10 include/xen/trace.h and the dom0 op in include/public/dom0_ops.h
11
12 alloc buffer (alloc_trace_bufs) :
13 alloc_xenheap_pages
14
15 Shared buffer between dom0 and hypervisor :
16 share_xen_page_with_privileged_guests
17
18
19
20 trace_create / trace_destroy :
21
22 call xen hooks from dom0 to allocate a new buffer, get the newly allocated
23 struct trace pointer.
24 Share struct traces with dom0 to have offset and consumed counts.
25 Share the buffers with dom0 too.
26
27 Create a new "xen" channel.
28
29
30 Create 4 new xen facilities (see include/public/trace.h) :
31 xen_sched (grep TRC_SCHED)
32 sched_dom_add
33 sched_dom_rem
34 sched_sleep
35 sched_wake
36 sched_yield
37 sched_block
38 sched_shutdown
39 sched_ctl
40 sched_switch
41 sched_s_timer_fn
42 sched_t_timer_fn
43 sched_dom_timer_fn
44 sched_dom_timer_fn
45 sched_switch_infprev
46 sched_switch_infnext
47 xen_dom0op (grep TRC_DOM0OP)
48 dom0op_enter_base
49 dom0op_leave_base
50 xen_vmx (grep TRC_VMX)
51 vmx_vmexit
52 vmx_vmentry
53 vmx_timer_intr
54 vmx_int
55 vmx_io
56 xen_mem (grep TRC_MEM)
57 mem_page_grant_map
58 mem_page_grant_unmap
59 mem_page_grant_transfer
60
61
62 How to share xen pages efficiently ?
63 Pages allocated in xen heap, the shared with dom0.
64
65 How buffers are accessed in dom0 ?
66 directly from pointers to buffers contained in get_info control information.
67
68 do_dom0_op
69
70 tbufcontrol -> control info
71 int tb_control(dom0_tbufcontrol_t *tbc)
72
73 DOM0_TBUF_GET_INFO buffer_mfn __pa(t_bufs[0]) >> PAGE_SHIFT;
74
75
76 create trace :
77
78 in :
79 trace name
80 buffer size
81 return : 0 success, 1 failure
82 do :
83 alloc buffer xen
84 share with dom0
85
86 destroy trace :
87 in :
88 trace name
89 do : unshare buffer / free.
90
91
92 start/stop :
93 tb_control that will update the control structure.
94 in : trace name
95 start : put active to 1 + inc. nb_active traces
96 stop : put active to 0 + dec nb_active traces.
97 return : 0 success, 1 failure.
98
99 consume :
100 in : trace name
101 tb_control that will update the consumed count.
102 in : old count.
103 return : 0 success, 1 failure (pushed).
104
105 get_info :
106 tb_control that returns a fresh copy of trace control info.
107
108
109
110 NOTE 8-11-2006
111
112 Xen 3.0.3
113 Only one init of buffers (cannot change buffer size)
114 tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(per_cpu(t_bufs, 0)) : 0;
115 /* Convert between Xen-heap virtual addresses and machine frame numbers. */
116 #define virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT)
117
118 struct t_buf *tbufs_mapped;
119
120 tbufs_mapped = xc_map_foreign_range(xc_handle, DOMID_XEN,
121 size * num, PROT_READ | PROT_WRITE,
122 tbufs_mfn);
123
124 int fd = open("/proc/xen/privcmd", O_RDWR);
125
126 /* sleep for this long (milliseconds) between checking the trace buffers */
127 #define POLL_SLEEP_MILLIS 100
128
129
130 netfront.c
131 xenbus_alloc_evtchn
132 bind_evtchn_to_irqhandler
133
134
135 virq :
136
137 include/public/xen.h VIRQ_TBUF
138 /* G. (DOM0) Trace buffer has records available. */
139
140 trace_notify_guest : send_guest_global_virq(dom0, VIRQ_TBUF);
141
142 see arch/i386/oprofile/xenoprof.c
143 bind_virq
144
145
146
This page took 0.047812 seconds and 4 git commands to generate.