statistics.txt 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. DM statistics
  2. =============
  3. Device Mapper supports the collection of I/O statistics on user-defined
  4. regions of a DM device. If no regions are defined no statistics are
  5. collected so there isn't any performance impact. Only bio-based DM
  6. devices are currently supported.
  7. Each user-defined region specifies a starting sector, length and step.
  8. Individual statistics will be collected for each step-sized area within
  9. the range specified.
  10. The I/O statistics counters for each step-sized area of a region are
  11. in the same format as /sys/block/*/stat or /proc/diskstats (see:
  12. Documentation/iostats.txt). But two extra counters (12 and 13) are
  13. provided: total time spent reading and writing. When the histogram
  14. argument is used, the 14th parameter is reported that represents the
  15. histogram of latencies. All these counters may be accessed by sending
  16. the @stats_print message to the appropriate DM device via dmsetup.
  17. The reported times are in milliseconds and the granularity depends on
  18. the kernel ticks. When the option precise_timestamps is used, the
  19. reported times are in nanoseconds.
  20. Each region has a corresponding unique identifier, which we call a
  21. region_id, that is assigned when the region is created. The region_id
  22. must be supplied when querying statistics about the region, deleting the
  23. region, etc. Unique region_ids enable multiple userspace programs to
  24. request and process statistics for the same DM device without stepping
  25. on each other's data.
  26. The creation of DM statistics will allocate memory via kmalloc or
  27. fallback to using vmalloc space. At most, 1/4 of the overall system
  28. memory may be allocated by DM statistics. The admin can see how much
  29. memory is used by reading
  30. /sys/module/dm_mod/parameters/stats_current_allocated_bytes
  31. Messages
  32. ========
  33. @stats_create <range> <step>
  34. [<number_of_optional_arguments> <optional_arguments>...]
  35. [<program_id> [<aux_data>]]
  36. Create a new region and return the region_id.
  37. <range>
  38. "-" - whole device
  39. "<start_sector>+<length>" - a range of <length> 512-byte sectors
  40. starting with <start_sector>.
  41. <step>
  42. "<area_size>" - the range is subdivided into areas each containing
  43. <area_size> sectors.
  44. "/<number_of_areas>" - the range is subdivided into the specified
  45. number of areas.
  46. <number_of_optional_arguments>
  47. The number of optional arguments
  48. <optional_arguments>
  49. The following optional arguments are supported
  50. precise_timestamps - use precise timer with nanosecond resolution
  51. instead of the "jiffies" variable. When this argument is
  52. used, the resulting times are in nanoseconds instead of
  53. milliseconds. Precise timestamps are a little bit slower
  54. to obtain than jiffies-based timestamps.
  55. histogram:n1,n2,n3,n4,... - collect histogram of latencies. The
  56. numbers n1, n2, etc are times that represent the boundaries
  57. of the histogram. If precise_timestamps is not used, the
  58. times are in milliseconds, otherwise they are in
  59. nanoseconds. For each range, the kernel will report the
  60. number of requests that completed within this range. For
  61. example, if we use "histogram:10,20,30", the kernel will
  62. report four numbers a:b:c:d. a is the number of requests
  63. that took 0-10 ms to complete, b is the number of requests
  64. that took 10-20 ms to complete, c is the number of requests
  65. that took 20-30 ms to complete and d is the number of
  66. requests that took more than 30 ms to complete.
  67. <program_id>
  68. An optional parameter. A name that uniquely identifies
  69. the userspace owner of the range. This groups ranges together
  70. so that userspace programs can identify the ranges they
  71. created and ignore those created by others.
  72. The kernel returns this string back in the output of
  73. @stats_list message, but it doesn't use it for anything else.
  74. If we omit the number of optional arguments, program id must not
  75. be a number, otherwise it would be interpreted as the number of
  76. optional arguments.
  77. <aux_data>
  78. An optional parameter. A word that provides auxiliary data
  79. that is useful to the client program that created the range.
  80. The kernel returns this string back in the output of
  81. @stats_list message, but it doesn't use this value for anything.
  82. @stats_delete <region_id>
  83. Delete the region with the specified id.
  84. <region_id>
  85. region_id returned from @stats_create
  86. @stats_clear <region_id>
  87. Clear all the counters except the in-flight i/o counters.
  88. <region_id>
  89. region_id returned from @stats_create
  90. @stats_list [<program_id>]
  91. List all regions registered with @stats_create.
  92. <program_id>
  93. An optional parameter.
  94. If this parameter is specified, only matching regions
  95. are returned.
  96. If it is not specified, all regions are returned.
  97. Output format:
  98. <region_id>: <start_sector>+<length> <step> <program_id> <aux_data>
  99. precise_timestamps histogram:n1,n2,n3,...
  100. The strings "precise_timestamps" and "histogram" are printed only
  101. if they were specified when creating the region.
  102. @stats_print <region_id> [<starting_line> <number_of_lines>]
  103. Print counters for each step-sized area of a region.
  104. <region_id>
  105. region_id returned from @stats_create
  106. <starting_line>
  107. The index of the starting line in the output.
  108. If omitted, all lines are returned.
  109. <number_of_lines>
  110. The number of lines to include in the output.
  111. If omitted, all lines are returned.
  112. Output format for each step-sized area of a region:
  113. <start_sector>+<length> counters
  114. The first 11 counters have the same meaning as
  115. /sys/block/*/stat or /proc/diskstats.
  116. Please refer to Documentation/iostats.txt for details.
  117. 1. the number of reads completed
  118. 2. the number of reads merged
  119. 3. the number of sectors read
  120. 4. the number of milliseconds spent reading
  121. 5. the number of writes completed
  122. 6. the number of writes merged
  123. 7. the number of sectors written
  124. 8. the number of milliseconds spent writing
  125. 9. the number of I/Os currently in progress
  126. 10. the number of milliseconds spent doing I/Os
  127. 11. the weighted number of milliseconds spent doing I/Os
  128. Additional counters:
  129. 12. the total time spent reading in milliseconds
  130. 13. the total time spent writing in milliseconds
  131. @stats_print_clear <region_id> [<starting_line> <number_of_lines>]
  132. Atomically print and then clear all the counters except the
  133. in-flight i/o counters. Useful when the client consuming the
  134. statistics does not want to lose any statistics (those updated
  135. between printing and clearing).
  136. <region_id>
  137. region_id returned from @stats_create
  138. <starting_line>
  139. The index of the starting line in the output.
  140. If omitted, all lines are printed and then cleared.
  141. <number_of_lines>
  142. The number of lines to process.
  143. If omitted, all lines are printed and then cleared.
  144. @stats_set_aux <region_id> <aux_data>
  145. Store auxiliary data aux_data for the specified region.
  146. <region_id>
  147. region_id returned from @stats_create
  148. <aux_data>
  149. The string that identifies data which is useful to the client
  150. program that created the range. The kernel returns this
  151. string back in the output of @stats_list message, but it
  152. doesn't use this value for anything.
  153. Examples
  154. ========
  155. Subdivide the DM device 'vol' into 100 pieces and start collecting
  156. statistics on them:
  157. dmsetup message vol 0 @stats_create - /100
  158. Set the auxillary data string to "foo bar baz" (the escape for each
  159. space must also be escaped, otherwise the shell will consume them):
  160. dmsetup message vol 0 @stats_set_aux 0 foo\\ bar\\ baz
  161. List the statistics:
  162. dmsetup message vol 0 @stats_list
  163. Print the statistics:
  164. dmsetup message vol 0 @stats_print 0
  165. Delete the statistics:
  166. dmsetup message vol 0 @stats_delete 0