ia64/linux-2.6.18-xen.hg

view Documentation/usb/usbmon.txt @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
children
line source
1 * Introduction
3 The name "usbmon" in lowercase refers to a facility in kernel which is
4 used to collect traces of I/O on the USB bus. This function is analogous
5 to a packet socket used by network monitoring tools such as tcpdump(1)
6 or Ethereal. Similarly, it is expected that a tool such as usbdump or
7 USBMon (with uppercase letters) is used to examine raw traces produced
8 by usbmon.
10 The usbmon reports requests made by peripheral-specific drivers to Host
11 Controller Drivers (HCD). So, if HCD is buggy, the traces reported by
12 usbmon may not correspond to bus transactions precisely. This is the same
13 situation as with tcpdump.
15 * How to use usbmon to collect raw text traces
17 Unlike the packet socket, usbmon has an interface which provides traces
18 in a text format. This is used for two purposes. First, it serves as a
19 common trace exchange format for tools while most sophisticated formats
20 are finalized. Second, humans can read it in case tools are not available.
22 To collect a raw text trace, execute following steps.
24 1. Prepare
26 Mount debugfs (it has to be enabled in your kernel configuration), and
27 load the usbmon module (if built as module). The second step is skipped
28 if usbmon is built into the kernel.
30 # mount -t debugfs none_debugs /sys/kernel/debug
31 # modprobe usbmon
32 #
34 Verify that bus sockets are present.
36 # ls /sys/kernel/debug/usbmon
37 1s 1t 2s 2t 3s 3t 4s 4t
38 #
40 2. Find which bus connects to the desired device
42 Run "cat /proc/bus/usb/devices", and find the T-line which corresponds to
43 the device. Usually you do it by looking for the vendor string. If you have
44 many similar devices, unplug one and compare two /proc/bus/usb/devices outputs.
45 The T-line will have a bus number. Example:
47 T: Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
48 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
49 P: Vendor=0557 ProdID=2004 Rev= 1.00
50 S: Manufacturer=ATEN
51 S: Product=UC100KM V2.00
53 Bus=03 means it's bus 3.
55 3. Start 'cat'
57 # cat /sys/kernel/debug/usbmon/3t > /tmp/1.mon.out
59 This process will be reading until killed. Naturally, the output can be
60 redirected to a desirable location. This is preferred, because it is going
61 to be quite long.
63 4. Perform the desired operation on the USB bus
65 This is where you do something that creates the traffic: plug in a flash key,
66 copy files, control a webcam, etc.
68 5. Kill cat
70 Usually it's done with a keyboard interrupt (Control-C).
72 At this point the output file (/tmp/1.mon.out in this example) can be saved,
73 sent by e-mail, or inspected with a text editor. In the last case make sure
74 that the file size is not excessive for your favourite editor.
76 * Raw text data format
78 The '1t' type data consists of a stream of events, such as URB submission,
79 URB callback, submission error. Every event is a text line, which consists
80 of whitespace separated words. The number of position of words may depend
81 on the event type, but there is a set of words, common for all types.
83 Here is the list of words, from left to right:
84 - URB Tag. This is used to identify URBs is normally a kernel mode address
85 of the URB structure in hexadecimal.
86 - Timestamp in microseconds, a decimal number. The timestamp's resolution
87 depends on available clock, and so it can be much worse than a microsecond
88 (if the implementation uses jiffies, for example).
89 - Event Type. This type refers to the format of the event, not URB type.
90 Available types are: S - submission, C - callback, E - submission error.
91 - "Pipe". The pipe concept is deprecated. This is a composite word, used to
92 be derived from information in pipes. It consists of three fields, separated
93 by colons: URB type and direction, Device address, Endpoint number.
94 Type and direction are encoded with two bytes in the following manner:
95 Ci Co Control input and output
96 Zi Zo Isochronous input and output
97 Ii Io Interrupt input and output
98 Bi Bo Bulk input and output
99 Device address and Endpoint number are 3-digit and 2-digit (respectively)
100 decimal numbers, with leading zeroes.
101 - URB Status. In most cases, this field contains a number, sometimes negative,
102 which represents a "status" field of the URB. This field makes no sense for
103 submissions, but is present anyway to help scripts with parsing. When an
104 error occurs, the field contains the error code. In case of a submission of
105 a Control packet, this field contains a Setup Tag instead of an error code.
106 It is easy to tell whether the Setup Tag is present because it is never a
107 number. Thus if scripts find a number in this field, they proceed to read
108 Data Length. If they find something else, like a letter, they read the setup
109 packet before reading the Data Length.
110 - Setup packet, if present, consists of 5 words: one of each for bmRequestType,
111 bRequest, wValue, wIndex, wLength, as specified by the USB Specification 2.0.
112 These words are safe to decode if Setup Tag was 's'. Otherwise, the setup
113 packet was present, but not captured, and the fields contain filler.
114 - Data Length. For submissions, this is the requested length. For callbacks,
115 this is the actual length.
116 - Data tag. The usbmon may not always capture data, even if length is nonzero.
117 The data words are present only if this tag is '='.
118 - Data words follow, in big endian hexadecimal format. Notice that they are
119 not machine words, but really just a byte stream split into words to make
120 it easier to read. Thus, the last word may contain from one to four bytes.
121 The length of collected data is limited and can be less than the data length
122 report in Data Length word.
124 Here is an example of code to read the data stream in a well known programming
125 language:
127 class ParsedLine {
128 int data_len; /* Available length of data */
129 byte data[];
131 void parseData(StringTokenizer st) {
132 int availwords = st.countTokens();
133 data = new byte[availwords * 4];
134 data_len = 0;
135 while (st.hasMoreTokens()) {
136 String data_str = st.nextToken();
137 int len = data_str.length() / 2;
138 int i;
139 int b; // byte is signed, apparently?! XXX
140 for (i = 0; i < len; i++) {
141 // data[data_len] = Byte.parseByte(
142 // data_str.substring(i*2, i*2 + 2),
143 // 16);
144 b = Integer.parseInt(
145 data_str.substring(i*2, i*2 + 2),
146 16);
147 if (b >= 128)
148 b *= -1;
149 data[data_len] = (byte) b;
150 data_len++;
151 }
152 }
153 }
154 }
156 This format may be changed in the future.
158 Examples:
160 An input control transfer to get a port status.
162 d5ea89a0 3575914555 S Ci:001:00 s a3 00 0000 0003 0004 4 <
163 d5ea89a0 3575914560 C Ci:001:00 0 4 = 01050000
165 An output bulk transfer to send a SCSI command 0x5E in a 31-byte Bulk wrapper
166 to a storage device at address 5:
168 dd65f0e8 4128379752 S Bo:005:02 -115 31 = 55534243 5e000000 00000000 00000600 00000000 00000000 00000000 000000
169 dd65f0e8 4128379808 C Bo:005:02 0 31 >
171 * Raw binary format and API
173 TBD