← Documents Documentation/tools/rtla/rtla-timerlat-top.rst GitHub 원문 ↗

Linux 6.18.37 · Kernel Tools

rtla-timerlat-top: 운영체제 타이머 지연 측정

timerlat 주기 요약, 40us 중지 조건, CPU 23의 IRQ handler delay와 차단 스택 자동 분석을 설명합니다.

Source pathDocumentation/tools/rtla/rtla-timerlat-top.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

rtla-timerlat-top.rst:1-136

timerlat 주기 요약, 40us 중지 조건, CPU 23의 IRQ handler delay와 차단 스택 자동 분석을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. |tool| replace:: timerlat top
2
3 ====================
4 rtla-timerlat-top
5 ====================
6 -------------------------------------------
7 Measures the operating system timer latency
8 -------------------------------------------
9
10 :Manual section: 1
11
12 SYNOPSIS
13 ========
14 **rtla timerlat top** [*OPTIONS*] ...
15
16 DESCRIPTION
17 ===========
18
19 .. include:: common_timerlat_description.txt
20
21 The **rtla timerlat top** displays a summary of the periodic output
22 from the *timerlat* tracer. It also provides information for each
23 operating system noise via the **osnoise:** tracepoints that can be
24 seem with the option **-T**.
25
26 OPTIONS
27 =======
28
29 .. include:: common_timerlat_options.txt
30
31 .. include:: common_top_options.txt
32
33 .. include:: common_options.txt
34
35 .. include:: common_timerlat_aa.txt
36
37 **--aa-only** *us*
38
39 Set stop tracing conditions and run without collecting and displaying statistics.
40 Print the auto-analysis if the system hits the stop tracing condition. This option
41 is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
42 collecting the statistics.
43
44 EXAMPLE
45 =======
46
47 In the example below, the timerlat tracer is dispatched in cpus *1-23* in the
48 automatic trace mode, instructing the tracer to stop if a *40 us* latency or
49 higher is found::
50
51 # timerlat -a 40 -c 1-23 -q
52 Timer Latency
53 0 00:00:12 | IRQ Timer Latency (us) | Thread Timer Latency (us)
54 CPU COUNT | cur min avg max | cur min avg max
55 1 #12322 | 0 0 1 15 | 10 3 9 31
56 2 #12322 | 3 0 1 12 | 10 3 9 23
57 3 #12322 | 1 0 1 21 | 8 2 8 34
58 4 #12322 | 1 0 1 17 | 10 2 11 33
59 5 #12322 | 0 0 1 12 | 8 3 8 25
60 6 #12322 | 1 0 1 14 | 16 3 11 35
61 7 #12322 | 0 0 1 14 | 9 2 8 29
62 8 #12322 | 1 0 1 22 | 9 3 9 34
63 9 #12322 | 0 0 1 14 | 8 2 8 24
64 10 #12322 | 1 0 0 12 | 9 3 8 24
65 11 #12322 | 0 0 0 15 | 6 2 7 29
66 12 #12321 | 1 0 0 13 | 5 3 8 23
67 13 #12319 | 0 0 1 14 | 9 3 9 26
68 14 #12321 | 1 0 0 13 | 6 2 8 24
69 15 #12321 | 1 0 1 15 | 12 3 11 27
70 16 #12318 | 0 0 1 13 | 7 3 10 24
71 17 #12319 | 0 0 1 13 | 11 3 9 25
72 18 #12318 | 0 0 0 12 | 8 2 8 20
73 19 #12319 | 0 0 1 18 | 10 2 9 28
74 20 #12317 | 0 0 0 20 | 9 3 8 34
75 21 #12318 | 0 0 0 13 | 8 3 8 28
76 22 #12319 | 0 0 1 11 | 8 3 10 22
77 23 #12320 | 28 0 1 28 | 41 3 11 41
78 rtla timerlat hit stop tracing
79 ## CPU 23 hit stop tracing, analyzing it ##
80 IRQ handler delay: 27.49 us (65.52 %)
81 IRQ latency: 28.13 us
82 Timerlat IRQ duration: 9.59 us (22.85 %)
83 Blocking thread: 3.79 us (9.03 %)
84 objtool:49256 3.79 us
85 Blocking thread stacktrace
86 -> timerlat_irq
87 -> __hrtimer_run_queues
88 -> hrtimer_interrupt
89 -> __sysvec_apic_timer_interrupt
90 -> sysvec_apic_timer_interrupt
91 -> asm_sysvec_apic_timer_interrupt
92 -> _raw_spin_unlock_irqrestore
93 -> cgroup_rstat_flush_locked
94 -> cgroup_rstat_flush_irqsafe
95 -> mem_cgroup_flush_stats
96 -> mem_cgroup_wb_stats
97 -> balance_dirty_pages
98 -> balance_dirty_pages_ratelimited_flags
99 -> btrfs_buffered_write
100 -> btrfs_do_write_iter
101 -> vfs_write
102 -> __x64_sys_pwrite64
103 -> do_syscall_64
104 -> entry_SYSCALL_64_after_hwframe
105 ------------------------------------------------------------------------
106 Thread latency: 41.96 us (100%)
107
108 The system has exit from idle latency!
109 Max timerlat IRQ latency from idle: 17.48 us in cpu 4
110 Saving trace to timerlat_trace.txt
111
112 In this case, the major factor was the delay suffered by the *IRQ handler*
113 that handles **timerlat** wakeup: *65.52%*. This can be caused by the
114 current thread masking interrupts, which can be seen in the blocking
115 thread stacktrace: the current thread (*objtool:49256*) disabled interrupts
116 via *raw spin lock* operations inside mem cgroup, while doing write
117 syscall in a btrfs file system.
118
119 The raw trace is saved in the **timerlat_trace.txt** file for further analysis.
120
121 Note that **rtla timerlat** was dispatched without changing *timerlat* tracer
122 threads' priority. That is generally not needed because these threads have
123 priority *FIFO:95* by default, which is a common priority used by real-time
124 kernel developers to analyze scheduling delays.
125
126 SEE ALSO
127 --------
128 **rtla-timerlat**\(1), **rtla-timerlat-hist**\(1)
129
130 *timerlat* tracer documentation: <https://www.kernel.org/doc/html/latest/trace/timerlat-tracer.html>
131
132 AUTHOR
133 ------
134 Written by Daniel Bristot de Oliveira <bristot@kernel.org>
135
136 .. include:: common_appendix.txt
137

3. 한국어 전문 번역

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

요약 화면, 옵션과 자동 분석 전용 모드

1-43

`rtla timerlat top [OPTIONS]`는 `timerlat` 추적기의 주기 출력을 CPU별 요약으로 표시한다. `-T`를 사용하면 `osnoise:` tracepoint를 활성화하여 각각의 운영체제 간섭 정보도 함께 제공한다.

이 모드는 timerlat 설명·옵션, top 출력 옵션, RTLA 공통 옵션, timerlat 자동 분석 정의를 포함한다. `--aa-only us`는 통계 수집과 표시를 생략한 채 추적 중지 조건만 설정하고, 임계값을 넘었을 때 자동 분석을 출력한다. 따라서 통계 수집 비용 없이 원인 분석 기능을 켜고 싶을 때 유용하다.

top 모드 구성
구성기능
common_timerlat_description.txtIRQ와 스레드 타이머 지연 측정
common_timerlat_options.txttimerlat 임계값과 추적 설정
common_top_options.txt주기 요약과 quiet 출력
common_options.txtCPU, 시간, 우선순위와 이벤트
common_timerlat_aa.txt / --aa-only자동 원인 분석과 통계 없는 경량 실행

요약 화면에 결합되는 공통 기능이다.

timerlat top 관찰 경로
Timer interruptIRQ timer latency
timerlat IRQ handlerWake timerlat thread
Thread scheduledThread timer latency
Threshold hitStop trace + auto-analysis

주기별 IRQ 지연과 이후 스레드 지연을 같은 CPU 행에서 비교한다.

.. |tool| replace:: timerlat top

====================
rtla-timerlat-top
====================
-------------------------------------------
Measures the operating system timer latency
-------------------------------------------

:Manual section: 1

SYNOPSIS
========
**rtla timerlat top** [*OPTIONS*] ...

DESCRIPTION
===========

.. include:: common_timerlat_description.txt

The **rtla timerlat top** displays a summary of the periodic output
from the *timerlat* tracer. It also provides information for each
operating system noise via the **osnoise:** tracepoints that can be
seem with the option **-T**.

OPTIONS
=======

.. include:: common_timerlat_options.txt

.. include:: common_top_options.txt

.. include:: common_options.txt

.. include:: common_timerlat_aa.txt

**--aa-only** *us*

        Set stop tracing conditions and run without collecting and displaying statistics.
        Print the auto-analysis if the system hits the stop tracing condition. This option
        is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
        collecting the statistics.

40us 중지 조건과 CPU 23 자동 분석

44-111

예제는 CPU 1-23에서 자동 추적 모드를 실행하고 40us 이상의 지연이 발견되면 추적을 멈춘다. `timerlat -a 40 -c 1-23 -q`의 `-q`는 실행 중 갱신 대신 최종 결과를 중심으로 보여 준다.

상단 표에서 `COUNT`는 CPU별 표본 수이고 IRQ와 Thread 영역의 `cur`, `min`, `avg`, `max`는 현재·최소·평균·최대 지연을 microsecond 단위로 나타낸다. CPU 23에서 IRQ 28us와 스레드 41us가 관찰되어 40us 중지 조건을 넘었고 자동 분석이 시작되었다.

자동 분석은 전체 41.96us 스레드 지연을 구성 요소별로 나눈다. IRQ handler delay가 27.49us로 65.52%를 차지하고, timerlat IRQ 자체 실행은 9.59us로 22.85%, 차단 스레드는 3.79us로 9.03%다. 따라서 이 사례의 주된 원인은 timerlat wakeup IRQ가 실행되기 전까지 인터럽트가 가려진 시간이다.

차단 스택은 `objtool:49256` 스레드가 btrfs 파일 시스템에서 write syscall을 수행하던 중 mem cgroup의 `raw spin lock` 경로를 지나며 인터럽트를 비활성화했음을 보여 준다. 스택의 함수명과 호출 순서는 원문 그대로 보존되며, idle 복귀 지연과 CPU 4의 idle 상태 최대 IRQ 지연 17.48us도 별도로 보고된다. 원시 추적은 `timerlat_trace.txt`에 저장된다.

CPU 23 지연 분해
요인시간비율
IRQ handler delay27.49 us65.52%
Timerlat IRQ duration9.59 us22.85%
Blocking thread3.79 us9.03%
Thread latency41.96 us100%

자동 분석이 보고한 41.96us 스레드 지연의 구성이다.

차단 경로의 핵심
구간해석
timerlat_irq -> hrtimer_interrupttimerlat wakeup을 처리하는 타이머 IRQ 경로
_raw_spin_unlock_irqrestore인터럽트 비활성 구간의 종료 지점
cgroup_rstat_flush_locked -> mem_cgroup_wb_statsmem cgroup 통계 갱신 경로
balance_dirty_pages -> btrfs_buffered_write쓰기 조절과 btrfs buffered write
vfs_write -> __x64_sys_pwrite64사용자 write syscall 진입 경로

긴 원문 stacktrace에서 진단에 중요한 경계를 추린다.

자동 분석 판단
CPU 23 Thread max 41 us40 us threshold exceeded
Stop tracingDecompose latency
IRQ handler delay 65.52%Inspect blocking stacktrace
Save timerlat_trace.txtDetailed follow-up

임계값 초과 표본을 원시 추적과 원인 스택으로 연결한다.

EXAMPLE
=======

In the example below, the timerlat tracer is dispatched in cpus *1-23* in the
automatic trace mode, instructing the tracer to stop if a *40 us* latency or
higher is found::

  # timerlat -a 40 -c 1-23 -q
                                     Timer Latency
    0 00:00:12   |          IRQ Timer Latency (us)        |         Thread Timer Latency (us)
  CPU COUNT      |      cur       min       avg       max |      cur       min       avg       max
    1 #12322     |        0         0         1        15 |       10         3         9        31
    2 #12322     |        3         0         1        12 |       10         3         9        23
    3 #12322     |        1         0         1        21 |        8         2         8        34
    4 #12322     |        1         0         1        17 |       10         2        11        33
    5 #12322     |        0         0         1        12 |        8         3         8        25
    6 #12322     |        1         0         1        14 |       16         3        11        35
    7 #12322     |        0         0         1        14 |        9         2         8        29
    8 #12322     |        1         0         1        22 |        9         3         9        34
    9 #12322     |        0         0         1        14 |        8         2         8        24
   10 #12322     |        1         0         0        12 |        9         3         8        24
   11 #12322     |        0         0         0        15 |        6         2         7        29
   12 #12321     |        1         0         0        13 |        5         3         8        23
   13 #12319     |        0         0         1        14 |        9         3         9        26
   14 #12321     |        1         0         0        13 |        6         2         8        24
   15 #12321     |        1         0         1        15 |       12         3        11        27
   16 #12318     |        0         0         1        13 |        7         3        10        24
   17 #12319     |        0         0         1        13 |       11         3         9        25
   18 #12318     |        0         0         0        12 |        8         2         8        20
   19 #12319     |        0         0         1        18 |       10         2         9        28
   20 #12317     |        0         0         0        20 |        9         3         8        34
   21 #12318     |        0         0         0        13 |        8         3         8        28
   22 #12319     |        0         0         1        11 |        8         3        10        22
   23 #12320     |       28         0         1        28 |       41         3        11        41
  rtla timerlat hit stop tracing
  ## CPU 23 hit stop tracing, analyzing it ##
  IRQ handler delay:                                        27.49 us (65.52 %)
  IRQ latency:                                              28.13 us
  Timerlat IRQ duration:                                     9.59 us (22.85 %)
  Blocking thread:                                           3.79 us (9.03 %)
                         objtool:49256                       3.79 us
    Blocking thread stacktrace
                -> timerlat_irq
                -> __hrtimer_run_queues
                -> hrtimer_interrupt
                -> __sysvec_apic_timer_interrupt
                -> sysvec_apic_timer_interrupt
                -> asm_sysvec_apic_timer_interrupt
                -> _raw_spin_unlock_irqrestore
                -> cgroup_rstat_flush_locked
                -> cgroup_rstat_flush_irqsafe
                -> mem_cgroup_flush_stats
                -> mem_cgroup_wb_stats
                -> balance_dirty_pages
                -> balance_dirty_pages_ratelimited_flags
                -> btrfs_buffered_write
                -> btrfs_do_write_iter
                -> vfs_write
                -> __x64_sys_pwrite64
                -> do_syscall_64
                -> entry_SYSCALL_64_after_hwframe
  ------------------------------------------------------------------------
    Thread latency:                                          41.96 us (100%)

  The system has exit from idle latency!
    Max timerlat IRQ latency from idle: 17.48 us in cpu 4
  Saving trace to timerlat_trace.txt

원인 결론과 기본 우선순위

112-124

이 사례에서 가장 큰 요인은 timerlat wakeup을 담당하는 IRQ handler가 겪은 65.52%의 지연이다. 현재 스레드 `objtool:49256`이 btrfs 파일 시스템의 write syscall을 수행하면서 mem cgroup 내부의 raw spin lock 연산으로 인터럽트를 가렸다는 사실을 차단 스택에서 확인할 수 있다.

추가 분석을 위해 원시 추적은 `timerlat_trace.txt`에 저장된다. 이 실행에서는 timerlat 추적기 스레드의 우선순위를 따로 바꾸지 않았다. 기본값이 실시간 커널 개발자가 스케줄링 지연을 분석할 때 흔히 쓰는 `FIFO:95`이므로 일반적으로 별도 변경이 필요하지 않다.

진단 결론
항목결론
주된 지연IRQ handler delay 27.49us, 전체의 65.52%
차단 주체objtool:49256, mem cgroup raw spin lock 경로
작업 맥락btrfs write syscall
후속 자료timerlat_trace.txt
기본 추적 스레드 우선순위FIFO:95

요약 수치와 후속 자료를 함께 기록한다.

In this case, the major factor was the delay suffered by the *IRQ handler*
that handles **timerlat** wakeup: *65.52%*. This can be caused by the
current thread masking interrupts, which can be seen in the blocking
thread stacktrace: the current thread (*objtool:49256*) disabled interrupts
via *raw spin lock* operations inside mem cgroup, while doing write
syscall in a btrfs file system.

The raw trace is saved in the **timerlat_trace.txt** file for further analysis.

Note that **rtla timerlat** was dispatched without changing *timerlat* tracer
threads' priority. That is generally not needed because these threads have
priority *FIFO:95* by default, which is a common priority used by real-time
kernel developers to analyze scheduling delays.

관련 문서와 작성 정보

125-136

관련 매뉴얼은 `rtla-timerlat(1)`과 `rtla-timerlat-hist(1)`이며, 커널 추적기 세부 사항은 timerlat tracer 문서에서 확인한다.

이 문서는 Daniel Bristot de Oliveira가 작성했다. 마지막 `common_appendix.txt`는 RTLA 공통 부록을 포함한다.

관련 자료
문서용도
rtla-timerlat(1)timerlat 명령과 모드 진입
rtla-timerlat-hist(1)IRQ·스레드 지연의 전체 분포
timerlat tracer documentation커널 추적기와 이벤트 의미

top 결과를 분포 또는 추적기 내부 설명과 연결한다.


SEE ALSO
--------
**rtla-timerlat**\(1), **rtla-timerlat-hist**\(1)

*timerlat* tracer documentation: <https://www.kernel.org/doc/html/latest/trace/timerlat-tracer.html>

AUTHOR
------
Written by Daniel Bristot de Oliveira <bristot@kernel.org>

.. include:: common_appendix.txt