← Documents Documentation/RCU/torture.rst GitHub 원문 ↗

Linux 6.18.37 · RCU

RCU torture test 운용

rcutorture 통계와 오류 지표를 읽고 kvm.sh, kvm-again.sh, kvm-remote.sh로 시험을 자동화하는 방법을 정리합니다.

Source pathDocumentation/RCU/torture.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

torture.rst:1-374

rcutorture 통계와 오류 지표를 읽고 kvm.sh, kvm-again.sh, kvm-remote.sh로 시험을 자동화하는 방법을 정리합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ==========================
4 RCU Torture Test Operation
5 ==========================
6
7
8 CONFIG_RCU_TORTURE_TEST
9 =======================
10
11 The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
12 implementations. It creates an rcutorture kernel module that can
13 be loaded to run a torture test. The test periodically outputs
14 status messages via printk(), which can be examined via the dmesg
15 command (perhaps grepping for "torture"). The test is started
16 when the module is loaded, and stops when the module is unloaded.
17
18 Module parameters are prefixed by "rcutorture." in
19 Documentation/admin-guide/kernel-parameters.txt.
20
21 Output
22 ======
23
24 The statistics output is as follows::
25
26 rcu-torture:--- Start of test: nreaders=16 nfakewriters=4 stat_interval=30 verbose=0 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4
27 rcu-torture: rtc: (null) ver: 155441 tfle: 0 rta: 155441 rtaf: 8884 rtf: 155440 rtmbe: 0 rtbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 3055767
28 rcu-torture: Reader Pipe: 727860534 34213 0 0 0 0 0 0 0 0 0
29 rcu-torture: Reader Batch: 727877838 17003 0 0 0 0 0 0 0 0 0
30 rcu-torture: Free-Block Circulation: 155440 155440 155440 155440 155440 155440 155440 155440 155440 155440 0
31 rcu-torture:--- End of test: SUCCESS: nreaders=16 nfakewriters=4 stat_interval=30 verbose=0 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4
32
33 The command "dmesg | grep torture:" will extract this information on
34 most systems. On more esoteric configurations, it may be necessary to
35 use other commands to access the output of the printk()s used by
36 the RCU torture test. The printk()s use KERN_ALERT, so they should
37 be evident. ;-)
38
39 The first and last lines show the rcutorture module parameters, and the
40 last line shows either "SUCCESS" or "FAILURE", based on rcutorture's
41 automatic determination as to whether RCU operated correctly.
42
43 The entries are as follows:
44
45 * "rtc": The hexadecimal address of the structure currently visible
46 to readers.
47
48 * "ver": The number of times since boot that the RCU writer task
49 has changed the structure visible to readers.
50
51 * "tfle": If non-zero, indicates that the "torture freelist"
52 containing structures to be placed into the "rtc" area is empty.
53 This condition is important, since it can fool you into thinking
54 that RCU is working when it is not. :-/
55
56 * "rta": Number of structures allocated from the torture freelist.
57
58 * "rtaf": Number of allocations from the torture freelist that have
59 failed due to the list being empty. It is not unusual for this
60 to be non-zero, but it is bad for it to be a large fraction of
61 the value indicated by "rta".
62
63 * "rtf": Number of frees into the torture freelist.
64
65 * "rtmbe": A non-zero value indicates that rcutorture believes that
66 rcu_assign_pointer() and rcu_dereference() are not working
67 correctly. This value should be zero.
68
69 * "rtbe": A non-zero value indicates that one of the rcu_barrier()
70 family of functions is not working correctly.
71
72 * "rtbke": rcutorture was unable to create the real-time kthreads
73 used to force RCU priority inversion. This value should be zero.
74
75 * "rtbre": Although rcutorture successfully created the kthreads
76 used to force RCU priority inversion, it was unable to set them
77 to the real-time priority level of 1. This value should be zero.
78
79 * "rtbf": The number of times that RCU priority boosting failed
80 to resolve RCU priority inversion.
81
82 * "rtb": The number of times that rcutorture attempted to force
83 an RCU priority inversion condition. If you are testing RCU
84 priority boosting via the "test_boost" module parameter, this
85 value should be non-zero.
86
87 * "nt": The number of times rcutorture ran RCU read-side code from
88 within a timer handler. This value should be non-zero only
89 if you specified the "irqreader" module parameter.
90
91 * "Reader Pipe": Histogram of "ages" of structures seen by readers.
92 If any entries past the first two are non-zero, RCU is broken.
93 And rcutorture prints the error flag string "!!!" to make sure
94 you notice. The age of a newly allocated structure is zero,
95 it becomes one when removed from reader visibility, and is
96 incremented once per grace period subsequently -- and is freed
97 after passing through (RCU_TORTURE_PIPE_LEN-2) grace periods.
98
99 The output displayed above was taken from a correctly working
100 RCU. If you want to see what it looks like when broken, break
101 it yourself. ;-)
102
103 * "Reader Batch": Another histogram of "ages" of structures seen
104 by readers, but in terms of counter flips (or batches) rather
105 than in terms of grace periods. The legal number of non-zero
106 entries is again two. The reason for this separate view is that
107 it is sometimes easier to get the third entry to show up in the
108 "Reader Batch" list than in the "Reader Pipe" list.
109
110 * "Free-Block Circulation": Shows the number of torture structures
111 that have reached a given point in the pipeline. The first element
112 should closely correspond to the number of structures allocated,
113 the second to the number that have been removed from reader view,
114 and all but the last remaining to the corresponding number of
115 passes through a grace period. The last entry should be zero,
116 as it is only incremented if a torture structure's counter
117 somehow gets incremented farther than it should.
118
119 Different implementations of RCU can provide implementation-specific
120 additional information. For example, Tree SRCU provides the following
121 additional line::
122
123 srcud-torture: Tree SRCU per-CPU(idx=0): 0(35,-21) 1(-4,24) 2(1,1) 3(-26,20) 4(28,-47) 5(-9,4) 6(-10,14) 7(-14,11) T(1,6)
124
125 This line shows the per-CPU counter state, in this case for Tree SRCU
126 using a dynamically allocated srcu_struct (hence "srcud-" rather than
127 "srcu-"). The numbers in parentheses are the values of the "old" and
128 "current" counters for the corresponding CPU. The "idx" value maps the
129 "old" and "current" values to the underlying array, and is useful for
130 debugging. The final "T" entry contains the totals of the counters.
131
132 Usage on Specific Kernel Builds
133 ===============================
134
135 It is sometimes desirable to torture RCU on a specific kernel build,
136 for example, when preparing to put that kernel build into production.
137 In that case, the kernel should be built with CONFIG_RCU_TORTURE_TEST=m
138 so that the test can be started using modprobe and terminated using rmmod.
139
140 For example, the following script may be used to torture RCU::
141
142 #!/bin/sh
143
144 modprobe rcutorture
145 sleep 3600
146 rmmod rcutorture
147 dmesg | grep torture:
148
149 The output can be manually inspected for the error flag of "!!!".
150 One could of course create a more elaborate script that automatically
151 checked for such errors. The "rmmod" command forces a "SUCCESS",
152 "FAILURE", or "RCU_HOTPLUG" indication to be printk()ed. The first
153 two are self-explanatory, while the last indicates that while there
154 were no RCU failures, CPU-hotplug problems were detected.
155
156
157 Usage on Mainline Kernels
158 =========================
159
160 When using rcutorture to test changes to RCU itself, it is often
161 necessary to build a number of kernels in order to test that change
162 across a broad range of combinations of the relevant Kconfig options
163 and of the relevant kernel boot parameters. In this situation, use
164 of modprobe and rmmod can be quite time-consuming and error-prone.
165
166 Therefore, the tools/testing/selftests/rcutorture/bin/kvm.sh
167 script is available for mainline testing for x86, arm64, and
168 powerpc. By default, it will run the series of tests specified by
169 tools/testing/selftests/rcutorture/configs/rcu/CFLIST, with each test
170 running for 30 minutes within a guest OS using a minimal userspace
171 supplied by an automatically generated initrd. After the tests are
172 complete, the resulting build products and console output are analyzed
173 for errors and the results of the runs are summarized.
174
175 On larger systems, rcutorture testing can be accelerated by passing the
176 --cpus argument to kvm.sh. For example, on a 64-CPU system, "--cpus 43"
177 would use up to 43 CPUs to run tests concurrently, which as of v5.4 would
178 complete all the scenarios in two batches, reducing the time to complete
179 from about eight hours to about one hour (not counting the time to build
180 the sixteen kernels). The "--dryrun sched" argument will not run tests,
181 but rather tell you how the tests would be scheduled into batches. This
182 can be useful when working out how many CPUs to specify in the --cpus
183 argument.
184
185 Not all changes require that all scenarios be run. For example, a change
186 to Tree SRCU might run only the SRCU-N and SRCU-P scenarios using the
187 --configs argument to kvm.sh as follows: "--configs 'SRCU-N SRCU-P'".
188 Large systems can run multiple copies of the full set of scenarios,
189 for example, a system with 448 hardware threads can run five instances
190 of the full set concurrently. To make this happen::
191
192 kvm.sh --cpus 448 --configs '5*CFLIST'
193
194 Alternatively, such a system can run 56 concurrent instances of a single
195 eight-CPU scenario::
196
197 kvm.sh --cpus 448 --configs '56*TREE04'
198
199 Or 28 concurrent instances of each of two eight-CPU scenarios::
200
201 kvm.sh --cpus 448 --configs '28*TREE03 28*TREE04'
202
203 Of course, each concurrent instance will use memory, which can be
204 limited using the --memory argument, which defaults to 512M. Small
205 values for memory may require disabling the callback-flooding tests
206 using the --bootargs parameter discussed below.
207
208 Sometimes additional debugging is useful, and in such cases the --kconfig
209 parameter to kvm.sh may be used, for example, ``--kconfig 'CONFIG_RCU_EQS_DEBUG=y'``.
210 In addition, there are the --gdb, --kasan, and --kcsan parameters.
211 Note that --gdb limits you to one scenario per kvm.sh run and requires
212 that you have another window open from which to run ``gdb`` as instructed
213 by the script.
214
215 Kernel boot arguments can also be supplied, for example, to control
216 rcutorture's module parameters. For example, to test a change to RCU's
217 CPU stall-warning code, use "--bootargs 'rcutorture.stall_cpu=30'".
218 This will of course result in the scripting reporting a failure, namely
219 the resulting RCU CPU stall warning. As noted above, reducing memory may
220 require disabling rcutorture's callback-flooding tests::
221
222 kvm.sh --cpus 448 --configs '56*TREE04' --memory 128M \
223 --bootargs 'rcutorture.fwd_progress=0'
224
225 Sometimes all that is needed is a full set of kernel builds. This is
226 what the --buildonly parameter does.
227
228 The --duration parameter can override the default run time of 30 minutes.
229 For example, ``--duration 2d`` would run for two days, ``--duration 3h``
230 would run for three hours, ``--duration 5m`` would run for five minutes,
231 and ``--duration 45s`` would run for 45 seconds. This last can be useful
232 for tracking down rare boot-time failures.
233
234 Finally, the --trust-make parameter allows each kernel build to reuse what
235 it can from the previous kernel build. Please note that without the
236 --trust-make parameter, your tags files may be demolished.
237
238 There are additional more arcane arguments that are documented in the
239 source code of the kvm.sh script.
240
241 If a run contains failures, the number of buildtime and runtime failures
242 is listed at the end of the kvm.sh output, which you really should redirect
243 to a file. The build products and console output of each run is kept in
244 tools/testing/selftests/rcutorture/res in timestamped directories. A
245 given directory can be supplied to kvm-find-errors.sh in order to have
246 it cycle you through summaries of errors and full error logs. For example::
247
248 tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh \
249 tools/testing/selftests/rcutorture/res/2020.01.20-15.54.23
250
251 However, it is often more convenient to access the files directly.
252 Files pertaining to all scenarios in a run reside in the top-level
253 directory (2020.01.20-15.54.23 in the example above), while per-scenario
254 files reside in a subdirectory named after the scenario (for example,
255 "TREE04"). If a given scenario ran more than once (as in "--configs
256 '56*TREE04'" above), the directories corresponding to the second and
257 subsequent runs of that scenario include a sequence number, for example,
258 "TREE04.2", "TREE04.3", and so on.
259
260 The most frequently used file in the top-level directory is testid.txt.
261 If the test ran in a git repository, then this file contains the commit
262 that was tested and any uncommitted changes in diff format.
263
264 The most frequently used files in each per-scenario-run directory are:
265
266 .config:
267 This file contains the Kconfig options.
268
269 Make.out:
270 This contains build output for a specific scenario.
271
272 console.log:
273 This contains the console output for a specific scenario.
274 This file may be examined once the kernel has booted, but
275 it might not exist if the build failed.
276
277 vmlinux:
278 This contains the kernel, which can be useful with tools like
279 objdump and gdb.
280
281 A number of additional files are available, but are less frequently used.
282 Many are intended for debugging of rcutorture itself or of its scripting.
283
284 As of v5.4, a successful run with the default set of scenarios produces
285 the following summary at the end of the run on a 12-CPU system::
286
287 SRCU-N ------- 804233 GPs (148.932/s) [srcu: g10008272 f0x0 ]
288 SRCU-P ------- 202320 GPs (37.4667/s) [srcud: g1809476 f0x0 ]
289 SRCU-t ------- 1122086 GPs (207.794/s) [srcu: g0 f0x0 ]
290 SRCU-u ------- 1111285 GPs (205.794/s) [srcud: g1 f0x0 ]
291 TASKS01 ------- 19666 GPs (3.64185/s) [tasks: g0 f0x0 ]
292 TASKS02 ------- 20541 GPs (3.80389/s) [tasks: g0 f0x0 ]
293 TASKS03 ------- 19416 GPs (3.59556/s) [tasks: g0 f0x0 ]
294 TINY01 ------- 836134 GPs (154.84/s) [rcu: g0 f0x0 ] n_max_cbs: 34198
295 TINY02 ------- 850371 GPs (157.476/s) [rcu: g0 f0x0 ] n_max_cbs: 2631
296 TREE01 ------- 162625 GPs (30.1157/s) [rcu: g1124169 f0x0 ]
297 TREE02 ------- 333003 GPs (61.6672/s) [rcu: g2647753 f0x0 ] n_max_cbs: 35844
298 TREE03 ------- 306623 GPs (56.782/s) [rcu: g2975325 f0x0 ] n_max_cbs: 1496497
299 CPU count limited from 16 to 12
300 TREE04 ------- 246149 GPs (45.5831/s) [rcu: g1695737 f0x0 ] n_max_cbs: 434961
301 TREE05 ------- 314603 GPs (58.2598/s) [rcu: g2257741 f0x2 ] n_max_cbs: 193997
302 TREE07 ------- 167347 GPs (30.9902/s) [rcu: g1079021 f0x0 ] n_max_cbs: 478732
303 CPU count limited from 16 to 12
304 TREE09 ------- 752238 GPs (139.303/s) [rcu: g13075057 f0x0 ] n_max_cbs: 99011
305
306
307 Repeated Runs
308 =============
309
310 Suppose that you are chasing down a rare boot-time failure. Although you
311 could use kvm.sh, doing so will rebuild the kernel on each run. If you
312 need (say) 1,000 runs to have confidence that you have fixed the bug,
313 these pointless rebuilds can become extremely annoying.
314
315 This is why kvm-again.sh exists.
316
317 Suppose that a previous kvm.sh run left its output in this directory::
318
319 tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28
320
321 Then this run can be re-run without rebuilding as follow::
322
323 kvm-again.sh tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28
324
325 A few of the original run's kvm.sh parameters may be overridden, perhaps
326 most notably --duration and --bootargs. For example::
327
328 kvm-again.sh tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28 \
329 --duration 45s
330
331 would re-run the previous test, but for only 45 seconds, thus facilitating
332 tracking down the aforementioned rare boot-time failure.
333
334
335 Distributed Runs
336 ================
337
338 Although kvm.sh is quite useful, its testing is confined to a single
339 system. It is not all that hard to use your favorite framework to cause
340 (say) 5 instances of kvm.sh to run on your 5 systems, but this will very
341 likely unnecessarily rebuild kernels. In addition, manually distributing
342 the desired rcutorture scenarios across the available systems can be
343 painstaking and error-prone.
344
345 And this is why the kvm-remote.sh script exists.
346
347 If the following command works::
348
349 ssh system0 date
350
351 and if it also works for system1, system2, system3, system4, and system5,
352 and all of these systems have 64 CPUs, you can type::
353
354 kvm-remote.sh "system0 system1 system2 system3 system4 system5" \
355 --cpus 64 --duration 8h --configs "5*CFLIST"
356
357 This will build each default scenario's kernel on the local system, then
358 spread each of five instances of each scenario over the systems listed,
359 running each scenario for eight hours. At the end of the runs, the
360 results will be gathered, recorded, and printed. Most of the parameters
361 that kvm.sh will accept can be passed to kvm-remote.sh, but the list of
362 systems must come first.
363
364 The kvm.sh ``--dryrun scenarios`` argument is useful for working out
365 how many scenarios may be run in one batch across a group of systems.
366
367 You can also re-run a previous remote run in a manner similar to kvm.sh::
368
369 kvm-remote.sh "system0 system1 system2 system3 system4 system5" \
370 tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28-remote \
371 --duration 24h
372
373 In this case, most of the kvm-again.sh parameters may be supplied following
374 the pathname of the old run-results directory.
375

3. 한국어 전문 번역

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

rcutorture 실행과 통계 출력

1-130

`CONFIG_RCU_TORTURE_TEST`는 모든 RCU 구현에서 사용할 수 있으며 `rcutorture` kernel module을 만든다. module을 load하면 시험이 시작되고 unload하면 끝난다. 상태는 `printk()`로 주기적으로 나오며 보통 `dmesg | grep torture:`로 찾는다. module parameter는 `Documentation/admin-guide/kernel-parameters.txt`에서 `rcutorture.` 접두사로 정리되어 있다.

첫 줄과 마지막 줄은 reader, fake writer, 통계 주기, shuffle, stutter, IRQ reader, FQS, priority boost 같은 parameter를 보여 준다. 마지막 줄의 `SUCCESS` 또는 `FAILURE`는 rcutorture의 자동 판정이다.

`rtc`는 독자에게 현재 보이는 구조체 주소, `ver`는 writer가 가시 구조체를 바꾼 횟수다. `tfle`는 torture freelist가 비었음을 뜻하며 0이 아니면 RCU가 고장인데도 정상처럼 보이게 할 수 있다. `rta`는 할당 수, `rtaf`는 빈 목록 때문에 실패한 할당 수, `rtf`는 freelist로 반환한 수다. `rtaf` 자체가 0이 아닐 수는 있지만 `rta`의 큰 비율이면 문제다.

`rtmbe`는 `rcu_assign_pointer()`/`rcu_dereference()` 오류, `rtbe`는 `rcu_barrier()` 계열 오류를 뜻하므로 둘 다 0이어야 한다. `rtbke`와 `rtbre`는 priority inversion 유도용 realtime kthread 생성 또는 우선순위 설정 실패, `rtbf`는 priority boosting 실패 횟수다. `rtb`는 역전 유도 시도 수로 `test_boost` 시험에서는 0이 아니어야 한다. `nt`는 timer handler 안에서 RCU read-side code를 실행한 횟수이며 `irqreader`를 지정했을 때만 0이 아니어야 한다.

`Reader Pipe`는 독자가 본 구조체 나이의 histogram이다. 새 객체는 0, 독자 가시성에서 제거되면 1, 이후 GP마다 증가하고 파이프 끝 전에 해제된다. 첫 두 항목 이후가 0이 아니면 RCU가 깨진 것이며 `!!!`가 출력된다. `Reader Batch`는 같은 현상을 GP 대신 counter flip 또는 batch 기준으로 보여 주며 역시 0이 아닌 항목은 두 개까지만 정상이다.

`Free-Block Circulation`은 torture 구조체가 파이프 각 지점에 도달한 수다. 첫 값은 할당 수, 둘째는 가시성에서 제거된 수, 이후는 GP 통과 수에 가까워야 하고 마지막 값은 항상 0이어야 한다. Tree SRCU의 추가 줄은 CPU별 old/current counter, 배열에 매핑하는 `idx`, 마지막 총합 `T`를 보여 준다.

오류 지표
필드의미정상 기대
tfletorture freelist 고갈0
rtmbepointer 게시/역참조 오류0
rtbebarrier 계열 오류0
rtbke/rtbreRT kthread 준비 실패0
rtbfpriority boost 실패0
rtbpriority inversion 시도test_boost이면 0 아님
nttimer RCU readirqreader일 때만 0 아님

정상 실행에서 0이어야 하거나 특정 조건에서만 증가해야 하는 값을 우선 확인한다.

.. SPDX-License-Identifier: GPL-2.0

==========================
RCU Torture Test Operation
==========================


CONFIG_RCU_TORTURE_TEST
=======================

The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
implementations.  It creates an rcutorture kernel module that can
be loaded to run a torture test.  The test periodically outputs
status messages via printk(), which can be examined via the dmesg
command (perhaps grepping for "torture").  The test is started
when the module is loaded, and stops when the module is unloaded.

Module parameters are prefixed by "rcutorture." in
Documentation/admin-guide/kernel-parameters.txt.

Output
======

The statistics output is as follows::

        rcu-torture:--- Start of test: nreaders=16 nfakewriters=4 stat_interval=30 verbose=0 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4
        rcu-torture: rtc:           (null) ver: 155441 tfle: 0 rta: 155441 rtaf: 8884 rtf: 155440 rtmbe: 0 rtbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 3055767
        rcu-torture: Reader Pipe:  727860534 34213 0 0 0 0 0 0 0 0 0
        rcu-torture: Reader Batch:  727877838 17003 0 0 0 0 0 0 0 0 0
        rcu-torture: Free-Block Circulation:  155440 155440 155440 155440 155440 155440 155440 155440 155440 155440 0
        rcu-torture:--- End of test: SUCCESS: nreaders=16 nfakewriters=4 stat_interval=30 verbose=0 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4

The command "dmesg | grep torture:" will extract this information on
most systems.  On more esoteric configurations, it may be necessary to
use other commands to access the output of the printk()s used by
the RCU torture test.  The printk()s use KERN_ALERT, so they should
be evident.  ;-)

The first and last lines show the rcutorture module parameters, and the
last line shows either "SUCCESS" or "FAILURE", based on rcutorture's
automatic determination as to whether RCU operated correctly.

The entries are as follows:

*        "rtc": The hexadecimal address of the structure currently visible
        to readers.

*        "ver": The number of times since boot that the RCU writer task
        has changed the structure visible to readers.

*        "tfle": If non-zero, indicates that the "torture freelist"
        containing structures to be placed into the "rtc" area is empty.
        This condition is important, since it can fool you into thinking
        that RCU is working when it is not.  :-/

*        "rta": Number of structures allocated from the torture freelist.

*        "rtaf": Number of allocations from the torture freelist that have
        failed due to the list being empty.  It is not unusual for this
        to be non-zero, but it is bad for it to be a large fraction of
        the value indicated by "rta".

*        "rtf": Number of frees into the torture freelist.

*        "rtmbe": A non-zero value indicates that rcutorture believes that
        rcu_assign_pointer() and rcu_dereference() are not working
        correctly.  This value should be zero.

*        "rtbe": A non-zero value indicates that one of the rcu_barrier()
        family of functions is not working correctly.

*        "rtbke": rcutorture was unable to create the real-time kthreads
        used to force RCU priority inversion.  This value should be zero.

*        "rtbre": Although rcutorture successfully created the kthreads
        used to force RCU priority inversion, it was unable to set them
        to the real-time priority level of 1.  This value should be zero.

*        "rtbf": The number of times that RCU priority boosting failed
        to resolve RCU priority inversion.

*        "rtb": The number of times that rcutorture attempted to force
        an RCU priority inversion condition.  If you are testing RCU
        priority boosting via the "test_boost" module parameter, this
        value should be non-zero.

*        "nt": The number of times rcutorture ran RCU read-side code from
        within a timer handler.  This value should be non-zero only
        if you specified the "irqreader" module parameter.

*        "Reader Pipe": Histogram of "ages" of structures seen by readers.
        If any entries past the first two are non-zero, RCU is broken.
        And rcutorture prints the error flag string "!!!" to make sure
        you notice.  The age of a newly allocated structure is zero,
        it becomes one when removed from reader visibility, and is
        incremented once per grace period subsequently -- and is freed
        after passing through (RCU_TORTURE_PIPE_LEN-2) grace periods.

        The output displayed above was taken from a correctly working
        RCU.  If you want to see what it looks like when broken, break
        it yourself.  ;-)

*        "Reader Batch": Another histogram of "ages" of structures seen
        by readers, but in terms of counter flips (or batches) rather
        than in terms of grace periods.  The legal number of non-zero
        entries is again two.  The reason for this separate view is that
        it is sometimes easier to get the third entry to show up in the
        "Reader Batch" list than in the "Reader Pipe" list.

*        "Free-Block Circulation": Shows the number of torture structures
        that have reached a given point in the pipeline.  The first element
        should closely correspond to the number of structures allocated,
        the second to the number that have been removed from reader view,
        and all but the last remaining to the corresponding number of
        passes through a grace period.  The last entry should be zero,
        as it is only incremented if a torture structure's counter
        somehow gets incremented farther than it should.

Different implementations of RCU can provide implementation-specific
additional information.  For example, Tree SRCU provides the following
additional line::

        srcud-torture: Tree SRCU per-CPU(idx=0): 0(35,-21) 1(-4,24) 2(1,1) 3(-26,20) 4(28,-47) 5(-9,4) 6(-10,14) 7(-14,11) T(1,6)

This line shows the per-CPU counter state, in this case for Tree SRCU
using a dynamically allocated srcu_struct (hence "srcud-" rather than
"srcu-").  The numbers in parentheses are the values of the "old" and
"current" counters for the corresponding CPU.  The "idx" value maps the
"old" and "current" values to the underlying array, and is useful for
debugging.  The final "T" entry contains the totals of the counters.

특정 커널 빌드 시험

131-156

제품 투입 전처럼 특정 커널 빌드를 시험하려면 `CONFIG_RCU_TORTURE_TEST=m`으로 빌드해 `modprobe rcutorture`, 대기, `rmmod rcutorture` 순서로 실행할 수 있다. 예제는 한 시간 동안 실행한 뒤 dmesg의 torture 줄을 추출한다.

출력의 `!!!`를 수동 또는 script로 검사한다. `rmmod`는 최종 `SUCCESS`, `FAILURE`, `RCU_HOTPLUG` 중 하나를 출력하게 한다. `RCU_HOTPLUG`는 RCU 자체 실패는 없었지만 CPU hotplug 문제가 감지되었다는 뜻이다.

단일 빌드 시험
CONFIG_RCU_TORTURE_TEST=mmodprobe rcutorture지정 시간 실행rmmod rcutorturedmesg에서 결과 확인

module 수명과 시험 수명이 일치한다.


Usage on Specific Kernel Builds
===============================

It is sometimes desirable to torture RCU on a specific kernel build,
for example, when preparing to put that kernel build into production.
In that case, the kernel should be built with CONFIG_RCU_TORTURE_TEST=m
so that the test can be started using modprobe and terminated using rmmod.

For example, the following script may be used to torture RCU::

        #!/bin/sh

        modprobe rcutorture
        sleep 3600
        rmmod rcutorture
        dmesg | grep torture:

The output can be manually inspected for the error flag of "!!!".
One could of course create a more elaborate script that automatically
checked for such errors.  The "rmmod" command forces a "SUCCESS",
"FAILURE", or "RCU_HOTPLUG" indication to be printk()ed.  The first
two are self-explanatory, while the last indicates that while there
were no RCU failures, CPU-hotplug problems were detected.

mainline kvm.sh 시험 구성

157-239

RCU 자체 변경은 Kconfig와 boot parameter 조합이 많아 module을 수동으로 반복하는 방식이 느리고 오류가 나기 쉽다. `tools/testing/selftests/rcutorture/bin/kvm.sh`는 x86, arm64, powerpc에서 mainline 시험을 자동화한다. 기본으로 `configs/rcu/CFLIST`의 시나리오를 각각 최소 userspace initrd를 쓰는 guest에서 30분 실행하고 build 결과와 console output을 분석한다.

큰 시스템에서는 `--cpus`로 시나리오를 병렬화하고 `--dryrun sched`로 batch 배치를 미리 본다. `--configs 'SRCU-N SRCU-P'`처럼 필요한 시나리오만 고르거나 `5*CFLIST`, `56*TREE04`, `28*TREE03 28*TREE04`처럼 복제 수를 지정할 수 있다.

각 동시 실행은 메모리를 사용하며 `--memory` 기본값은 512M이다. 메모리를 줄이면 `--bootargs 'rcutorture.fwd_progress=0'`처럼 callback flooding을 꺼야 할 수 있다. 추가 진단에는 `--kconfig`, `--gdb`, `--kasan`, `--kcsan`이 있으며 `--gdb`는 한 번에 한 시나리오만 허용하고 별도 창에서 gdb를 실행해야 한다.

`--bootargs`로 `rcutorture.stall_cpu=30` 같은 시험을 주입할 수 있으며 의도된 stall 경고 때문에 자동화가 실패로 보고할 수 있다. `--buildonly`는 빌드만, `--duration`은 `2d`, `3h`, `5m`, `45s`처럼 실행 시간을 바꾼다. `--trust-make`는 이전 빌드 산출물을 재사용하지만, 이 옵션이 없으면 tags 파일이 사라질 수 있다.

kvm.sh 주요 선택
옵션용도
--cpus동시 실행 CPU 한도--cpus 43
--configs시나리오와 복제 수56*TREE04
--memoryguest별 메모리128M
--bootargsrcutorture parameterstall_cpu=30
--duration실행 시간45s
--kconfig추가 kernel 설정RCU_EQS_DEBUG=y
--buildonly실행 없이 빌드전체 build 점검

시험 범위, 병렬도, 자원, 진단 기능을 각각 독립적으로 조정한다.

Usage on Mainline Kernels
=========================

When using rcutorture to test changes to RCU itself, it is often
necessary to build a number of kernels in order to test that change
across a broad range of combinations of the relevant Kconfig options
and of the relevant kernel boot parameters.  In this situation, use
of modprobe and rmmod can be quite time-consuming and error-prone.

Therefore, the tools/testing/selftests/rcutorture/bin/kvm.sh
script is available for mainline testing for x86, arm64, and
powerpc.  By default, it will run the series of tests specified by
tools/testing/selftests/rcutorture/configs/rcu/CFLIST, with each test
running for 30 minutes within a guest OS using a minimal userspace
supplied by an automatically generated initrd.  After the tests are
complete, the resulting build products and console output are analyzed
for errors and the results of the runs are summarized.

On larger systems, rcutorture testing can be accelerated by passing the
--cpus argument to kvm.sh.  For example, on a 64-CPU system, "--cpus 43"
would use up to 43 CPUs to run tests concurrently, which as of v5.4 would
complete all the scenarios in two batches, reducing the time to complete
from about eight hours to about one hour (not counting the time to build
the sixteen kernels).  The "--dryrun sched" argument will not run tests,
but rather tell you how the tests would be scheduled into batches.  This
can be useful when working out how many CPUs to specify in the --cpus
argument.

Not all changes require that all scenarios be run.  For example, a change
to Tree SRCU might run only the SRCU-N and SRCU-P scenarios using the
--configs argument to kvm.sh as follows:  "--configs 'SRCU-N SRCU-P'".
Large systems can run multiple copies of the full set of scenarios,
for example, a system with 448 hardware threads can run five instances
of the full set concurrently.  To make this happen::

        kvm.sh --cpus 448 --configs '5*CFLIST'

Alternatively, such a system can run 56 concurrent instances of a single
eight-CPU scenario::

        kvm.sh --cpus 448 --configs '56*TREE04'

Or 28 concurrent instances of each of two eight-CPU scenarios::

        kvm.sh --cpus 448 --configs '28*TREE03 28*TREE04'

Of course, each concurrent instance will use memory, which can be
limited using the --memory argument, which defaults to 512M.  Small
values for memory may require disabling the callback-flooding tests
using the --bootargs parameter discussed below.

Sometimes additional debugging is useful, and in such cases the --kconfig
parameter to kvm.sh may be used, for example, ``--kconfig 'CONFIG_RCU_EQS_DEBUG=y'``.
In addition, there are the --gdb, --kasan, and --kcsan parameters.
Note that --gdb limits you to one scenario per kvm.sh run and requires
that you have another window open from which to run ``gdb`` as instructed
by the script.

Kernel boot arguments can also be supplied, for example, to control
rcutorture's module parameters.  For example, to test a change to RCU's
CPU stall-warning code, use "--bootargs 'rcutorture.stall_cpu=30'".
This will of course result in the scripting reporting a failure, namely
the resulting RCU CPU stall warning.  As noted above, reducing memory may
require disabling rcutorture's callback-flooding tests::

        kvm.sh --cpus 448 --configs '56*TREE04' --memory 128M \
                --bootargs 'rcutorture.fwd_progress=0'

Sometimes all that is needed is a full set of kernel builds.  This is
what the --buildonly parameter does.

The --duration parameter can override the default run time of 30 minutes.
For example, ``--duration 2d`` would run for two days, ``--duration 3h``
would run for three hours, ``--duration 5m`` would run for five minutes,
and ``--duration 45s`` would run for 45 seconds.  This last can be useful
for tracking down rare boot-time failures.

Finally, the --trust-make parameter allows each kernel build to reuse what
it can from the previous kernel build.  Please note that without the
--trust-make parameter, your tags files may be demolished.

There are additional more arcane arguments that are documented in the
source code of the kvm.sh script.

결과 디렉터리와 요약 읽기

240-306

실패가 있으면 `kvm.sh` 마지막에 build-time과 runtime 실패 수가 나온다. 전체 출력은 파일로 redirect하는 편이 좋다. 산출물은 `tools/testing/selftests/rcutorture/res` 아래 timestamp 디렉터리에 저장되고, 해당 경로를 `kvm-find-errors.sh`에 넘기면 오류 요약과 전체 log를 차례로 볼 수 있다.

최상위에는 전체 시나리오 파일과 `testid.txt`가 있다. git 저장소에서 실행했다면 `testid.txt`에 시험 commit과 미커밋 diff가 기록된다. 시나리오별 하위 디렉터리는 `TREE04`처럼 이름 붙고 반복 실행은 `TREE04.2`, `TREE04.3`처럼 sequence가 붙는다.

각 시나리오의 `.config`는 Kconfig, `Make.out`은 build output, `console.log`는 guest console, `vmlinux`는 `objdump`와 gdb에 사용할 kernel image다. build가 실패하면 `console.log`가 없을 수 있다.

성공 요약은 시나리오별 grace period 완료 수와 초당 처리율, 내부 flavor 상태, 최대 callback 수 등을 보여 준다. `CPU count limited`는 시나리오 요구 CPU가 호스트에서 제공한 한도로 줄었음을 뜻한다. 이 수치들은 성능 경쟁이 아니라 해당 구성에서 충분한 진행과 오류 없는 완료를 확인하는 기준으로 읽는다.

실패 결과 조사
kvm.sh 출력 저장실패 수 확인timestamp 디렉터리 선택kvm-find-errors.sh시나리오 .config 확인Make.out과 console.log 분석

요약에서 실패 시나리오를 찾고 해당 디렉터리의 구성과 console을 함께 본다.


If a run contains failures, the number of buildtime and runtime failures
is listed at the end of the kvm.sh output, which you really should redirect
to a file.  The build products and console output of each run is kept in
tools/testing/selftests/rcutorture/res in timestamped directories.  A
given directory can be supplied to kvm-find-errors.sh in order to have
it cycle you through summaries of errors and full error logs.  For example::

        tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh \
                tools/testing/selftests/rcutorture/res/2020.01.20-15.54.23

However, it is often more convenient to access the files directly.
Files pertaining to all scenarios in a run reside in the top-level
directory (2020.01.20-15.54.23 in the example above), while per-scenario
files reside in a subdirectory named after the scenario (for example,
"TREE04").  If a given scenario ran more than once (as in "--configs
'56*TREE04'" above), the directories corresponding to the second and
subsequent runs of that scenario include a sequence number, for example,
"TREE04.2", "TREE04.3", and so on.

The most frequently used file in the top-level directory is testid.txt.
If the test ran in a git repository, then this file contains the commit
that was tested and any uncommitted changes in diff format.

The most frequently used files in each per-scenario-run directory are:

.config:
        This file contains the Kconfig options.

Make.out:
        This contains build output for a specific scenario.

console.log:
        This contains the console output for a specific scenario.
        This file may be examined once the kernel has booted, but
        it might not exist if the build failed.

vmlinux:
        This contains the kernel, which can be useful with tools like
        objdump and gdb.

A number of additional files are available, but are less frequently used.
Many are intended for debugging of rcutorture itself or of its scripting.

As of v5.4, a successful run with the default set of scenarios produces
the following summary at the end of the run on a 12-CPU system::

    SRCU-N ------- 804233 GPs (148.932/s) [srcu: g10008272 f0x0 ]
    SRCU-P ------- 202320 GPs (37.4667/s) [srcud: g1809476 f0x0 ]
    SRCU-t ------- 1122086 GPs (207.794/s) [srcu: g0 f0x0 ]
    SRCU-u ------- 1111285 GPs (205.794/s) [srcud: g1 f0x0 ]
    TASKS01 ------- 19666 GPs (3.64185/s) [tasks: g0 f0x0 ]
    TASKS02 ------- 20541 GPs (3.80389/s) [tasks: g0 f0x0 ]
    TASKS03 ------- 19416 GPs (3.59556/s) [tasks: g0 f0x0 ]
    TINY01 ------- 836134 GPs (154.84/s) [rcu: g0 f0x0 ] n_max_cbs: 34198
    TINY02 ------- 850371 GPs (157.476/s) [rcu: g0 f0x0 ] n_max_cbs: 2631
    TREE01 ------- 162625 GPs (30.1157/s) [rcu: g1124169 f0x0 ]
    TREE02 ------- 333003 GPs (61.6672/s) [rcu: g2647753 f0x0 ] n_max_cbs: 35844
    TREE03 ------- 306623 GPs (56.782/s) [rcu: g2975325 f0x0 ] n_max_cbs: 1496497
    CPU count limited from 16 to 12
    TREE04 ------- 246149 GPs (45.5831/s) [rcu: g1695737 f0x0 ] n_max_cbs: 434961
    TREE05 ------- 314603 GPs (58.2598/s) [rcu: g2257741 f0x2 ] n_max_cbs: 193997
    TREE07 ------- 167347 GPs (30.9902/s) [rcu: g1079021 f0x0 ] n_max_cbs: 478732
    CPU count limited from 16 to 12
    TREE09 ------- 752238 GPs (139.303/s) [rcu: g13075057 f0x0 ] n_max_cbs: 99011

빌드 재사용 반복 실행

307-334

희귀한 boot-time 실패를 수백 또는 수천 번 재현할 때 매번 kernel을 다시 빌드하는 것은 낭비다. `kvm-again.sh`는 이전 `kvm.sh` 결과 디렉터리의 빌드를 재사용해 같은 시험을 다시 실행한다.

이전 결과 경로를 첫 인수로 주고 실행하며, 원래 parameter 중 `--duration`과 `--bootargs` 등을 일부 덮어쓸 수 있다. 예제의 `--duration 45s`는 같은 build와 구성을 45초만 반복해 드문 부팅 실패를 좁히는 데 적합하다.

반복 재현
기존 kvm.sh 결과 선택kvm-again.sh 실행duration/bootargs 덮어쓰기재현 결과 누적수정 전후 빈도 비교

한 번 검증한 build를 고정하고 실행 횟수와 runtime 조건만 바꾼다.

Repeated Runs
=============

Suppose that you are chasing down a rare boot-time failure.  Although you
could use kvm.sh, doing so will rebuild the kernel on each run.  If you
need (say) 1,000 runs to have confidence that you have fixed the bug,
these pointless rebuilds can become extremely annoying.

This is why kvm-again.sh exists.

Suppose that a previous kvm.sh run left its output in this directory::

        tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28

Then this run can be re-run without rebuilding as follow::

        kvm-again.sh tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28

A few of the original run's kvm.sh parameters may be overridden, perhaps
most notably --duration and --bootargs.  For example::

        kvm-again.sh tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28 \
                --duration 45s

would re-run the previous test, but for only 45 seconds, thus facilitating
tracking down the aforementioned rare boot-time failure.

여러 시스템에 분산 실행

335-374

`kvm.sh`는 한 시스템에 한정되며 여러 호스트에서 각각 실행하면 kernel을 불필요하게 중복 빌드하고 시나리오 배분도 수동 오류가 생긴다. `kvm-remote.sh`는 kernel을 로컬에서 한 번 빌드한 뒤 시나리오 인스턴스를 SSH 가능한 여러 시스템에 분산한다.

예제는 여섯 호스트 각각에 `ssh systemN date`가 동작하고 64 CPU가 있다는 전제에서 `--cpus 64 --duration 8h --configs '5*CFLIST'`를 실행한다. 기본 시나리오를 각각 다섯 인스턴스씩 분산하고 완료 후 결과를 수집·기록·출력한다. 시스템 목록은 다른 인수보다 먼저 와야 한다.

`kvm.sh --dryrun scenarios`로 여러 시스템에서 한 batch에 넣을 시나리오 수를 계산할 수 있다. 이전 remote 결과 경로를 넘기고 `--duration 24h`처럼 `kvm-again.sh`와 비슷하게 재실행하는 것도 가능하다.

분산 rcutorture
모든 호스트 SSH 확인로컬 kernel build시나리오 인스턴스 배분원격 guest 실행결과 회수통합 요약

build는 중앙에서 한 번 수행하고 실행과 결과 수집을 여러 호스트에 배치한다.

Distributed Runs
================

Although kvm.sh is quite useful, its testing is confined to a single
system.  It is not all that hard to use your favorite framework to cause
(say) 5 instances of kvm.sh to run on your 5 systems, but this will very
likely unnecessarily rebuild kernels.  In addition, manually distributing
the desired rcutorture scenarios across the available systems can be
painstaking and error-prone.

And this is why the kvm-remote.sh script exists.

If the following command works::

        ssh system0 date

and if it also works for system1, system2, system3, system4, and system5,
and all of these systems have 64 CPUs, you can type::

        kvm-remote.sh "system0 system1 system2 system3 system4 system5" \
                --cpus 64 --duration 8h --configs "5*CFLIST"

This will build each default scenario's kernel on the local system, then
spread each of five instances of each scenario over the systems listed,
running each scenario for eight hours.  At the end of the runs, the
results will be gathered, recorded, and printed.  Most of the parameters
that kvm.sh will accept can be passed to kvm-remote.sh, but the list of
systems must come first.

The kvm.sh ``--dryrun scenarios`` argument is useful for working out
how many scenarios may be run in one batch across a group of systems.

You can also re-run a previous remote run in a manner similar to kvm.sh::

        kvm-remote.sh "system0 system1 system2 system3 system4 system5" \
                tools/testing/selftests/rcutorture/res/2022.11.03-11.26.28-remote \
                --duration 24h

In this case, most of the kvm-again.sh parameters may be supplied following
the pathname of the old run-results directory.