| 1 | |
| 2 | |
| 3 | LTTng for Xen |
| 4 | |
| 5 | Design document |
| 6 | |
| 7 | Mathieu Desnoyers, November 2006 |
| 8 | |
| 9 | Last modification : |
| 10 | |
| 11 | Only allow a single channel. Directory consumed by a lttd-xen client through |
| 12 | hypercalls. This design choice is made because there are no RCU lists and there |
| 13 | is no link between the number of CPUs seen by Xen and number of CPUs in the |
| 14 | dom0. |
| 15 | |
| 16 | Does better than Xentrace : |
| 17 | Variable size records |
| 18 | Easily extensible event description |
| 19 | // not planned : missing RCU list. Multiple active traces |
| 20 | Reader uses poll()-like mechanism instead of polling the buffers each 100ms. |
| 21 | |
| 22 | |
| 23 | * Dom0 lttd-xen process |
| 24 | |
| 25 | Does an hypercall to map the buffers (increment refcount) |
| 26 | Does an hypercall to poll for data, put to sleep by the OS. |
| 27 | Uses write from the mapped buffers to a file. |
| 28 | unmap buffer, decrement refcount. |
| 29 | |
| 30 | |
| 31 | * Xen |
| 32 | |
| 33 | tb_control (hypercalls seen from dom0 OS) |
| 34 | (hypercalls done by lttctl-xen) |
| 35 | - trace_create |
| 36 | Map a page for control information, return it for mapping by user space. (rw) |
| 37 | Map multiple pages for buffers. return them for mapping by user space. |
| 38 | (shared, read-only for consumer) |
| 39 | increment refcount |
| 40 | - trace_start |
| 41 | Activate tracing in control information. |
| 42 | - trace_stop |
| 43 | Stop tracing in control information. |
| 44 | - trace_destroy |
| 45 | wait for pending writers (is the hypervisor preemptible ? not full.) |
| 46 | Preemption : not full -> spinlock does not disable preemption : would deadlock |
| 47 | for the non irq_disable case. |
| 48 | volountary : poll call -> volountary. explicit __schedule call., do_yield(). |
| 49 | Quiescent state detection. |
| 50 | for_each_domain( d ) |
| 51 | for_each_vcpu( d, v ) |
| 52 | vcpu_sleep_sync(v); |
| 53 | decrement refcount : destroy the channels |
| 54 | |
| 55 | Events coming from xen : |
| 56 | - Buffer switch |
| 57 | through virq sent to dom0 |
| 58 | |
| 59 | |
| 60 | |
| 61 | * Dom0 Linux OS |
| 62 | |
| 63 | Receive virq upon buffer switch. |
| 64 | xen_wakeup_readers handler : wakes up the readers for the channel. |
| 65 | |
| 66 | Hypercalls are autonomous from LTTng linux kernel tracing. |
| 67 | |
| 68 | on lttngxentrace create, hypercall channel_create |
| 69 | on lttngxentrace start, hypercall channel_start |
| 70 | on lttngxentrace stop, hypercall channel_stop |
| 71 | on lttngxentrace destroy, hypercall channel_destroy |
| 72 | |
| 73 | |
| 74 | * Facilities |
| 75 | |
| 76 | Export a facilities per cpu channel too. |
| 77 | |
| 78 | |
| 79 | Q1 : In Xen preemptible ? Full ? Volountary ? Volountary X |
| 80 | Q2 : How to synchronize to wait for writers to finish writing ? X |
| 81 | |
| 82 | |
| 83 | Number of CPUs in dom0 != number of CPUs in Xen. |
| 84 | CPU hotplug in kernel tracing ? Done. |
| 85 | |
| 86 | |