DMSTATS(8)
๐ DMSTATS(8) โ the maintenance commands girlie ๐
okay bestie, so dmstats is literally the Device-mapper statistics management tool, and it lives in section 8 of the manual (that's the maintenance-commands section, iykyk). she's iconic, she's powerful, and she is obsessed with IO stats. let's get into it ๐ฆ
โจ NAME โจ
dmstats โ Device-mapper statistics management ๐
๐ธ SYNOPSIS ๐ธ
so here's the whole vibe, in exact syntax, no cap:
dmsetup stats command [OPTIONS]
dmstats command device_name|--major major --minor minor|-u|--uuid uuid
[-v|--verbose]
dmstats clear device_name [--allprograms|--programid id] [--allregions|
--regionid id]
dmstats create device_name ...|file_path ...|--alldevices
[--areas nr_areas|--areasize area_size] [--bounds histogram_boundaries]
[--filemap] [--follow follow_mode]
[--foreground] [--nogroup] [--nomonitor] [--precise]
[--start start_sector --length length|--segments]
[--userdata user_data] [--programid id]
dmstats delete device_name|--alldevices [--allprograms|--programid id]
[--allregions|--regionid id]
dmstats group [device_name|--alldevices] [--alias name]
[--regions regions]
dmstats help [-c|-C|--columns]
dmstats list [device_name] [--allprograms|--programid id] [--area]
[--group] [--region] [--histogram] [--nosuffix] [--notimesuffix]
[--units units]
dmstats print [device_name] [--clear] [--allprograms|--programid id]
[--allregions|--regionid id]
dmstats report [device_name] [--interval seconds] [--count count]
[--units units] [--allprograms|--programid id] [--allregions|
--regionid id] [--area] [--group] [--region] [--histogram]
[--nosuffix] [--notimesuffix] [--units units]
[-O|--sort sort_fields] [-S|--select selection]
dmstats ungroup [device_name|--alldevices] [--groupid id]
dmstats update_filemap file_path [--follow follow_mode] [--foreground]
[--groupid id] [--nomonitor]
๐ DESCRIPTION ๐
dmstats is the program that manages IO statistics regions for devices that use the device-mapper driver. and the way that regions can be created, deleted, listed and reported on using the tool?? literally so much range. she does it all ๐
the first argument to dmstats is a command. that's the main character of the sentence, periodt.
the second argument is the device name, uuid or major and minor numbers. pick your fave, bestie.
then further options permit the selection of regions, output format control, and reporting behaviour. so you're never stuck with a vibe you don't want โจ
๐ซถ heads up: when no device argument is given, dmstats will by default operate on all device-mapper devices present. and thecreateanddeletecommands require the use of--alldeviceswhen used in this way โ no skipping that step, fr fr.
(part 1 of 6 โ more coming, don't go anywhere ๐)
โจ OPTIONS โจ
okay bestie, this is the big one โ every single flag and option, no skips, no cap. ๐
--alias nameโ set an alias name for a group. cute little nickname energy. ๐--alldevicesโ if no device arguments are given, allow operation on all devices when creating or deleting regions. ๐--allprogramsโ include regions from all program IDs for list and report operations. ๐--allregionsโ include all present regions for commands that normally accept a single region identifier. ๐--areaโ when performing a list or report, include objects of type area in the results. ๐--areas nr_areasโ specify the number of statistics areas to create within a new region. ๐งฉ--areasize area_size[b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E]โ specify the size of areas into which a new region should be divided. An optional suffix selects units of: (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalize to use multiples of 1000 (S.I.) instead of 1024. โจ--bounds histogram_boundaries[ns|us|ms|s]โ specify the boundaries of a latency histogram to be tracked for the region as a comma-separated list of latency values. Latency values are given in nanoseconds. An optional unit suffix ofns,us,msorsmay be given after each value to specify units of nanoseconds, microseconds, milliseconds or seconds respectively. ๐ฆ--clearโ when printing statistics counters, also atomically reset them to zero. ๐งผ--count countโ specify the iteration count for repeating reports. If thecountargument is zero reports will continue to repeat until interrupted. ๐--groupโ when performing a list or report, include objects of type group in the results. ๐ฏ--filemapโ instead of creating regions on a device as specified by command line options, open the file found at eachfile_pathargument, and create regions corresponding to the locations of the on-disk extents allocated to the file(s). ๐บ๏ธ--follow follow_modeโ specify thedmfilemapd(8)file following mode. The file map monitoring daemon can monitor files in two distinct ways: the mode affects the behaviour of the daemon when a file under monitoring is renamed or unlinked, and the conditions that cause the daemon to terminate.- The
follow_modeargument is either"inode", for follow-inode mode, or"path", for follow-path mode. - If follow-inode mode is used, the daemon will hold the file open, and continue to update regions from the same file descriptor. This means that the mapping will follow rename, move (within the same file system), and unlink operations. This mode is useful if the file is expected to be moved, renamed, or unlinked while it is being monitored.
- In follow-inode mode, the daemon will exit once it detects that the file has been unlinked and the daemon is the last holder of a reference to it.
- If follow-path is used, the daemon will re-open the provided path on each monitoring iteration. This means that the group will be updated to reflect a new file being moved to the same path as the original file. This mode is useful for files that are expected to be updated via unlink and rename.
- In follow-path mode, the daemon will exit if the file is removed and not replaced within a brief tolerance interval.
- In either mode, the daemon exits automatically if the monitored group is removed.
- The
--foregroundโ specify that thedmfilemapd(8)daemon should run in the foreground. The daemon will not fork into the background, and will replace thedmstatscommand that started it. ๐--groupid idโ specify the group to operate on. ๐ซถ--histogramโ when used with the report and list commands select default fields that emphasize latency histogram data. ๐--interval secondsโ specify the interval in seconds between successive iterations for repeating reports. If--intervalis specified but--countis not, reports will continue to repeat until interrupted. โฑ๏ธ--length length[b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E]โ specify the length of a new statistics region in sectors. An optional suffix selects units of: (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalize to use multiples of 1000 (S.I.) instead of 1024. ๐-j|--major majorโ specify the major number. ๐ข-m|--minor minorโ specify the minor number. ๐ข--nogroupโ when creating regions mapping the extents of a file in the file system, do not create a group or set an alias. ๐ โโ๏ธ--nomonitorโ disable thedmfilemapd(8)daemon when creating new file mapped groups. Normally the device-mapper filemap monitoring daemondmfilemapd(8), is started for each file mapped group to update the set of regions as the file changes on disk: use of this option disables this behaviour.- Regions in the group may still be updated with the
update_filemapcommand, or by starting the daemon manually.
- Regions in the group may still be updated with the
--nosuffixโ suppress the suffix on output sizes. Use with--units(excepthandH) if processing the output. ๐ซ--notimesuffixโ suppress the suffix on output time values. Histogram boundary values will be reported in units of nanoseconds. โณ-o|--optionsโ specify which report fields to display. ๐งพ--preciseโ attempt to use nanosecond precision counters when creating new statistics regions. ๐ฏ--programid idโ specify a program ID string. When creating new statistics regions this string is stored with the region. Subsequent operations may supply a program ID in order to select only regions with a matching value. The default program ID for dmstats-managed regions is"dmstats". ๐--regionโ when performing a list or report, include objects of type region in the results. ๐--regionid idโ specify the region to operate on. ๐ฏ--regions region_listโ specify a list of regions to group. The group list is a comma-separated list of region identifiers. Continuous sequences of identifiers may be expressed as a hyphen-separated range, for example:'1โ10'. ๐--relativeโ if displaying the histogram report show relative (percentage) values instead of absolute counts. ๐--segmentsโ when used withcreate, create a new statistics region for each target contained in the given device(s). This causes a separate region to be allocated for each segment of the device.- The newly created regions are automatically placed into a group unless the
--nogroupoption is given. When grouping is enabled a group alias may be specified using the--aliasoption.
- The newly created regions are automatically placed into a group unless the
-S|--select selectionโ display only rows that match selection criteria; all rows then include the additional"selected"column (-o selected), showing1if the row matches the selection and0otherwise. The selection criteria are defined by specifying column names and their valid values while making use of supported comparison operators. ๐-O|--sort sort_fieldsโ sort output according to the list of fields given. Precede any sort field with-for a reverse sort on that column. ๐--start start[b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E]โ specify the start offset of a new statistics region in sectors. An optional suffix selects units of: (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalize to use multiples of 1000 (S.I.) instead of 1024. ๐--units [units][h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E]โ set the display units for report output. All sizes are output in these units: (h)uman-readable, (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalize to use multiples of 1000 (S.I.) instead of 1024. Can also specify custom units e.g.--units 3M. ๐--userdata user_dataโ specify user data (a word) to be stored with a new region. The value is added to any internal auxiliary data (for example, group information), and stored with the region in theaux_datafield provided by the kernel. Whitespace is not permitted. ๐ท๏ธ-u|--uuidโ specify the UUID. ๐-v|--verbose [-v|--verbose]โ produce additional output. ๐ฃ๏ธ
โจ COMMANDS โจ
okay bestie, here's the whole menu of things you can actually do with dmstats ๐
every single command, no skips, no "and the rest is obvious" energy. buckle up.
๐งผ clear
clear device_name [--allprograms|--programid id] [--allregions|
--regionid id]
This one tells the kernel to clear the statistics counters for the regions you point at โ with exactly one exception: the in-flight IO counters. those ones do not get cleared. don't @ me, that's just how it is. ๐
๐ฑ create
create device_name ...|file_path ...|--alldevices [--areas nr_areas|
--areasize area_size] [--bounds histogram_boundaries] [--filemap]
[--follow follow_mode] [--foreground] [--nogroup] [--nomonitor]
[--precise] [--start start_sector --length length|--segments]
[--userdata user_data] [--programid id]
Creates one or more brand-new statistics regions on the device(s) you named. this is the glow-up command โจ
So the region is gonna span the entire device unless you give it --start and --length, or --segments. The --start and --length options let you drop a region of whatever arbitrary length you want at whatever arbitrary offset into the device. And --segments? That makes a whole new region for each target in the corresponding device-mapper device's table. one region per target, slay.
If you use --precise, the command will attempt to create a region using nanosecond precision counters. fancy timestamps, we love her.
If --bounds is given, a latency histogram gets tracked for the new region. The boundaries of the histogram bins are given as a comma-separated list of latency values. There's an implicit lower bound of zero on the first bin, and an implicit upper bound of infinity (or the configured interval duration) on the final bin. sneaky little bounds, iconic.
Latencies are given in nanoseconds. You can also tack on an optional unit suffix of ns, us, ms, or s after each value to specify units of nanoseconds, microseconds, milliseconds or seconds respectively โ so like, 10 ms is equivalent to 10,000,000 ns. math is math ๐งฎ Latency values with a precision of less than one millisecond can only be used when precise timestamps are enabled: if --precise is not given and values less than one millisecond are used, it will be enabled automatically. the command got you, fr fr.
An optional program_id or user_data string may be associated with the region. A program_id may then be used to select regions for subsequent list, print, and report operations. The user_data stores an arbitrary string and is not used by dmstats or the device-mapper kernel statistics subsystem โ it's just vibes, a lil free-text box for you.
By default, dmstats creates regions with a program_id of "dmstats". ๐
On success the region_id of the newly created region is printed to stdout. congrats, you made a region ๐
Now, the file stuff ๐
If the --filemap option is given with a regular file, or a list of files, as the file_path argument, then instead of creating regions with parameters specified on the command line, dmstats will open the files located at file_path and create regions corresponding to the physical extents allocated to the file. This can be used to monitor statistics for individual files in the file system โ for example, virtual machine images, swap areas, or large database files.
To work with the--filemapoption, files must be located on a local file system, backed by a device-mapper device, that supports physical extent data using theFIEMAPioctl (e.g.Ext4andXFS). no local fs, no fiemap, no dice.
By default, regions that map a file are placed into a group and the group alias is set to the basename of the file. This behaviour can be overridden with the --alias and --nogroup options.
Creating a group that maps a file automatically starts a daemon, dmfilemapd(8), to monitor the file and update the mapping as the extents allocated to the file change. This behaviour can be disabled using the --nomonitor option. (yes, a whole daemon. she's got a job and she's doing it ๐ซถ)
Use the --group option to display information only for groups when listing and reporting.
๐๏ธ delete
delete device_name|--alldevices [--allprograms|--programid id]
[--allregions|--regionid id]
Deletes the statistics region you specify. All counters and resources used by the region are released and the region will not appear in the output of subsequent list, print, or report operations. gone. poof. ๐จ
All regions registered on a device may be removed using --allregions.
To remove all regions on all devices, both --allregions and --alldevices must be used. both. together. besties.
If a --groupid is given instead of a --regionid, the command will attempt to delete the group and all regions that it contains.
And if a deleted region is the first member of a group of regions, the group will also be removed. bye group, we hardly knew ye ๐ญ
๐ซ group
group [device_name|--alldevices] [--alias name] [--regions regions]
Combines one or more statistics regions on the specified device into a group. friendship bracelet for your regions ๐
The list of regions to be grouped is specified with --regions, and an optional alias may be assigned with --alias. The set of regions is given as a comma-separated list of region identifiers. A continuous range of identifiers spanning from R1 to R2 may be expressed as 'R1-R2'. ranges!! so convenient.
Regions that have a histogram configured can be grouped: in this case the number of histogram bins and their bounds must match exactly. no mismatched bins in this house.
On success the group list and newly created group_id are printed to stdout. ๐
The group metadata is stored with the first (lowest numbered) region_id in the group: deleting this region will also delete the group, and other group members will be returned to their prior state. so like, that one region is holding the whole group's keys. protect her.
๐ help
help [-c|-C|--columns]
Outputs a summary of the commands available, optionally including the list of report fields. it's the "hey what do i do now" command, always there for you ๐ซถ
๐ list
list [device_name] [--allprograms|--programid id] [--area] [--group]
[--region] [--histogram] [--nosuffix] [--notimesuffix]
[--units units]
List the statistics regions, areas, or groups registered on the device. If the --allprograms switch is given, all regions will be listed regardless of region program ID values.
By default only regions and groups are included in list output. If -v or --verbose is given, the report will also include a row of information for each configured group and for each area contained in each region displayed. verbose = she's showing everything โจ
Regions that contain a single area are by default omitted from the verbose list, since their properties are identical to the area that they contain โ to view all regions regardless of the number of areas present, use --region. To also view the areas contained within regions, use --area.
If --histogram is given, the report will include the bin count and latency boundary values for any configured histograms. ๐
๐จ๏ธ print
print [device_name] [--clear] [--allprograms|--programid id]
[--allregions|--regionid id]
Print raw statistics counters for the specified region or for all present regions. raw numbers, no garnish, just data ๐ง
๐ report
report [device_name] [--interval seconds] [--count count]
[--units units] [--allprograms|--programid id] [--allregions|
--regionid id] [--area] [--group] [--region] [--histogram]
[--nosuffix] [--notimesuffix] [--units units]
[-O|--sort sort_fields] [-S|--select selection]
Start a report for the specified object or for all present objects. If the count argument is specified, the report will repeat at a fixed interval set by the --interval option. The default interval is one second. tick tock, tick tock โฐ
If the --allprograms switch is given, all regions will be listed, regardless of region program ID values.
If --histogram is given, the report will include the histogram values and latency boundaries.
If --relative is used, the default histogram field displays bin values as a percentage</> of the total number of I/Os. percentages are so much cuter than raw numbers honestly.
Object types (areas, regions and groups) to include in the report are selected using the --area, --region, and --group options.
๐ ungroup
ungroup [device_name|--alldevices] [--groupid id]
Remove an existing group and return all the group's regions to their original state. it's the breakup command, but make it administrative ๐ญ๐
The group to be removed is specified using --groupid.
๐ update_filemap
update_filemap file_path [--follow follow_mode] [--foreground]
[--groupid id] [--nomonitor]
Update a group of dmstats regions specified by group_id, that were previously created with --filemap, either directly, or by starting the monitoring daemon dmfilemapd(8). keeping the file mapping fresh, no cap โจ
This will add and remove regions to reflect changes in the allocated extents of the file on disk since it was created or last updated.
Use of this command is not normally needed, since the dmfilemapd(8) daemon will automatically monitor filemap groups and perform these updates when required. she handles it, you can chill ๐
If a filemapped group was created with --nomonitor, or the daemon has been killed, then update_filemap can be used to manually force an update or start a new daemon.
Use --nomonitor to force a direct update and disable starting the monitoring daemon.
๐ REGIONS, AREAS, AND GROUPS ๐
okay so this is the part where it gets good. The device-mapper statistics facility lets you keep separate performance counters for literally any arbitrary region of a device. A region can span any range โ from a single sector all the way up to the whole entire device. And a region can be broken down further into a bunch of distinct areas (one or more, no cap), and each area gets its own little counter set. When you do that, you also get a summary value for the whole region that you can use in reports. bestie that's so convenient.
On top of that, one or more regions on a single device can be combined into a statistics group. Groups let several regions get aggregated and reported as one single entity โ counters for every region and every area get summed up and used to report totals for all the group members. Groups also let you assign an optional alias, so you can give meaningful names to sets of regions. iconic behavior tbh.
โ ๏ธ real talk: the group metadata is stored with the first (lowest numbered) region_id in the group. So deleting that region also deletes the group, and the other group members get returned to their prior state. do not forget this one. ๐
By default, new regions span the entire device. The --start and --length options let you place a region of any size at any location on the device. โจ
Using offsets, you can create regions that map individual objects within a block device โ think partitions, files in a file system, or stripes and other structures in a RAID volume. And groups let several non-contiguous regions get assembled together for reporting and data aggregation. ๐
A region can be either divided into the specified number of equal-sized areas, or into areas of the given size by specifying one of --areas or --areasize when you create a region with the create command. Heads up though: depending on the size of the areas and the device region, that final area within the region might come out smaller than you asked for. it's giving "close enough" ๐ซถ
๐ Region identifiers
Every region gets assigned an identifier when it's created, and that's what you use to reference it in all your later operations. Region identifiers are unique within a given device โ and yes, that includes across different program_id values.
Depending on the sequence of create and delete operations, there can be gaps in the sequence of region_id values for a particular device. so don't freak out if the numbers skip around, that's just how it is.
Treat the region_id as an opaque identifier โ it's just a handle for referencing the region. no cap.
๐ฆ Group identifiers
Groups also get assigned an integer identifier at creation time, and just like region identifiers, group identifiers are unique within the containing device.
The group_id should also be treated as an opaque identifier used to reference the group. same energy, different noun ๐
๐ธ FILE MAPPING ๐ธ
Using --filemap, you can create regions that correspond to the extents of a file in the file system. This means you can monitor IO statistics on a per-file basis โ like, say, to keep an eye on huge database files, virtual machine images, or literally any other file you're obsessed with. ๐
To use file mapping, the file has to be on a file system backed by a device-mapper device that supports the FIEMAP ioctl and returns data describing the physical location of extents. Currently that includes xfs(5) and ext4(5). so those two are the vibe. ๐
By default, the regions making up a file get placed together in a group, and the group alias is set to the basename(3) of the file. That way you can report statistics for the file as a whole, aggregating values for all the regions making up the group. And if you want to see only the whole file (the group) when you use the list and report commands, use --group. โจ
Since the file can totally change after the initial group of regions is created, there's the update_filemap command and the dmfilemapd(8) daemon โ so you can update file mapped groups either manually or automatically. slay.
๐ง File follow modes
The file map monitoring daemon can monitor files in two distinct ways: follow-inode mode and follow-path mode.
The mode changes how the daemon behaves when a file it's monitoring gets renamed or unlinked, and it also changes the conditions that make the daemon terminate.
If follow-inode mode is used, the daemon will hold the file open and keep updating regions from that same file descriptor. This means the mapping will follow rename, move (within the same file system), and unlink operations. So this mode is your bestie if the file is expected to be moved, renamed, or unlinked while it's being monitored. ๐ซถ
In follow-inode mode, the daemon will exit once it detects that the file has been unlinked and the daemon is the last holder of a reference to it.
If follow-path is used, the daemon will re-open the provided path on every single monitoring iteration. That means the group gets updated to reflect a new file being moved to the same path as the original file. This mode is perfect for files that are expected to be updated via unlink and rename. ๐
In follow-path mode, the daemon will exit if the file is removed and not replaced within a brief tolerance interval (one second).
To stop the daemon, just delete the group containing the mapped regions โ the daemon will automatically shut down. ๐
The daemon can also be safely killed at any time with the group kept. But here's the catch: if the file is still being allocated, the mapping will become progressively out-of-date as extents are added and removed. In that case, you can restart the daemon or update the group manually with the update_filemap command. โญ
See the create command and the --filemap, --follow, and --nomonitor options for further information. iykyk.
๐ Limitations
The daemon tries its best to maintain good synchronization between the file extents and the regions contained in the group, but โ because it can only react to new allocations once they have been written โ there are inevitably some I/O events that just cannot be counted when a file is growing. This hits especially hard if the file is being extended by a single thread writing beyond end-of-file (for example, the dd(1) program). ๐ญ
Events may also be lost because there is currently no way to atomically resize a dmstats region and preserve its current counter values. This affects files when they grow by extending the final extent, rather than allocating a new extent: any events that had accumulated in the region between any prior operation and the resize are lost. gone. poof. ๐
File mapping is currently most effective in cases where the majority of I/O does not trigger extent allocation. Future updates may address these limitations when kernel support is available. so... watch this space. ๐
โจ REPORT FIELDS โจ
okay so the dmstats report gives you a bunch of different types of field, right? and you can totally add them to the default field set, or use them to build your own custom reports from scratch. your report, your rules ๐
big thing to know: all performance counters and metrics are calculated per-area. every single one. no cap.
๐ธ Derived metrics ๐ธ
so there's a whole crew of metric fields that hand you high-level performance indicators, and they're basically the glow-up version of the fields from the conventional Linux iostat program โ they're all derived from the basic counter values the kernel gives you for each area. so like, the receipts come from the kernel, and these fields do the math for you ๐งฎโจ
reads_merged_per_secโ reads merged per second.writes_merged_per_secโ writes merged per second.reads_per_secโ reads completed per second.writes_per_secโ writes completed per second.read_size_per_secโ size of data read per second.write_size_per_secโ size of data written per second.avg_request_sizeโ average request size.queue_sizeโ average queue size.awaitโ the average wait time for read and write operations.r_awaitโ the average wait time for read operations.w_awaitโ the average wait time for write operations.throughputโ the device throughput, in operations per second.service_timeโ the average service time (in milliseconds, bestie) for operations issued to the device.utilโ percentage of elapsed time during which I/O requests were issued to the device (that's the bandwidth utilization for the device, iykyk). and heads up: device saturation occurs when this value gets close to 100% ๐๐ฅ
๐ฆ Group, region and area meta fields ๐ฆ
meta fields are the ones that spill the tea about which groups, regions, or areas the statistics values actually relate to. so that's the region and area identifier, start, length, and counts, plus the program ID and user data values. the whole context package, basically ๐
region_idโ the region identifier. it's a non-negative integer that the kernel hands back when a statistics region gets created.region_startโ where the region starts. the display units are chosen by the--unitsoption.region_lenโ how long the region is. display units again come from--units.area_idโ the area identifier. these are assigned by the device-mapper statistics library and they uniquely identify each area inside a region. every ID maps to a distinct set of performance counters for that area of the statistics region. and here's the vibe: area identifiers are always monotonically increasing within a region, so higher ID values line up with greater sector addresses within the area, and there are no gaps in the sequence of identifiers. clean and orderly, we love to see it โจarea_startโ where the area starts. display units selected by--units.area_lenโ the length of the area. you already know:--unitspicks the display units.area_countโ the number of areas in this region.program_idโ the program ID value associated with this region.user_dataโ the user data value associated with this region.group_idโ the group identifier. it's a non-negative integer returned by thedmstats groupcommand when a statistics group is created.interval_nsโ the estimated interval over which the current counter values have accumulated. reported as an integer, expressed in units of nanoseconds.intervalโ same estimated interval, same accumulated-counter-values situation, but reported as a real number in units of seconds.
๐ Basic counters ๐
basic counters give you direct access to the raw counter data straight from the kernel, so another program can do further processing on it. raw data, no filter, iconic ๐
so the kernel provides thirteen separate counters for each statistics area. the first eleven of these match the counters you'd find in /proc/diskstats or /sys/block/*/*/stat. and the final pair? those give you separate counters for read and write time. cute.
read_countโ count of reads completed this interval.reads_merged_countโ count of reads merged this interval.read_sector_countโ count of 512-byte sectors read this interval.read_timeโ accumulated duration of all read requests (ns).write_countโ count of writes completed this interval.writes_merged_countโ count of writes merged this interval.write_sector_countโ count of 512-byte sectors written this interval.write_timeโ accumulated duration of all write requests (ns).in_progress_countโ count of requests currently in progress.io_ticksโ nanoseconds spent servicing requests.queue_ticksโ okay this one's a whole thing: this field gets incremented at each I/O start, I/O completion, I/O merge, or read of these stats, by the number of I/Os in progress multiplied by the number of milliseconds spent doing I/O since the last update of this field. and why do we care? because it can give you an easy measure of both I/O completion time and the backlog that may be accumulating. two-for-one, slay.read_ticksโ nanoseconds spent servicing reads.write_ticksโ nanoseconds spent servicing writes.
๐ Histogram fields ๐
histograms measure the frequency distribution of user-specified I/O latency intervals. the histogram bin boundaries get specified when a region is created. periodt.
and you can drop a brief representation of the histogram values and latency intervals into the report using these fields ๐
hist_countโ a list of the histogram counts for the current statistics area, in order of ascending latency value. each value represents the number of I/Os with latency times falling into that bin's time range during the sample period.hist_count_boundsโ a list of the histogram counts for the current statistics area, in order of ascending latency value, including bin boundaries: each count is prefixed by the lower bound of the corresponding histogram bin.hist_count_rangesโ a list of the histogram counts for the current statistics area, in order of ascending latency value, including bin boundaries: each count is prefixed by both the lower and upper bounds of the corresponding histogram bin.hist_percentโ a list of the relative histogram values for the current statistics area, in order of ascending latency value, expressed as a percentage. each value represents the proportion of I/Os with latency times falling into that bin's time range during the sample period.hist_percent_boundsโ a list of the relative histogram values for the current statistics area, in order of ascending latency value, expressed as a percentage and including bin boundaries. each value represents the proportion of I/Os with latency times falling into that bin's time range during the sample period, and it's prefixed with the corresponding bin's lower bound.hist_percent_rangesโ a list of the relative histogram values for the current statistics area, in order of ascending latency value, expressed as a percentage and including bin boundaries. each value represents the proportion of I/Os with latency times falling into that bin's time range during the sample period, and it's prefixed with the corresponding bin's lower and upper bounds.hist_boundsโ a list of the histogram boundary values for the current statistics area, in order of ascending latency value. the values are expressed in whole units of seconds, milliseconds, microseconds or nanoseconds, with a suffix indicating the unit.hist_rangesโ a list of the histogram bin ranges for the current statistics area, in order of ascending latency value. the values are expressed as"LOWER-UPPER"in whole units of seconds, milliseconds, microseconds or nanoseconds, with a suffix indicating the unit.hist_binsโ the number of latency histogram bins configured for the area.
๐ EXAMPLES ๐
Okay bestie, this is the part where it all clicks. Real commands, real output, no cap. Watch and learn โจ
Create a whole-device region with one area on vg00/lvol1 ๐
# dmstats create vg00/lvol1
vg00/lvol1: Created new region with 1 area(s) as region ID 0
Create a 32 MiB region 1 GiB into device d0 ๐ฆ
# dmstats create --start 1G --length 32M d0
d0: Created new region with 1 area(s) as region ID 0
Create a whole-device region with 8 areas on every device ๐ธ
# dmstats create --alldevices --areas 8
vg00-lvol1: Created new region with 8 area(s) as region ID 0
vg00-lvol2: Created new region with 8 area(s) as region ID 0
vg00-lvol3: Created new region with 8 area(s) as region ID 0
vg01-lvol0: Created new region with 8 area(s) as region ID 2
vg01-lvol1: Created new region with 8 area(s) as region ID 0
vg00-lvol2: Created new region with 8 area(s) as region ID 1
Delete all regions on all devices ๐
# dmstats delete --alldevices --allregions
Create a whole-device region with areas 10 GiB in size on vg00/lvol1 using dmsetup ๐
# dmsetup stats create --areasize 10G vg00/lvol1
vg00-lvol1: Created new region with 5 area(s) as region ID 1
Create a 1 GiB region with 16 areas at the start of vg00/lvol1 ๐
# dmstats create --start 0 --length 1G --areas=16 vg00/lvol1
vg00-lvol1: Created new region with 16 area(s) as region ID 0
List the statistics regions registered on vg00/lvol1 โจ
# dmstats list vg00/lvol1
Name RgID RStart RSize #Areas ASize ProgID
vg00-lvol1 0 0 61.00g 1 61.00g dmstats
vg00-lvol1 1 61.00g 19.20g 1 19.20g dmstats
vg00-lvol1 2 80.20g 2.14g 1 2.14g dmstats
Display five statistics reports for vg00/lvol1 at an interval of one second โฑ๏ธ
# dmstats report --interval 1 --count 5 vg00/lvol1
# dmstats report
Name RgID ArID AStart ASize RRqM/s WRqM/s R/s โ
vg00-lvol1 0 0 0 61.00g 0.00 0.00 0.00
vg00-lvol1 1 0 61.00g 19.20g 0.00 0.00 0.00
vg00-lvol1 2 0 80.20g 2.14g 0.00 0.00 0.00
โ W/s RSz/s WSz/s AvRqSz QSize Util% AWait RdAWa WrAWa
218.00 0.00 1.04m 4.50k 2.97 81.70 13.62 0.00 13.62
5.00 0.00 548.00k 109.50k 0.14 11.00 27.40 0.00 27.40
14.00 0.00 1.15m 84.00k 0.39 18.70 27.71 0.00 27.71
That little โ in there? It's the manpage telling you the row wraps around, bestie. The header got too long for one line so it just keeps going. It's giving โจsidewaysโจ.
Create one region for each target contained in device vg00/lvol1 ๐
# dmstats create --segments vg00/lvol1
vg00-lvol1: Created new region with 1 area(s) as region ID 0
vg00-lvol1: Created new region with 1 area(s) as region ID 1
vg00-lvol1: Created new region with 1 area(s) as region ID 2
Create regions mapping each file in the directory images/ and place them into separate groups, each named after the corresponding file. ๐ง
# dmstats create --filemap images/*
images/vm1.qcow2: Created new group with 87 region(s) as group ID 0.
images/vm1-1.qcow2: Created new group with 8 region(s) as group ID 87.
images/vm2.qcow2: Created new group with 11 region(s) as group ID 95.
images/vm2-1.qcow2: Created new group with 1454 region(s) as group ID 106.
images/vm3.img: Created new group with 2 region(s) as group ID 1560.
Print raw counters for region 4 on device d0 ๐ฅ
# dmstats print --regionid 4 d0
2097152+65536 0 0 0 0 29 0 264 701 0 41 701 0 41
๐ซถ AUTHORS ๐ซถ
- Bryn M. Reeves
The icon who built this. Respect. ๐
๐ SEE ALSO ๐
dmfilemapd(8),dmsetup(8),ext4(5),xfs(5)- LVM2 resource page:
- Device-mapper resource page:
- Device-mapper statistics kernel documentation
Documentation/device-mapper/statistics.txt
And that's the whole page, bestie!! ๐ Go forth and measure literally every I/O your kernel does. Slay. ๐ โจ
This one's from the Linux fam, dated Mar 23 2025, and it's filed under DMSTATS(8) โ iykyk. ๐ฆ๐ธ๐
๐ฆ where this page comes from
- arch rolling: device-mapper 2.03.43-2
- arch rolling: device-mapper 2.03.44-1 ยท GPL-2.0-only AND LGPL-2.1-only
- centos-stream 10: device-mapper 10:1.02.217-1.el10 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms