162306a36Sopenharmony_ci====================
262306a36Sopenharmony_cirtla-timerlat-top
362306a36Sopenharmony_ci====================
462306a36Sopenharmony_ci-------------------------------------------
562306a36Sopenharmony_ciMeasures the operating system timer latency
662306a36Sopenharmony_ci-------------------------------------------
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci:Manual section: 1
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciSYNOPSIS
1162306a36Sopenharmony_ci========
1262306a36Sopenharmony_ci**rtla timerlat top** [*OPTIONS*] ...
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciDESCRIPTION
1562306a36Sopenharmony_ci===========
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci.. include:: common_timerlat_description.rst
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciThe **rtla timerlat top** displays a summary of the periodic output
2062306a36Sopenharmony_cifrom the *timerlat* tracer. It also provides information for each
2162306a36Sopenharmony_cioperating system noise via the **osnoise:** tracepoints that can be
2262306a36Sopenharmony_ciseem with the option **-T**.
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciOPTIONS
2562306a36Sopenharmony_ci=======
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci.. include:: common_timerlat_options.rst
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci.. include:: common_top_options.rst
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci.. include:: common_options.rst
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci.. include:: common_timerlat_aa.rst
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci**--aa-only** *us*
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci        Set stop tracing conditions and run without collecting and displaying statistics.
3862306a36Sopenharmony_ci        Print the auto-analysis if the system hits the stop tracing condition. This option
3962306a36Sopenharmony_ci        is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
4062306a36Sopenharmony_ci        collecting the statistics.
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciEXAMPLE
4362306a36Sopenharmony_ci=======
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciIn the example below, the timerlat tracer is dispatched in cpus *1-23* in the
4662306a36Sopenharmony_ciautomatic trace mode, instructing the tracer to stop if a *40 us* latency or
4762306a36Sopenharmony_cihigher is found::
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci  # timerlat -a 40 -c 1-23 -q
5062306a36Sopenharmony_ci                                     Timer Latency
5162306a36Sopenharmony_ci    0 00:00:12   |          IRQ Timer Latency (us)        |         Thread Timer Latency (us)
5262306a36Sopenharmony_ci  CPU COUNT      |      cur       min       avg       max |      cur       min       avg       max
5362306a36Sopenharmony_ci    1 #12322     |        0         0         1        15 |       10         3         9        31
5462306a36Sopenharmony_ci    2 #12322     |        3         0         1        12 |       10         3         9        23
5562306a36Sopenharmony_ci    3 #12322     |        1         0         1        21 |        8         2         8        34
5662306a36Sopenharmony_ci    4 #12322     |        1         0         1        17 |       10         2        11        33
5762306a36Sopenharmony_ci    5 #12322     |        0         0         1        12 |        8         3         8        25
5862306a36Sopenharmony_ci    6 #12322     |        1         0         1        14 |       16         3        11        35
5962306a36Sopenharmony_ci    7 #12322     |        0         0         1        14 |        9         2         8        29
6062306a36Sopenharmony_ci    8 #12322     |        1         0         1        22 |        9         3         9        34
6162306a36Sopenharmony_ci    9 #12322     |        0         0         1        14 |        8         2         8        24
6262306a36Sopenharmony_ci   10 #12322     |        1         0         0        12 |        9         3         8        24
6362306a36Sopenharmony_ci   11 #12322     |        0         0         0        15 |        6         2         7        29
6462306a36Sopenharmony_ci   12 #12321     |        1         0         0        13 |        5         3         8        23
6562306a36Sopenharmony_ci   13 #12319     |        0         0         1        14 |        9         3         9        26
6662306a36Sopenharmony_ci   14 #12321     |        1         0         0        13 |        6         2         8        24
6762306a36Sopenharmony_ci   15 #12321     |        1         0         1        15 |       12         3        11        27
6862306a36Sopenharmony_ci   16 #12318     |        0         0         1        13 |        7         3        10        24
6962306a36Sopenharmony_ci   17 #12319     |        0         0         1        13 |       11         3         9        25
7062306a36Sopenharmony_ci   18 #12318     |        0         0         0        12 |        8         2         8        20
7162306a36Sopenharmony_ci   19 #12319     |        0         0         1        18 |       10         2         9        28
7262306a36Sopenharmony_ci   20 #12317     |        0         0         0        20 |        9         3         8        34
7362306a36Sopenharmony_ci   21 #12318     |        0         0         0        13 |        8         3         8        28
7462306a36Sopenharmony_ci   22 #12319     |        0         0         1        11 |        8         3        10        22
7562306a36Sopenharmony_ci   23 #12320     |       28         0         1        28 |       41         3        11        41
7662306a36Sopenharmony_ci  rtla timerlat hit stop tracing
7762306a36Sopenharmony_ci  ## CPU 23 hit stop tracing, analyzing it ##
7862306a36Sopenharmony_ci  IRQ handler delay:                                        27.49 us (65.52 %)
7962306a36Sopenharmony_ci  IRQ latency:                                              28.13 us
8062306a36Sopenharmony_ci  Timerlat IRQ duration:                                     9.59 us (22.85 %)
8162306a36Sopenharmony_ci  Blocking thread:                                           3.79 us (9.03 %)
8262306a36Sopenharmony_ci                         objtool:49256                       3.79 us
8362306a36Sopenharmony_ci    Blocking thread stacktrace
8462306a36Sopenharmony_ci                -> timerlat_irq
8562306a36Sopenharmony_ci                -> __hrtimer_run_queues
8662306a36Sopenharmony_ci                -> hrtimer_interrupt
8762306a36Sopenharmony_ci                -> __sysvec_apic_timer_interrupt
8862306a36Sopenharmony_ci                -> sysvec_apic_timer_interrupt
8962306a36Sopenharmony_ci                -> asm_sysvec_apic_timer_interrupt
9062306a36Sopenharmony_ci                -> _raw_spin_unlock_irqrestore
9162306a36Sopenharmony_ci                -> cgroup_rstat_flush_locked
9262306a36Sopenharmony_ci                -> cgroup_rstat_flush_irqsafe
9362306a36Sopenharmony_ci                -> mem_cgroup_flush_stats
9462306a36Sopenharmony_ci                -> mem_cgroup_wb_stats
9562306a36Sopenharmony_ci                -> balance_dirty_pages
9662306a36Sopenharmony_ci                -> balance_dirty_pages_ratelimited_flags
9762306a36Sopenharmony_ci                -> btrfs_buffered_write
9862306a36Sopenharmony_ci                -> btrfs_do_write_iter
9962306a36Sopenharmony_ci                -> vfs_write
10062306a36Sopenharmony_ci                -> __x64_sys_pwrite64
10162306a36Sopenharmony_ci                -> do_syscall_64
10262306a36Sopenharmony_ci                -> entry_SYSCALL_64_after_hwframe
10362306a36Sopenharmony_ci  ------------------------------------------------------------------------
10462306a36Sopenharmony_ci    Thread latency:                                          41.96 us (100%)
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci  The system has exit from idle latency!
10762306a36Sopenharmony_ci    Max timerlat IRQ latency from idle: 17.48 us in cpu 4
10862306a36Sopenharmony_ci  Saving trace to timerlat_trace.txt
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ciIn this case, the major factor was the delay suffered by the *IRQ handler*
11162306a36Sopenharmony_cithat handles **timerlat** wakeup: *65.52%*. This can be caused by the
11262306a36Sopenharmony_cicurrent thread masking interrupts, which can be seen in the blocking
11362306a36Sopenharmony_cithread stacktrace: the current thread (*objtool:49256*) disabled interrupts
11462306a36Sopenharmony_civia *raw spin lock* operations inside mem cgroup, while doing write
11562306a36Sopenharmony_cisyscall in a btrfs file system.
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ciThe raw trace is saved in the **timerlat_trace.txt** file for further analysis.
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ciNote that **rtla timerlat** was dispatched without changing *timerlat* tracer
12062306a36Sopenharmony_cithreads' priority. That is generally not needed because these threads have
12162306a36Sopenharmony_cipriority *FIFO:95* by default, which is a common priority used by real-time
12262306a36Sopenharmony_cikernel developers to analyze scheduling delays.
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ciSEE ALSO
12562306a36Sopenharmony_ci--------
12662306a36Sopenharmony_ci**rtla-timerlat**\(1), **rtla-timerlat-hist**\(1)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci*timerlat* tracer documentation: <https://www.kernel.org/doc/html/latest/trace/timerlat-tracer.html>
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ciAUTHOR
13162306a36Sopenharmony_ci------
13262306a36Sopenharmony_ciWritten by Daniel Bristot de Oliveira <bristot@kernel.org>
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci.. include:: common_appendix.rst
135