← Documents Documentation/admin-guide/device-mapper/statistics.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Device Mapper

DM statistics

Bio-based DM device를 사용자 정의 region과 area로 나눠 I/O counter, 정밀 timestamp와 latency histogram을 수집·조회·초기화하는 message interface입니다.

Source pathDocumentation/admin-guide/device-mapper/statistics.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

Region과 counter 모델

statistics.rst:1-39

시작 sector, 길이와 step으로 area를 나누고 region_id별 block I/O 통계를 수집합니다.

생성과 userspace metadata

statistics.rst:40-103

Range·step, precise timestamp, histogram, program_id와 aux_data 문법을 설명합니다.

관리·출력·예제

statistics.rst:104-225

Region 삭제·clear·list·print·print_clear·set_aux와 13개 counter 및 dmsetup 사용법을 정리합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

사용자 정의 region별 I/O 통계

1-39

Device Mapper는 DM device에서 사용자가 정의한 region별 I/O statistics 수집을 지원합니다. Region을 정의하지 않으면 통계를 수집하지 않으므로 성능 영향도 없습니다. 현재는 bio-based DM device만 지원합니다.

각 region은 시작 sector, 길이와 step을 지정합니다. 지정 범위 안을 step 크기 area로 나누고 각 area마다 독립적인 statistics를 수집합니다.

Region subdivision
DM device사용자 정의 start + lengthRegionStep 크기로 분할Area 0..N 각각의 counters

하나의 DM device 범위를 region과 step-sized area로 나눠 각 area의 counter를 독립적으로 유지합니다.

각 area의 I/O counter 형식은 `/sys/block/*/stat` 또는 `/proc/diskstats`와 같습니다. 자세한 내용은 `Documentation/admin-guide/iostats.rst`를 참고합니다. 여기에 read와 write에 소비한 total time인 counter 12와 13을 추가합니다. Histogram argument를 사용하면 latency histogram을 나타내는 14번째 parameter도 보고합니다. 이 counter들은 `dmsetup`을 통해 적절한 DM device에 `@stats_print` message를 보내 읽습니다.

기본 보고 시간 단위는 millisecond이며 granularity는 kernel tick에 좌우됩니다. `precise_timestamps` option을 사용하면 nanosecond 단위로 보고합니다.

Region을 만들 때 고유한 `region_id`를 할당합니다. 통계 query, region 삭제 등의 작업에는 이 id를 지정해야 합니다. 고유 id 덕분에 여러 userspace program이 서로의 data를 침범하지 않고 같은 DM device의 통계를 요청·처리할 수 있습니다.

DM statistics 생성은 `kmalloc`으로 memory를 할당하고 필요하면 `vmalloc` 공간으로 fallback합니다. 전체 system memory의 최대 1/4까지 DM statistics가 할당할 수 있습니다. 현재 사용량은 다음 parameter에서 확인합니다.

	/sys/module/dm_mod/parameters/stats_current_allocated_bytes
DM statistics 기본 특성
항목기본값 또는 제한선택 사항
지원 deviceBio-based DM device그 외는 현재 미지원
시간Millisecond, kernel tick granularity`precise_timestamps`: nanosecond
Memory allocator`kmalloc`실패 시 `vmalloc` fallback
Memory 상한전체 system memory의 1/4Sysfs parameter로 현재량 확인

지원 대상, 시간 단위와 memory 제한을 요약합니다.

@stats_create 범위와 step

40-60

`@stats_create`는 새 region을 만들고 그 `region_id`를 반환합니다.

    @stats_create <range> <step> [<number_of_optional_arguments> <optional_arguments>...] [<program_id> [<aux_data>]]

`<range>`에 `-`를 쓰면 device 전체를 뜻합니다. `<start_sector>+<length>` 형식은 `<start_sector>`에서 시작하는 `<length>`개의 512-byte sector 범위를 뜻합니다.

`<step>`에 `<area_size>`를 쓰면 range를 각각 `<area_size>` sector인 area로 나눕니다. `/<number_of_areas>`를 쓰면 지정한 개수의 area로 range를 나눕니다.

@stats_create 핵심 문법
위치형식의미
`<range>``-`전체 DM device
`<range>``<start_sector>+<length>`512-byte sector 기준 부분 범위
`<step>``<area_size>`각 area의 sector 수
`<step>``/<number_of_areas>`전체 area 개수

Range 선택과 area 분할 방식을 독립적으로 지정합니다.

Region 생성 결과
`@stats_create`Range 해석Step으로 area 분할Counters·memory 할당`region_id` 반환

Range와 step을 해석해 area counter 집합을 만들고 고유 id를 반환합니다.

정밀 timestamp와 latency histogram

61-86

`<number_of_optional_arguments>`는 뒤따르는 optional argument 수입니다. 지원 option은 `precise_timestamps`와 `histogram:n1,n2,n3,n4,...`입니다.

`precise_timestamps`는 `jiffies` 대신 nanosecond resolution의 precise timer를 사용합니다. 결과 시간도 millisecond 대신 nanosecond가 됩니다. 정밀 timestamp는 jiffies 기반 timestamp보다 얻는 비용이 조금 더 큽니다.

`histogram:n1,n2,n3,n4,...`는 latency histogram을 수집합니다. `n1`, `n2` 등의 숫자가 bucket boundary입니다. `precise_timestamps`를 쓰지 않으면 millisecond, 쓰면 nanosecond 단위입니다. Kernel은 각 범위 안에서 완료된 request 수를 보고합니다.

Optional argument
Option결과비용 또는 단위
`precise_timestamps`Precise timer로 시간 측정Nanosecond, jiffies보다 조금 느림
`histogram:n1,n2,...`Boundary별 완료 request 수기본 ms, precise option과 함께면 ns

시간 측정 방식과 latency 분포 수집을 선택합니다.

예를 들어 `histogram:10,20,30`은 네 숫자 `a:b:c:d`를 보고합니다. `a`는 0~10 ms, `b`는 10~20 ms, `c`는 20~30 ms에 완료된 request 수이며 `d`는 30 ms보다 오래 걸린 request 수입니다. `precise_timestamps`를 함께 쓰면 같은 boundary 숫자의 단위는 ns입니다.

`histogram:10,20,30` bucket
`a`: 0-10`b`: 10-20`c`: 20-30`d`: >30

세 boundary는 네 latency 구간을 만듭니다.

program_id와 aux_data

87-103

`<program_id>`는 region의 userspace owner를 고유하게 식별하는 선택적 이름입니다. Region을 group으로 묶어 userspace program이 자신이 만든 range를 식별하고 다른 program의 range를 무시할 수 있게 합니다.

Kernel은 이 문자열을 `@stats_list` 출력에 돌려주지만 다른 용도로 사용하지 않습니다. Optional argument 개수를 생략한 경우 program id는 숫자일 수 없습니다. 숫자라면 optional argument 개수로 해석되기 때문입니다.

`<aux_data>`는 region을 만든 client program에 유용한 보조 data를 담는 선택적 한 단어입니다. Kernel은 이 값도 `@stats_list` 출력에 돌려줄 뿐 다른 용도로 사용하지 않습니다.

Userspace metadata
Field용도Kernel 동작
`program_id`Owner별 region grouping과 filtering`@stats_list`에 반환
`aux_data`Client가 정한 보조 정보`@stats_list`에 반환
Parsing 주의Optional argument 수를 생략했다면 숫자 program_id는 개수로 오인되므로 사용할 수 없습니다.

Kernel이 보존·반환하지만 의미를 해석하지 않는 두 문자열입니다.

Region 삭제·clear·list

104-131

`@stats_delete`는 `@stats_create`가 반환한 id의 region을 삭제합니다.

    @stats_delete <region_id>

`@stats_clear`는 in-flight I/O counter를 제외한 모든 counter를 지웁니다.

    @stats_clear <region_id>

`@stats_list`는 `@stats_create`로 등록한 모든 region을 나열합니다. 선택적 `<program_id>`를 지정하면 일치하는 region만 반환하고, 생략하면 모두 반환합니다.

    @stats_list [<program_id>]

List 출력은 region id, range, step, program id, aux data와 생성 시 선택한 timestamp·histogram option을 포함합니다.

	Output format:
	  <region_id>: <start_sector>+<length> <step> <program_id> <aux_data>
	        precise_timestamps histogram:n1,n2,n3,...

`precise_timestamps`와 `histogram` 문자열은 region을 만들 때 실제로 지정한 경우에만 출력됩니다.

Region 관리 message
Message동작보존되는 값
`@stats_delete <region_id>`Region 삭제없음
`@stats_clear <region_id>`Counter clearIn-flight I/O counter
`@stats_list [<program_id>]`Region 조회·filter상태 변경 없음

고유 region id를 중심으로 수명주기와 counter 상태를 제어합니다.

Area counter 출력과 번호별 의미

132-172

`@stats_print`는 region의 각 step-sized area counter를 출력합니다. 선택적인 `<starting_line>`은 출력 시작 line index이며, `<number_of_lines>`는 포함할 line 수입니다. 둘을 생략하면 모든 line을 반환합니다.

    @stats_print <region_id> [<starting_line> <number_of_lines>]

각 area 출력은 `<start_sector>+<length>` 뒤에 counter가 이어지는 형식입니다. 처음 11개 counter는 `/sys/block/*/stat` 또는 `/proc/diskstats`와 같은 의미이며 `Documentation/admin-guide/iostats.rst`에 자세히 설명되어 있습니다.

	Output format for each step-sized area of a region:

	  <start_sector>+<length>
		counters

	  The first 11 counters have the same meaning as
	  `/sys/block/*/stat or /proc/diskstats`.

	  Please refer to Documentation/admin-guide/iostats.rst for details.
Counter 1-13
번호Counter기본 단위
1완료된 read 수Requests
2Merge된 read 수Requests
3읽은 sector 수Sectors
4Read에 소비한 시간ms
5완료된 write 수Requests
6Merge된 write 수Requests
7Write한 sector 수Sectors
8Write에 소비한 시간ms
9현재 진행 중인 I/O 수Requests
10I/O 수행에 소비한 시간ms
11I/O 수행 시간의 weighted 값ms
12Read에 소비한 total timems
13Write에 소비한 total timems
정밀 시간`precise_timestamps`를 사용하면 시간 counter는 nanosecond로 보고됩니다.
선택적 counter 14Histogram을 설정했다면 latency bucket count가 14번째 parameter로 추가됩니다.

기본 11개 block I/O counter에 누적 read·write total time 두 개를 추가합니다.

손실 없는 원자적 print와 clear

173-189

`@stats_print_clear`는 counter를 원자적으로 출력한 뒤 in-flight I/O counter를 제외한 나머지를 지웁니다. Print와 clear 사이에 갱신되는 statistics를 잃고 싶지 않은 client에 유용합니다.

    @stats_print_clear <region_id> [<starting_line> <number_of_lines>]

`<starting_line>`은 출력 시작 index이고, `<number_of_lines>`는 처리할 line 수입니다. 생략하면 모든 line을 출력한 다음 clear합니다.

Atomic print-clear
현재 counters원자적 snapshotSnapshot 출력In-flight 제외 counter clear새 update는 다음 구간에 유지

하나의 operation으로 snapshot과 reset을 묶어 print와 clear 사이의 update 손실을 막습니다.

Region의 auxiliary data 변경

190-200

`@stats_set_aux <region_id> <aux_data>`는 지정한 region에 auxiliary data를 저장합니다.

    @stats_set_aux <region_id> <aux_data>

`<region_id>`는 `@stats_create`가 반환한 id입니다. `<aux_data>`는 range를 만든 client program에 유용한 data를 식별하는 문자열입니다. Kernel은 이 문자열을 `@stats_list` 출력에 돌려주지만 값 자체를 해석하거나 다른 용도로 사용하지 않습니다.

Aux data round trip
Client의 aux string`@stats_set_aux`Region metadata`@stats_list`같은 string 반환

Userspace가 정한 문자열을 kernel이 region metadata로 보존해 list 결과에 다시 제공합니다.

100개 area 생성부터 삭제까지

201-225

DM device `vol` 전체를 100개 area로 나누고 통계 수집을 시작합니다.

  dmsetup message vol 0 @stats_create - /100

Auxiliary data를 `foo bar baz`로 설정합니다. 각 space의 escape 자체도 escape해야 하며, 그렇지 않으면 shell이 이를 소비합니다.

  dmsetup message vol 0 @stats_set_aux 0 foo\\ bar\\ baz

등록 region을 나열하고 region 0의 statistics를 출력한 뒤 삭제합니다.

  dmsetup message vol 0 @stats_list
  dmsetup message vol 0 @stats_print 0
  dmsetup message vol 0 @stats_delete 0
예제 region 수명주기
`@stats_create - /100``region_id 0``@stats_set_aux 0``@stats_list``@stats_print 0``@stats_delete 0`

전체 device를 100개 area로 만들고 metadata 설정, 조회, 출력, 삭제 순으로 진행합니다.

예제 command 목적
Command결과
`@stats_create - /100`전체 device에 100개 area 생성
`@stats_set_aux 0 foo\\ bar\\ baz`Region 0에 aux string 저장
`@stats_list`등록 region과 metadata 표시
`@stats_print 0`Region 0의 area counter 출력
`@stats_delete 0`Region 0 삭제

각 dmsetup message가 statistics region에 수행하는 작업입니다.