← Documents Documentation/trace/osnoise-tracer.rst GitHub 원문 ↗

Linux 6.18.37 · Tracing

OSNOISE 트레이서

OSNOISE 트레이서가 NMI·IRQ·SoftIRQ·스레드·하드웨어 잡음을 분류하는 원리, 추적 출력 필드, 주기와 임계값 설정, 순 지속 시간 tracepoint 및 워크로드 없는 측정 방식을 설명합니다.

Source pathDocumentation/trace/osnoise-tracer.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

osnoise-tracer.rst:1-180

OSNOISE 트레이서가 NMI·IRQ·SoftIRQ·스레드·하드웨어 잡음을 분류하는 원리, 추적 출력 필드, 주기와 임계값 설정, 순 지속 시간 tracepoint 및 워크로드 없는 측정 방식을 설명합니다.

`hwlat_detector`가 운영체제 간섭을 차단해 NMI와 하드웨어만 분리하는 것과 달리, `osnoise`는 선점과 인터럽트를 허용하고 진입·종료 이벤트를 함께 관찰한다. 따라서 총 지연만 보는 것이 아니라 원인별 횟수와 순 지속 시간을 같은 실행 구간에서 비교할 수 있다.

가상 머신에서는 호스트의 간섭이 HW 잡음으로 보일 수 있으며, `stop_tracing_us`와 `stop_tracing_total_us`를 활용하면 큰 단일 지연 또는 누적 지연이 발생한 순간의 추적을 보존할 수 있다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ==============
2 OSNOISE Tracer
3 ==============
4
5 In the context of high-performance computing (HPC), the Operating System
6 Noise (*osnoise*) refers to the interference experienced by an application
7 due to activities inside the operating system. In the context of Linux,
8 NMIs, IRQs, SoftIRQs, and any other system thread can cause noise to the
9 system. Moreover, hardware-related jobs can also cause noise, for example,
10 via SMIs.
11
12 hwlat_detector is one of the tools used to identify the most complex
13 source of noise: *hardware noise*.
14
15 In a nutshell, the hwlat_detector creates a thread that runs
16 periodically for a given period. At the beginning of a period, the thread
17 disables interrupt and starts sampling. While running, the hwlatd
18 thread reads the time in a loop. As interrupts are disabled, threads,
19 IRQs, and SoftIRQs cannot interfere with the hwlatd thread. Hence, the
20 cause of any gap between two different reads of the time roots either on
21 NMI or in the hardware itself. At the end of the period, hwlatd enables
22 interrupts and reports the max observed gap between the reads. It also
23 prints a NMI occurrence counter. If the output does not report NMI
24 executions, the user can conclude that the hardware is the culprit for
25 the latency. The hwlat detects the NMI execution by observing
26 the entry and exit of a NMI.
27
28 The osnoise tracer leverages the hwlat_detector by running a
29 similar loop with preemption, SoftIRQs and IRQs enabled, thus allowing
30 all the sources of *osnoise* during its execution. Using the same approach
31 of hwlat, osnoise takes note of the entry and exit point of any
32 source of interferences, increasing a per-cpu interference counter. The
33 osnoise tracer also saves an interference counter for each source of
34 interference. The interference counter for NMI, IRQs, SoftIRQs, and
35 threads is increased anytime the tool observes these interferences' entry
36 events. When a noise happens without any interference from the operating
37 system level, the hardware noise counter increases, pointing to a
38 hardware-related noise. In this way, osnoise can account for any
39 source of interference. At the end of the period, the osnoise tracer
40 prints the sum of all noise, the max single noise, the percentage of CPU
41 available for the thread, and the counters for the noise sources.
42
43 Usage
44 -----
45
46 Write the ASCII text "osnoise" into the current_tracer file of the
47 tracing system (generally mounted at /sys/kernel/tracing).
48
49 For example::
50
51 [root@f32 ~]# cd /sys/kernel/tracing/
52 [root@f32 tracing]# echo osnoise > current_tracer
53
54 It is possible to follow the trace by reading the trace file::
55
56 [root@f32 tracing]# cat trace
57 # tracer: osnoise
58 #
59 # _-----=> irqs-off
60 # / _----=> need-resched
61 # | / _---=> hardirq/softirq
62 # || / _--=> preempt-depth MAX
63 # || / SINGLE Interference counters:
64 # |||| RUNTIME NOISE % OF CPU NOISE +-----------------------------+
65 # TASK-PID CPU# |||| TIMESTAMP IN US IN US AVAILABLE IN US HW NMI IRQ SIRQ THREAD
66 # | | | |||| | | | | | | | | | |
67 <...>-859 [000] .... 81.637220: 1000000 190 99.98100 9 18 0 1007 18 1
68 <...>-860 [001] .... 81.638154: 1000000 656 99.93440 74 23 0 1006 16 3
69 <...>-861 [002] .... 81.638193: 1000000 5675 99.43250 202 6 0 1013 25 21
70 <...>-862 [003] .... 81.638242: 1000000 125 99.98750 45 1 0 1011 23 0
71 <...>-863 [004] .... 81.638260: 1000000 1721 99.82790 168 7 0 1002 49 41
72 <...>-864 [005] .... 81.638286: 1000000 263 99.97370 57 6 0 1006 26 2
73 <...>-865 [006] .... 81.638302: 1000000 109 99.98910 21 3 0 1006 18 1
74 <...>-866 [007] .... 81.638326: 1000000 7816 99.21840 107 8 0 1016 39 19
75
76 In addition to the regular trace fields (from TASK-PID to TIMESTAMP), the
77 tracer prints a message at the end of each period for each CPU that is
78 running an osnoise/ thread. The osnoise specific fields report:
79
80 - The RUNTIME IN US reports the amount of time in microseconds that
81 the osnoise thread kept looping reading the time.
82 - The NOISE IN US reports the sum of noise in microseconds observed
83 by the osnoise tracer during the associated runtime.
84 - The % OF CPU AVAILABLE reports the percentage of CPU available for
85 the osnoise thread during the runtime window.
86 - The MAX SINGLE NOISE IN US reports the maximum single noise observed
87 during the runtime window.
88 - The Interference counters display how many each of the respective
89 interference happened during the runtime window.
90
91 Note that the example above shows a high number of HW noise samples.
92 The reason being is that this sample was taken on a virtual machine,
93 and the host interference is detected as a hardware interference.
94
95 Tracer Configuration
96 --------------------
97
98 The tracer has a set of options inside the osnoise directory, they are:
99
100 - osnoise/cpus: CPUs at which a osnoise thread will execute.
101 - osnoise/period_us: the period of the osnoise thread.
102 - osnoise/runtime_us: how long an osnoise thread will look for noise.
103 - osnoise/stop_tracing_us: stop the system tracing if a single noise
104 higher than the configured value happens. Writing 0 disables this
105 option.
106 - osnoise/stop_tracing_total_us: stop the system tracing if total noise
107 higher than the configured value happens. Writing 0 disables this
108 option.
109 - tracing_threshold: the minimum delta between two time() reads to be
110 considered as noise, in us. When set to 0, the default value will
111 be used, which is currently 1 us.
112 - osnoise/options: a set of on/off options that can be enabled by
113 writing the option name to the file or disabled by writing the option
114 name preceded with the 'NO\_' prefix. For example, writing
115 NO_OSNOISE_WORKLOAD disables the OSNOISE_WORKLOAD option. The
116 special DEAFAULTS option resets all options to the default value.
117
118 Tracer Options
119 --------------
120
121 The osnoise/options file exposes a set of on/off configuration options for
122 the osnoise tracer. These options are:
123
124 - DEFAULTS: reset the options to the default value.
125 - OSNOISE_WORKLOAD: do not dispatch osnoise workload (see dedicated
126 section below).
127 - PANIC_ON_STOP: call panic() if the tracer stops. This option serves to
128 capture a vmcore.
129 - OSNOISE_PREEMPT_DISABLE: disable preemption while running the osnoise
130 workload, allowing only IRQ and hardware-related noise.
131 - OSNOISE_IRQ_DISABLE: disable IRQs while running the osnoise workload,
132 allowing only NMIs and hardware-related noise, like hwlat tracer.
133
134 Additional Tracing
135 ------------------
136
137 In addition to the tracer, a set of tracepoints were added to
138 facilitate the identification of the osnoise source.
139
140 - osnoise:sample_threshold: printed anytime a noise is higher than
141 the configurable tolerance_ns.
142 - osnoise:nmi_noise: noise from NMI, including the duration.
143 - osnoise:irq_noise: noise from an IRQ, including the duration.
144 - osnoise:softirq_noise: noise from a SoftIRQ, including the
145 duration.
146 - osnoise:thread_noise: noise from a thread, including the duration.
147
148 Note that all the values are *net values*. For example, if while osnoise
149 is running, another thread preempts the osnoise thread, it will start a
150 thread_noise duration at the start. Then, an IRQ takes place, preempting
151 the thread_noise, starting a irq_noise. When the IRQ ends its execution,
152 it will compute its duration, and this duration will be subtracted from
153 the thread_noise, in such a way as to avoid the double accounting of the
154 IRQ execution. This logic is valid for all sources of noise.
155
156 Here is one example of the usage of these tracepoints::
157
158 osnoise/8-961 [008] d.h. 5789.857532: irq_noise: local_timer:236 start 5789.857529929 duration 1845 ns
159 osnoise/8-961 [008] dNh. 5789.858408: irq_noise: local_timer:236 start 5789.858404871 duration 2848 ns
160 migration/8-54 [008] d... 5789.858413: thread_noise: migration/8:54 start 5789.858409300 duration 3068 ns
161 osnoise/8-961 [008] .... 5789.858413: sample_threshold: start 5789.858404555 duration 8812 ns interferences 2
162
163 In this example, a noise sample of 8 microseconds was reported in the last
164 line, pointing to two interferences. Looking backward in the trace, the
165 two previous entries were about the migration thread running after a
166 timer IRQ execution. The first event is not part of the noise because
167 it took place one millisecond before.
168
169 It is worth noticing that the sum of the duration reported in the
170 tracepoints is smaller than eight us reported in the sample_threshold.
171 The reason roots in the overhead of the entry and exit code that happens
172 before and after any interference execution. This justifies the dual
173 approach: measuring thread and tracing.
174
175 Running osnoise tracer without workload
176 ---------------------------------------
177
178 By enabling the osnoise tracer with the NO_OSNOISE_WORKLOAD option set,
179 the osnoise: tracepoints serve to measure the execution time of
180 any type of Linux task, free from the interference of other tasks.
181

3. 한국어 전문 번역

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

운영체제 잡음과 측정 원리

1-42

고성능 컴퓨팅(HPC)에서 운영체제 잡음(Operating System Noise, *osnoise*)은 운영체제 내부 활동 때문에 응용 프로그램이 겪는 간섭을 뜻한다. Linux에서는 NMI, IRQ, SoftIRQ와 그 밖의 모든 시스템 스레드가 시스템 잡음을 일으킬 수 있다. SMI처럼 하드웨어와 관련된 작업도 잡음의 원인이 될 수 있다.

`hwlat_detector`는 가장 복잡한 잡음 원인인 하드웨어 잡음을 식별하는 도구 가운데 하나다.

간단히 말해 `hwlat_detector`는 지정된 주기마다 실행되는 스레드를 만든다. 각 주기가 시작되면 이 스레드는 인터럽트를 비활성화하고 표본 수집을 시작하며, `hwlatd` 스레드는 루프에서 계속 시간을 읽는다. 인터럽트가 꺼져 있으므로 스레드, IRQ, SoftIRQ는 `hwlatd`를 방해할 수 없다. 따라서 연속한 두 시간 읽기 사이에 틈이 생겼다면 원인은 NMI 또는 하드웨어 자체다.

주기가 끝나면 `hwlatd`는 인터럽트를 다시 활성화하고 관측된 읽기 간격 중 최댓값과 NMI 발생 횟수를 보고한다. 출력에 NMI 실행이 없다면 사용자는 지연의 원인이 하드웨어라고 결론 내릴 수 있다. `hwlat`은 NMI 진입과 종료를 관찰해 NMI 실행을 감지한다.

`osnoise` 트레이서는 선점, SoftIRQ, IRQ를 활성화한 채 `hwlat_detector`와 비슷한 루프를 실행한다. 이 때문에 실행 중 모든 *osnoise* 원인이 개입할 수 있다. `osnoise`는 각 간섭 원인의 진입점과 종료점을 기록하고 CPU별 간섭 카운터를 증가시키며, NMI·IRQ·SoftIRQ·스레드마다 별도 카운터도 유지한다. 각 진입 이벤트를 관찰할 때 해당 카운터가 증가한다.

운영체제 수준의 간섭이 없는데 잡음이 발생하면 하드웨어 잡음 카운터를 증가시켜 하드웨어 관련 잡음임을 나타낸다. 이런 방식으로 `osnoise`는 모든 간섭 원인을 집계한다. 각 주기가 끝나면 전체 잡음 합계, 단일 잡음의 최댓값, 스레드가 사용할 수 있었던 CPU 비율, 잡음 원인별 카운터를 출력한다.

hwlat와 osnoise 측정 경로
hwlat_detector인터럽트 비활성화
시간 읽기 루프NMI 진입·종료 관찰
읽기 간격NMI 또는 하드웨어 잡음
osnoise선점·SoftIRQ·IRQ 활성화
간섭 진입·종료CPU별·원인별 카운터와 잡음 시간

인터럽트와 선점 상태에 따라 시간 읽기 사이의 간격을 하드웨어 또는 운영체제 간섭으로 분류한다.

osnoise가 구분하는 간섭
원인관측 방식집계
NMINMI 진입과 종료NMI 카운터와 지속 시간
IRQ하드 IRQ 진입과 종료IRQ 카운터와 지속 시간
SoftIRQSoftIRQ 진입과 종료SIRQ 카운터와 지속 시간
스레드다른 스레드의 선점THREAD 카운터와 지속 시간
하드웨어운영체제 간섭이 없는 시간 간격HW 카운터

각 진입 이벤트를 세고, 운영체제 간섭으로 설명되지 않는 간격은 하드웨어 잡음으로 분류한다.

==============
OSNOISE Tracer
==============

In the context of high-performance computing (HPC), the Operating System
Noise (*osnoise*) refers to the interference experienced by an application
due to activities inside the operating system. In the context of Linux,
NMIs, IRQs, SoftIRQs, and any other system thread can cause noise to the
system. Moreover, hardware-related jobs can also cause noise, for example,
via SMIs.

hwlat_detector is one of the tools used to identify the most complex
source of noise: *hardware noise*.

In a nutshell, the hwlat_detector creates a thread that runs
periodically for a given period. At the beginning of a period, the thread
disables interrupt and starts sampling. While running, the hwlatd
thread reads the time in a loop. As interrupts are disabled, threads,
IRQs, and SoftIRQs cannot interfere with the hwlatd thread. Hence, the
cause of any gap between two different reads of the time roots either on
NMI or in the hardware itself. At the end of the period, hwlatd enables
interrupts and reports the max observed gap between the reads. It also
prints a NMI occurrence counter. If the output does not report NMI
executions, the user can conclude that the hardware is the culprit for
the latency. The hwlat detects the NMI execution by observing
the entry and exit of a NMI.

The osnoise tracer leverages the hwlat_detector by running a
similar loop with preemption, SoftIRQs and IRQs enabled, thus allowing
all the sources of *osnoise* during its execution. Using the same approach
of hwlat, osnoise takes note of the entry and exit point of any
source of interferences, increasing a per-cpu interference counter. The
osnoise tracer also saves an interference counter for each source of
interference. The interference counter for NMI, IRQs, SoftIRQs, and
threads is increased anytime the tool observes these interferences' entry
events. When a noise happens without any interference from the operating
system level, the hardware noise counter increases, pointing to a
hardware-related noise. In this way, osnoise can account for any
source of interference. At the end of the period, the osnoise tracer
prints the sum of all noise, the max single noise, the percentage of CPU
available for the thread, and the counters for the noise sources.

사용법과 출력 해석

43-94

추적 시스템의 `current_tracer` 파일에 ASCII 문자열 `osnoise`를 쓴다. 추적 시스템은 일반적으로 `/sys/kernel/tracing`에 마운트되어 있다.

        [root@f32 ~]# cd /sys/kernel/tracing/
        [root@f32 tracing]# echo osnoise > current_tracer

`trace` 파일을 읽으면 추적 결과를 확인할 수 있다.

        [root@f32 tracing]# cat trace
        # tracer: osnoise
        #
        #                                _-----=> irqs-off
        #                               / _----=> need-resched
        #                              | / _---=> hardirq/softirq
        #                              || / _--=> preempt-depth                            MAX
        #                              || /                                             SINGLE     Interference counters:
        #                              ||||               RUNTIME      NOISE   % OF CPU  NOISE    +-----------------------------+
        #           TASK-PID      CPU# ||||   TIMESTAMP    IN US       IN US  AVAILABLE  IN US     HW    NMI    IRQ   SIRQ THREAD
        #              | |         |   ||||      |           |             |    |            |      |      |      |      |      |
                   <...>-859     [000] ....    81.637220: 1000000        190  99.98100       9     18      0   1007     18      1
                   <...>-860     [001] ....    81.638154: 1000000        656  99.93440      74     23      0   1006     16      3
                   <...>-861     [002] ....    81.638193: 1000000       5675  99.43250     202      6      0   1013     25     21
                   <...>-862     [003] ....    81.638242: 1000000        125  99.98750      45      1      0   1011     23      0
                   <...>-863     [004] ....    81.638260: 1000000       1721  99.82790     168      7      0   1002     49     41
                   <...>-864     [005] ....    81.638286: 1000000        263  99.97370      57      6      0   1006     26      2
                   <...>-865     [006] ....    81.638302: 1000000        109  99.98910      21      3      0   1006     18      1
                   <...>-866     [007] ....    81.638326: 1000000       7816  99.21840     107      8      0   1016     39     19

일반 추적 필드인 `TASK-PID`부터 `TIMESTAMP`까지의 정보에 더해, 트레이서는 `osnoise/` 스레드가 실행 중인 각 CPU에 대해 매 주기 끝에 메시지 하나를 출력한다. 뒤쪽 열은 `osnoise` 전용 측정값과 간섭 카운터다.

osnoise 출력 필드 구조
영역필드의미
일반 추적TASK-PID태스크 이름과 PID
일반 추적CPU# / 상태 플래그 / TIMESTAMPCPU 번호, IRQ·선점 상태, 시각
측정RUNTIME IN US`osnoise` 스레드가 시간을 읽는 루프를 유지한 마이크로초
측정NOISE IN US해당 실행 구간에서 관측한 잡음 시간의 합계
측정% OF CPU AVAILABLE실행 구간 동안 `osnoise` 스레드가 사용할 수 있었던 CPU 비율
측정MAX SINGLE NOISE IN US실행 구간에서 관측한 단일 잡음의 최댓값
간섭 횟수HW / NMI / IRQ / SIRQ / THREAD실행 구간 동안 각 간섭이 발생한 횟수

원문의 ASCII 머리글을 일반 추적 정보, 시간 측정값, 간섭 원인 카운터로 나눠 구조화했다.

`RUNTIME IN US`는 `osnoise` 스레드가 시간을 반복해서 읽은 시간을 마이크로초로 나타낸다. `NOISE IN US`는 그 실행 시간에 트레이서가 관측한 잡음의 합계이며, `% OF CPU AVAILABLE`은 같은 창에서 스레드가 사용할 수 있었던 CPU의 비율이다. `MAX SINGLE NOISE IN US`는 단일 잡음의 최댓값이고, 간섭 카운터는 각 원인이 몇 번 발생했는지 보여 준다.

위 예제에서 HW 잡음 표본이 많은 이유는 가상 머신에서 수집했기 때문이다. 호스트의 간섭이 게스트에는 하드웨어 간섭으로 감지된다.

Usage
-----

Write the ASCII text "osnoise" into the current_tracer file of the
tracing system (generally mounted at /sys/kernel/tracing).

For example::

        [root@f32 ~]# cd /sys/kernel/tracing/
        [root@f32 tracing]# echo osnoise > current_tracer

It is possible to follow the trace by reading the trace file::

        [root@f32 tracing]# cat trace
        # tracer: osnoise
        #
        #                                _-----=> irqs-off
        #                               / _----=> need-resched
        #                              | / _---=> hardirq/softirq
        #                              || / _--=> preempt-depth                            MAX
        #                              || /                                             SINGLE     Interference counters:
        #                              ||||               RUNTIME      NOISE   % OF CPU  NOISE    +-----------------------------+
        #           TASK-PID      CPU# ||||   TIMESTAMP    IN US       IN US  AVAILABLE  IN US     HW    NMI    IRQ   SIRQ THREAD
        #              | |         |   ||||      |           |             |    |            |      |      |      |      |      |
                   <...>-859     [000] ....    81.637220: 1000000        190  99.98100       9     18      0   1007     18      1
                   <...>-860     [001] ....    81.638154: 1000000        656  99.93440      74     23      0   1006     16      3
                   <...>-861     [002] ....    81.638193: 1000000       5675  99.43250     202      6      0   1013     25     21
                   <...>-862     [003] ....    81.638242: 1000000        125  99.98750      45      1      0   1011     23      0
                   <...>-863     [004] ....    81.638260: 1000000       1721  99.82790     168      7      0   1002     49     41
                   <...>-864     [005] ....    81.638286: 1000000        263  99.97370      57      6      0   1006     26      2
                   <...>-865     [006] ....    81.638302: 1000000        109  99.98910      21      3      0   1006     18      1
                   <...>-866     [007] ....    81.638326: 1000000       7816  99.21840     107      8      0   1016     39     19

In addition to the regular trace fields (from TASK-PID to TIMESTAMP), the
tracer prints a message at the end of each period for each CPU that is
running an osnoise/ thread. The osnoise specific fields report:

 - The RUNTIME IN US reports the amount of time in microseconds that
   the osnoise thread kept looping reading the time.
 - The NOISE IN US reports the sum of noise in microseconds observed
   by the osnoise tracer during the associated runtime.
 - The % OF CPU AVAILABLE reports the percentage of CPU available for
   the osnoise thread during the runtime window.
 - The MAX SINGLE NOISE IN US reports the maximum single noise observed
   during the runtime window.
 - The Interference counters display how many each of the respective
   interference happened during the runtime window.

Note that the example above shows a high number of HW noise samples.
The reason being is that this sample was taken on a virtual machine,
and the host interference is detected as a hardware interference.

트레이서 설정 파일

95-117

트레이서 설정은 `osnoise` 디렉터리 안의 다음 파일로 제어한다.

osnoise 설정
파일기능
`osnoise/cpus``osnoise` 스레드를 실행할 CPU 목록
`osnoise/period_us``osnoise` 스레드의 주기
`osnoise/runtime_us`한 주기에서 잡음을 찾는 실행 시간
`osnoise/stop_tracing_us`설정값보다 큰 단일 잡음이 발생하면 시스템 추적 중단; `0`은 비활성화
`osnoise/stop_tracing_total_us`설정값보다 큰 전체 잡음이 발생하면 시스템 추적 중단; `0`은 비활성화
`tracing_threshold`두 `time()` 읽기 사이를 잡음으로 간주할 최소 간격(µs); `0`은 현재 기본값 `1 us` 사용
`osnoise/options`이름을 쓰면 옵션을 켜고 `NO_` 접두사를 붙여 쓰면 끄는 on/off 옵션 집합

CPU 배치, 측정 주기와 실행 시간, 자동 중단 임계값 및 세부 옵션을 설정한다.

예를 들어 `NO_OSNOISE_WORKLOAD`를 쓰면 `OSNOISE_WORKLOAD` 옵션을 비활성화한다. 원문의 마지막 문장에는 초기화 옵션이 `DEAFAULTS`로 표기되어 있지만, 다음 절의 실제 옵션 이름은 `DEFAULTS`이며 모든 옵션을 기본값으로 되돌린다.

Tracer Configuration
--------------------

The tracer has a set of options inside the osnoise directory, they are:

 - osnoise/cpus: CPUs at which a osnoise thread will execute.
 - osnoise/period_us: the period of the osnoise thread.
 - osnoise/runtime_us: how long an osnoise thread will look for noise.
 - osnoise/stop_tracing_us: stop the system tracing if a single noise
   higher than the configured value happens. Writing 0 disables this
   option.
 - osnoise/stop_tracing_total_us: stop the system tracing if total noise
   higher than the configured value happens. Writing 0 disables this
   option.
 - tracing_threshold: the minimum delta between two time() reads to be
   considered as noise, in us. When set to 0, the default value will
   be used, which is currently 1 us.
 - osnoise/options: a set of on/off options that can be enabled by
   writing the option name to the file or disabled by writing the option
   name preceded with the 'NO\_' prefix. For example, writing
   NO_OSNOISE_WORKLOAD disables the OSNOISE_WORKLOAD option. The
   special DEAFAULTS option resets all options to the default value.

on/off 트레이서 옵션

118-133

`osnoise/options` 파일은 다음 on/off 설정 옵션을 제공한다.

osnoise/options 항목
옵션동작
`DEFAULTS`모든 옵션을 기본값으로 재설정
`OSNOISE_WORKLOAD``osnoise` 워크로드를 디스패치하지 않음; 아래 전용 절 참조
`PANIC_ON_STOP`트레이서가 멈추면 `panic()`을 호출해 vmcore를 수집할 수 있게 함
`OSNOISE_PREEMPT_DISABLE`워크로드 실행 중 선점을 비활성화해 IRQ와 하드웨어 관련 잡음만 허용
`OSNOISE_IRQ_DISABLE`워크로드 실행 중 IRQ를 비활성화해 `hwlat` 트레이서처럼 NMI와 하드웨어 관련 잡음만 허용

옵션 이름을 파일에 써서 동작 범위와 중단 시 처리 방식을 바꾼다.

측정 범위 좁히기
기본 osnoise스레드 + SoftIRQ + IRQ + NMI + 하드웨어
OSNOISE_PREEMPT_DISABLEIRQ + NMI + 하드웨어
OSNOISE_IRQ_DISABLENMI + 하드웨어

옵션을 조합해 운영체제 간섭 원인을 단계적으로 제외한다.

Tracer Options
--------------

The osnoise/options file exposes a set of on/off configuration options for
the osnoise tracer. These options are:

 - DEFAULTS: reset the options to the default value.
 - OSNOISE_WORKLOAD: do not dispatch osnoise workload (see dedicated
   section below).
 - PANIC_ON_STOP: call panic() if the tracer stops. This option serves to
   capture a vmcore.
 - OSNOISE_PREEMPT_DISABLE: disable preemption while running the osnoise
   workload, allowing only IRQ and hardware-related noise.
 - OSNOISE_IRQ_DISABLE: disable IRQs while running the osnoise workload,
   allowing only NMIs and hardware-related noise, like hwlat tracer.

추가 tracepoint와 순 잡음 시간

134-174

잡음의 출처를 더 쉽게 식별할 수 있도록 트레이서와 함께 다음 tracepoint가 추가되었다.

osnoise tracepoint
tracepoint기록 내용
`osnoise:sample_threshold`잡음이 설정 가능한 `tolerance_ns`보다 클 때마다 출력
`osnoise:nmi_noise`NMI 잡음과 지속 시간
`osnoise:irq_noise`IRQ 잡음과 지속 시간
`osnoise:softirq_noise`SoftIRQ 잡음과 지속 시간
`osnoise:thread_noise`스레드 잡음과 지속 시간

임계값 초과 표본과 각 간섭 원인의 지속 시간을 개별 이벤트로 기록한다.

모든 시간 값은 *순 값(net value)*이다. 예를 들어 다른 스레드가 `osnoise` 스레드를 선점하면 `thread_noise`의 지속 시간 측정이 시작된다. 그 스레드를 다시 IRQ가 선점하면 `irq_noise` 측정이 시작된다. IRQ 실행이 끝났을 때 계산한 IRQ 지속 시간은 `thread_noise`에서 빼므로 IRQ 실행 시간이 이중 집계되지 않는다. 같은 논리가 모든 잡음 원인에 적용된다.

중첩 간섭의 순 시간 계산
osnoise 실행다른 스레드가 선점
thread_noise 시작IRQ가 스레드를 선점
irq_noise 시작·종료IRQ 지속 시간 계산
thread_noise 종료IRQ 시간을 빼 순 스레드 시간 계산

안쪽 간섭 시간을 바깥쪽 간섭에서 빼 각 원인의 시간이 한 번만 합산되게 한다.

다음은 이 tracepoint들을 사용한 예다.

       osnoise/8-961     [008] d.h.  5789.857532: irq_noise: local_timer:236 start 5789.857529929 duration 1845 ns
       osnoise/8-961     [008] dNh.  5789.858408: irq_noise: local_timer:236 start 5789.858404871 duration 2848 ns
     migration/8-54      [008] d...  5789.858413: thread_noise: migration/8:54 start 5789.858409300 duration 3068 ns
       osnoise/8-961     [008] ....  5789.858413: sample_threshold: start 5789.858404555 duration 8812 ns interferences 2

마지막 줄은 8마이크로초의 잡음 표본과 두 번의 간섭을 보고한다. 추적 내용을 거꾸로 살펴보면 앞의 두 항목은 타이머 IRQ가 실행된 뒤 migration 스레드가 실행된 기록이다. 첫 번째 이벤트는 약 1밀리초 전에 발생했으므로 이 잡음 표본에 포함되지 않는다.

tracepoint가 보고한 지속 시간의 합은 `sample_threshold`가 보고한 8마이크로초보다 작다. 각 간섭 실행 전후에 수행되는 진입·종료 코드의 오버헤드가 있기 때문이다. 이것이 측정 스레드와 이벤트 추적을 함께 사용하는 이중 접근법이 필요한 이유다.

Additional Tracing
------------------

In addition to the tracer, a set of tracepoints were added to
facilitate the identification of the osnoise source.

 - osnoise:sample_threshold: printed anytime a noise is higher than
   the configurable tolerance_ns.
 - osnoise:nmi_noise: noise from NMI, including the duration.
 - osnoise:irq_noise: noise from an IRQ, including the duration.
 - osnoise:softirq_noise: noise from a SoftIRQ, including the
   duration.
 - osnoise:thread_noise: noise from a thread, including the duration.

Note that all the values are *net values*. For example, if while osnoise
is running, another thread preempts the osnoise thread, it will start a
thread_noise duration at the start. Then, an IRQ takes place, preempting
the thread_noise, starting a irq_noise. When the IRQ ends its execution,
it will compute its duration, and this duration will be subtracted from
the thread_noise, in such a way as to avoid the double accounting of the
IRQ execution. This logic is valid for all sources of noise.

Here is one example of the usage of these tracepoints::

       osnoise/8-961     [008] d.h.  5789.857532: irq_noise: local_timer:236 start 5789.857529929 duration 1845 ns
       osnoise/8-961     [008] dNh.  5789.858408: irq_noise: local_timer:236 start 5789.858404871 duration 2848 ns
     migration/8-54      [008] d...  5789.858413: thread_noise: migration/8:54 start 5789.858409300 duration 3068 ns
       osnoise/8-961     [008] ....  5789.858413: sample_threshold: start 5789.858404555 duration 8812 ns interferences 2

In this example, a noise sample of 8 microseconds was reported in the last
line, pointing to two interferences. Looking backward in the trace, the
two previous entries were about the migration thread running after a
timer IRQ execution. The first event is not part of the noise because
it took place one millisecond before.

It is worth noticing that the sum of the duration reported in the
tracepoints is smaller than eight us reported in the sample_threshold.
The reason roots in the overhead of the entry and exit code that happens
before and after any interference execution. This justifies the dual
approach: measuring thread and tracing.

워크로드 없이 osnoise 실행

175-180

`NO_OSNOISE_WORKLOAD` 옵션을 설정한 채 `osnoise` 트레이서를 활성화하면 `osnoise:` tracepoint를 이용해 다른 태스크의 간섭을 배제하고 모든 종류의 Linux 태스크 실행 시간을 측정할 수 있다.

Running osnoise tracer without workload
---------------------------------------

By enabling the osnoise tracer with the NO_OSNOISE_WORKLOAD option set,
the osnoise: tracepoints serve to measure the execution time of
any type of Linux task, free from the interference of other tasks.