4 Device Mapper supports the collection of I/O statistics on user-defined
5 regions of a DM device. If no regions are defined no statistics are
6 collected so there isn't any performance impact. Only bio-based DM
7 devices are currently supported.
9 Each user-defined region specifies a starting sector, length and step.
10 Individual statistics will be collected for each step-sized area within
13 The I/O statistics counters for each step-sized area of a region are
14 in the same format as /sys/block/*/stat or /proc/diskstats (see:
15 Documentation/iostats.txt). But two extra counters (12 and 13) are
16 provided: total time spent reading and writing. All these counters may
17 be accessed by sending the @stats_print message to the appropriate DM
20 The reported times are in milliseconds and the granularity depends on
21 the kernel ticks. When the option precise_timestamps is used, the
22 reported times are in nanoseconds.
24 Each region has a corresponding unique identifier, which we call a
25 region_id, that is assigned when the region is created. The region_id
26 must be supplied when querying statistics about the region, deleting the
27 region, etc. Unique region_ids enable multiple userspace programs to
28 request and process statistics for the same DM device without stepping
31 The creation of DM statistics will allocate memory via kmalloc or
32 fallback to using vmalloc space. At most, 1/4 of the overall system
33 memory may be allocated by DM statistics. The admin can see how much
34 memory is used by reading
35 /sys/module/dm_mod/parameters/stats_current_allocated_bytes
40 @stats_create <range> <step>
41 [<number_of_optional_arguments> <optional_arguments>...]
42 [<program_id> [<aux_data>]]
44 Create a new region and return the region_id.
48 "<start_sector>+<length>" - a range of <length> 512-byte sectors
49 starting with <start_sector>.
52 "<area_size>" - the range is subdivided into areas each containing
54 "/<number_of_areas>" - the range is subdivided into the specified
57 <number_of_optional_arguments>
58 The number of optional arguments
61 The following optional arguments are supported
62 precise_timestamps - use precise timer with nanosecond resolution
63 instead of the "jiffies" variable. When this argument is
64 used, the resulting times are in nanoseconds instead of
65 milliseconds. Precise timestamps are a little bit slower
66 to obtain than jiffies-based timestamps.
69 An optional parameter. A name that uniquely identifies
70 the userspace owner of the range. This groups ranges together
71 so that userspace programs can identify the ranges they
72 created and ignore those created by others.
73 The kernel returns this string back in the output of
74 @stats_list message, but it doesn't use it for anything else.
75 If we omit the number of optional arguments, program id must not
76 be a number, otherwise it would be interpreted as the number of
80 An optional parameter. A word that provides auxiliary data
81 that is useful to the client program that created the range.
82 The kernel returns this string back in the output of
83 @stats_list message, but it doesn't use this value for anything.
85 @stats_delete <region_id>
87 Delete the region with the specified id.
90 region_id returned from @stats_create
92 @stats_clear <region_id>
94 Clear all the counters except the in-flight i/o counters.
97 region_id returned from @stats_create
99 @stats_list [<program_id>]
101 List all regions registered with @stats_create.
104 An optional parameter.
105 If this parameter is specified, only matching regions
107 If it is not specified, all regions are returned.
110 <region_id>: <start_sector>+<length> <step> <program_id> <aux_data>
112 @stats_print <region_id> [<starting_line> <number_of_lines>]
114 Print counters for each step-sized area of a region.
117 region_id returned from @stats_create
120 The index of the starting line in the output.
121 If omitted, all lines are returned.
124 The number of lines to include in the output.
125 If omitted, all lines are returned.
127 Output format for each step-sized area of a region:
129 <start_sector>+<length> counters
131 The first 11 counters have the same meaning as
132 /sys/block/*/stat or /proc/diskstats.
134 Please refer to Documentation/iostats.txt for details.
136 1. the number of reads completed
137 2. the number of reads merged
138 3. the number of sectors read
139 4. the number of milliseconds spent reading
140 5. the number of writes completed
141 6. the number of writes merged
142 7. the number of sectors written
143 8. the number of milliseconds spent writing
144 9. the number of I/Os currently in progress
145 10. the number of milliseconds spent doing I/Os
146 11. the weighted number of milliseconds spent doing I/Os
149 12. the total time spent reading in milliseconds
150 13. the total time spent writing in milliseconds
152 @stats_print_clear <region_id> [<starting_line> <number_of_lines>]
154 Atomically print and then clear all the counters except the
155 in-flight i/o counters. Useful when the client consuming the
156 statistics does not want to lose any statistics (those updated
157 between printing and clearing).
160 region_id returned from @stats_create
163 The index of the starting line in the output.
164 If omitted, all lines are printed and then cleared.
167 The number of lines to process.
168 If omitted, all lines are printed and then cleared.
170 @stats_set_aux <region_id> <aux_data>
172 Store auxiliary data aux_data for the specified region.
175 region_id returned from @stats_create
178 The string that identifies data which is useful to the client
179 program that created the range. The kernel returns this
180 string back in the output of @stats_list message, but it
181 doesn't use this value for anything.
186 Subdivide the DM device 'vol' into 100 pieces and start collecting
189 dmsetup message vol 0 @stats_create - /100
191 Set the auxillary data string to "foo bar baz" (the escape for each
192 space must also be escaped, otherwise the shell will consume them):
194 dmsetup message vol 0 @stats_set_aux 0 foo\\ bar\\ baz
198 dmsetup message vol 0 @stats_list
200 Print the statistics:
202 dmsetup message vol 0 @stats_print 0
204 Delete the statistics:
206 dmsetup message vol 0 @stats_delete 0