statistics.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 in milliseconds. All
  14. these counters may be accessed by sending the @stats_print message to
  15. the appropriate DM device via dmsetup.
  16. Each region has a corresponding unique identifier, which we call a
  17. region_id, that is assigned when the region is created. The region_id
  18. must be supplied when querying statistics about the region, deleting the
  19. region, etc. Unique region_ids enable multiple userspace programs to
  20. request and process statistics for the same DM device without stepping
  21. on each other's data.
  22. The creation of DM statistics will allocate memory via kmalloc or
  23. fallback to using vmalloc space. At most, 1/4 of the overall system
  24. memory may be allocated by DM statistics. The admin can see how much
  25. memory is used by reading
  26. /sys/module/dm_mod/parameters/stats_current_allocated_bytes
  27. Messages
  28. ========
  29. @stats_create <range> <step> [<program_id> [<aux_data>]]
  30. Create a new region and return the region_id.
  31. <range>
  32. "-" - whole device
  33. "<start_sector>+<length>" - a range of <length> 512-byte sectors
  34. starting with <start_sector>.
  35. <step>
  36. "<area_size>" - the range is subdivided into areas each containing
  37. <area_size> sectors.
  38. "/<number_of_areas>" - the range is subdivided into the specified
  39. number of areas.
  40. <program_id>
  41. An optional parameter. A name that uniquely identifies
  42. the userspace owner of the range. This groups ranges together
  43. so that userspace programs can identify the ranges they
  44. created and ignore those created by others.
  45. The kernel returns this string back in the output of
  46. @stats_list message, but it doesn't use it for anything else.
  47. <aux_data>
  48. An optional parameter. A word that provides auxiliary data
  49. that is useful to the client program that created the range.
  50. The kernel returns this string back in the output of
  51. @stats_list message, but it doesn't use this value for anything.
  52. @stats_delete <region_id>
  53. Delete the region with the specified id.
  54. <region_id>
  55. region_id returned from @stats_create
  56. @stats_clear <region_id>
  57. Clear all the counters except the in-flight i/o counters.
  58. <region_id>
  59. region_id returned from @stats_create
  60. @stats_list [<program_id>]
  61. List all regions registered with @stats_create.
  62. <program_id>
  63. An optional parameter.
  64. If this parameter is specified, only matching regions
  65. are returned.
  66. If it is not specified, all regions are returned.
  67. Output format:
  68. <region_id>: <start_sector>+<length> <step> <program_id> <aux_data>
  69. @stats_print <region_id> [<starting_line> <number_of_lines>]
  70. Print counters for each step-sized area of a region.
  71. <region_id>
  72. region_id returned from @stats_create
  73. <starting_line>
  74. The index of the starting line in the output.
  75. If omitted, all lines are returned.
  76. <number_of_lines>
  77. The number of lines to include in the output.
  78. If omitted, all lines are returned.
  79. Output format for each step-sized area of a region:
  80. <start_sector>+<length> counters
  81. The first 11 counters have the same meaning as
  82. /sys/block/*/stat or /proc/diskstats.
  83. Please refer to Documentation/iostats.txt for details.
  84. 1. the number of reads completed
  85. 2. the number of reads merged
  86. 3. the number of sectors read
  87. 4. the number of milliseconds spent reading
  88. 5. the number of writes completed
  89. 6. the number of writes merged
  90. 7. the number of sectors written
  91. 8. the number of milliseconds spent writing
  92. 9. the number of I/Os currently in progress
  93. 10. the number of milliseconds spent doing I/Os
  94. 11. the weighted number of milliseconds spent doing I/Os
  95. Additional counters:
  96. 12. the total time spent reading in milliseconds
  97. 13. the total time spent writing in milliseconds
  98. @stats_print_clear <region_id> [<starting_line> <number_of_lines>]
  99. Atomically print and then clear all the counters except the
  100. in-flight i/o counters. Useful when the client consuming the
  101. statistics does not want to lose any statistics (those updated
  102. between printing and clearing).
  103. <region_id>
  104. region_id returned from @stats_create
  105. <starting_line>
  106. The index of the starting line in the output.
  107. If omitted, all lines are printed and then cleared.
  108. <number_of_lines>
  109. The number of lines to process.
  110. If omitted, all lines are printed and then cleared.
  111. @stats_set_aux <region_id> <aux_data>
  112. Store auxiliary data aux_data for the specified region.
  113. <region_id>
  114. region_id returned from @stats_create
  115. <aux_data>
  116. The string that identifies data which is useful to the client
  117. program that created the range. The kernel returns this
  118. string back in the output of @stats_list message, but it
  119. doesn't use this value for anything.
  120. Examples
  121. ========
  122. Subdivide the DM device 'vol' into 100 pieces and start collecting
  123. statistics on them:
  124. dmsetup message vol 0 @stats_create - /100
  125. Set the auxillary data string to "foo bar baz" (the escape for each
  126. space must also be escaped, otherwise the shell will consume them):
  127. dmsetup message vol 0 @stats_set_aux 0 foo\\ bar\\ baz
  128. List the statistics:
  129. dmsetup message vol 0 @stats_list
  130. Print the statistics:
  131. dmsetup message vol 0 @stats_print 0
  132. Delete the statistics:
  133. dmsetup message vol 0 @stats_delete 0