5 Mathieu Desnoyers, April 2006
10 include/xen/trace.h and the dom0 op in include/public/dom0_ops.h
12 alloc buffer (alloc_trace_bufs) :
15 Shared buffer between dom0 and hypervisor :
16 share_xen_page_with_privileged_guests
20 trace_create / trace_destroy :
22 call xen hooks from dom0 to allocate a new buffer, get the newly allocated
24 Share struct traces with dom0 to have offset and consumed counts.
25 Share the buffers with dom0 too.
27 Create a new "xen" channel.
30 Create 4 new xen facilities (see include/public/trace.h) :
31 xen_sched (grep TRC_SCHED)
47 xen_dom0op (grep TRC_DOM0OP)
50 xen_vmx (grep TRC_VMX)
56 xen_mem (grep TRC_MEM)
59 mem_page_grant_transfer
62 How to share xen pages efficiently ?
63 Pages allocated in xen heap, the shared with dom0.
65 How buffers are accessed in dom0 ?
66 directly from pointers to buffers contained in get_info control information.
70 tbufcontrol -> control info
71 int tb_control(dom0_tbufcontrol_t *tbc)
73 DOM0_TBUF_GET_INFO buffer_mfn __pa(t_bufs[0]) >> PAGE_SHIFT;
81 return : 0 success, 1 failure
89 do : unshare buffer / free.
93 tb_control that will update the control structure.
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.
101 tb_control that will update the consumed count.
103 return : 0 success, 1 failure (pushed).
106 tb_control that returns a fresh copy of trace control info.
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)
118 struct t_buf *tbufs_mapped;
120 tbufs_mapped = xc_map_foreign_range(xc_handle, DOMID_XEN,
121 size * num, PROT_READ | PROT_WRITE,
124 int fd = open("/proc/xen/privcmd", O_RDWR);
126 /* sleep for this long (milliseconds) between checking the trace buffers */
127 #define POLL_SLEEP_MILLIS 100
132 bind_evtchn_to_irqhandler
137 include/public/xen.h VIRQ_TBUF
138 /* G. (DOM0) Trace buffer has records available. */
140 trace_notify_guest : send_guest_global_virq(dom0, VIRQ_TBUF);
142 see arch/i386/oprofile/xenoprof.c