All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/10] rtla/timerlat: Add auto-analysis action and report spike timestamps
@ 2026-11-27 15:31 Tomas Glozar
  2026-11-27 15:31 ` [RFC PATCH 01/10] rtla: Support auto-analysis as an action Tomas Glozar
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Tomas Glozar @ 2026-11-27 15:31 UTC (permalink / raw)
  To: Steven Rostedt, Tomas Glozar
  Cc: John Kacur, Luis Goncalves, Crystal Wood, Costa Shulyupin,
	Wander Lairson Costa, linux-trace-kernel

=== Problem ===

rtla timerlat already supports reacting to multiple spikes in one run by
resuming tracing using --on-threshold continue,

    $ rtla timerlat -q --thread 1000 --duration 10s \
        --on-threshold shell,command="echo Tracing stopped on latency spike" \
        --on-threshold trace \
        --on-threshold shell,command="echo Trace output:; tail -n5 timerlat_trace.txt" \
        --on-threshold continue

will stop tracing after each latency spike over 1000us and print the tail of its
trace:

    Tracing stopped on latency spike
    Saving trace to timerlat_trace.txt
    Trace output:
            <idle>-0       [003] dn.h2.. 10507.972291: irq_noise: local_timer:236 start 10507.972288915 duration 2208 ns
            <idle>-0       [003] d...3.. 10507.972293: thread_noise: swapper/3:0 start 10507.972289122 duration 1464 ns
        timerlatu/3-23927   [003] .....11 10507.972293: timerlat_sample: timer_latency=2319269 seqnum=8683 context=1
        timerlatu/3-23927   [003] d..h312 10507.972297: irq_noise: irq_work:246 start 10507.972295820 duration 1014 ns
        timerlatu/3-23927   [003] .....11 10507.972297: #8683  context thread timer_latency   2319269 ns
    Tracing stopped on latency spike
    Saving trace to timerlat_trace.txt
    Trace output:
            <idle>-0       [000] dn.h2.. 10508.176124: irq_noise: local_timer:236 start 10508.176121606 duration 2369 ns
            <idle>-0       [000] d...3.. 10508.176126: thread_noise: swapper/0:0 start 10508.176121766 duration 1973 ns
        timerlatu/0-23924   [000] .....11 10508.176127: timerlat_sample: timer_latency=1138875 seqnum=8894 context=1
        timerlatu/0-23924   [000] d..h312 10508.176131: irq_noise: irq_work:246 start 10508.176129579 duration 872 ns
        timerlatu/0-23924   [000] .....11 10508.176131: #8894  context thread timer_latency   1138875 ns
                                        Timer Latency
    0 00:00:12   |          IRQ Timer Latency (us)        |         Thread Timer Latency (us)      |    Ret user Timer Latency (us)
    CPU COUNT      |      cur       min       avg       max |      cur       min       avg       max |      cur       min       avg       max
    0 #7185      |        0         0         1      1358 |        3         2         4      1367 |        4         3         5      1000
    1 #7175      |        0         0         5      1361 |        3         2         8      1368 |        4         3         7       987
    2 #7178      |        0         0         1      1468 |        4         2         4      1474 |        5         3         4       433
    3 #7184      |        0         0         3      2315 |        2         2         7      2319 |        4         3         6       667
    ---------------|----------------------------------------|----------------------------------------|---------------------------------------
    ALL #28722  e0 |                  0         2      2315 |                  2         6      2319 |                  3         6      1000

However, one cannot use rtla timerlat's built-in auto-analysis to analyze
multiple spikes, because auto-analysis is not an action - instead, it is
done at the end of measurement and only if measurement stopped by the spike,
i.e. not resumed --on-threshold continue and stopped by the user or duration
timer.

=== Proposed solution ===

This patchset adds a new action, "aa", that allows auto-analysis to be used
right after a spike is detected.

This makes analyzing multiple spikes in a single run possible by allowing
the measurement to be resumed after the auto-analysis.

Example (output squished for better readability):

    # rtla timerlat top -q --thread 1200 --duration 10s --on-threshold aa --on-threshold continue
    [  0d 00:00:00.310] ## CPU 1 hit stop tracing, analyzing it ## (seqnum 703)
    IRQ handler delay:      1247.64 us (99.44 %)
    IRQ latency:            1248.12 us
    Timerlat IRQ duration:     2.55 us (0.20 %)
    Blocking thread:           1.26 us (0.10 %)
        kwin_wayland:5350      1.26 us
    IRQ interference           2.02 us (0.16 %)
        irq_work:246           2.02 us
    Softirq interference       0.62 us (0.05 %)
        SCHED:7                0.62 us
    -------------------------------------------
    Thread latency:         1254.68 us (100%)
    Max timerlat IRQ latency from idle: 167.32 us in cpu 2
    [  0d 00:00:00.360] ## CPU 1 hit stop tracing, analyzing it ## (seqnum 752)
    IRQ handler delay:      1259.94 us (99.40 %)
    IRQ latency:            1260.40 us
    Timerlat IRQ duration:     3.60 us (0.28 %)
    Blocking thread:           1.16 us (0.09 %)
        kwin_wayland:5350      1.16 us
    IRQ interference           1.68 us (0.13 %)
        irq_work:246           1.68 us
    Softirq interference       0.69 us (0.05 %)
        SCHED:7                0.60 us
        RCU:9                  0.09 us
    -------------------------------------------
    Thread latency:         1267.53 us (100 %)
    Max timerlat IRQ latency from idle: 11.55 us in cpu 12
                                            Timer Latency
    0 00:00:11    |  IRQ Timer Latency (us)  | Thread Timer Latency (us) | Ret user Timer Latency (us)
    CPU COUNT     |  cur   min   avg    max  |  cur   min   avg    max   |  cur   min   avg    max
    0 #9943       |    1     0     0   1085  |    4     1     2   1091   |    7     2     3   1092
    1 #9943       |    0     0     0   1260  |    2     1     2   1267   |    3     2     2    966
    2 #9945       |    0     0     0    167  |    1     1     1    169   |    2     2     2    170
    3 #9944       |    0     0     0     93  |    2     1     1     95   |    3     2     2     96
    4 #9946       |    1     0     0     35  |    3     2     2     40   |    5     3     3     43
    5 #9945       |    1     0     0     12  |    2     2     2     54   |    3     3     3     63
    6 #9944       |    1     0     0     15  |    3     2     2     21   |    3     3     3     32
    7 #9945       |    1     0     0    131  |    3     2     3    137   |    4     3     3    140
    8 #9945       |    1     0     0     15  |    2     2     2     60   |    3     3     3     62
    9 #9944       |    1     0     0     14  |    2     2     2     22   |    3     3     3     28
    10 #9945      |    1     0     0     12  |    2     2     2     23   |    3     3     3     31
    11 #9944      |    1     0     0     14  |    2     2     2     20   |    3     3     3     29
    12 #9945      |    1     0     1     11  |    5     4     5     32   |    6     5     7     41
    13 #9946      |    1     1     1     11  |    5     4     5     26   |    8     5     7     33
    --------------|--------------------------|---------------------------|----------------------------
    ALL #139224 e0|          0     0   1260  |          1     2   1267   |          2     3   1092

Timestamps are collected as offsets from the starting value of the tracefs
clock per-CPU and displayed along the auto-analysis output, together with
timerlat sequence numbers, to distinguish between individual spikes.

The feature also makes auto-analysis flexible in other ways, for example, it
can be made conditional on the success of the preceding action, or clearing
the terminal (via shell,command=clear) can be added before it.

When the aa action is not used, the default end-of-measurement analysis is
unchanged. When it is used, rtla skips the default analysis, as the action
already ran on the stopped trace.

=== Known functional limitations ===

- Specifying "--on-threshold aa" together with "--aa-only ..." option of
  rtla-timerlat-top skips the "Max latency was ..." message at the end, if no
  latency has been seen. This happens because the default end-of-measurement
  analysis is skipped, the message is a part of it in the current
  implementation.
- When aa action is triggered multiple times in a row to analyze the same spike,
  for example, when "--on-threshold aa" is passed twice, or when there is both
  "--on-threshold aa" and "--on-end aa", the first run consumes the trace data,
  so there is nothing left to analyze for the subsequent runs. (Likely minor.)
- The formatting of the auto-analysis timestamp is inconsistent with the top
  elapsed time format: the former prints days with "d" suffix, the later without
  it. A unified format should be chosen.

=== Known implementation limitations ===

- Commit "rtla: Support auto-analysis as an action" folds in multiple changes
  of both auto-analysis and actions necessary for the auto-analysis action
  itself (passing context through struct actions, resetting aa structures, ...).
  Ideally, it should be separated into multiple commits.
- struct actions takes a pointer to the whole struct osnoise_tool instead of
  only the required parts, creating surface for bugs, e.g. in initialization
  order.
- timerlat_aa_reset() resets each field manually, creating the risk that a newly
  added field is not reset there.

=== Further related feature ideas ===

- When "--on-threshold aa" is used, summarize all spikes at the end of tracing.
- Allow saving the auto-analysis output into a file, optionally with a suffix,
  so that latter results would not overwrite earlier ones.

The aforementioned limitations will, if everything goes well, be addressed in
a follow-up version of the patchset.

Suggestions for further improvements, changes to the output or interface, or
implementation comments are welcome.

Tomas Glozar (10):
  rtla: Support auto-analysis as an action
  rtla/tests: Add unit tests for aa action
  rtla/tests: Add runtime tests for aa action
  Documentation/rtla: Document aa action
  rtla/trace: Add helper to read "now ts" stats field
  rtla/trace: Add helper to gather "now ts" over a CPU set
  rtla/trace: Allow storing start clock value of tracefs instances
  rtla/timerlat: Save the trace clock at measurement start
  rtla/timerlat_aa: Print time offset and seqnum of the spike
  Documentation/rtla: Document auto-analysis timestamps

 Documentation/tools/rtla/common_options.txt   |  12 +
 .../tools/rtla/rtla-timerlat-top.rst          |   9 +-
 tools/tracing/rtla/src/actions.c              |  39 ++-
 tools/tracing/rtla/src/actions.h              |   8 +-
 tools/tracing/rtla/src/cli.c                  |   6 +
 tools/tracing/rtla/src/common.c               |  21 +-
 tools/tracing/rtla/src/common.h               |   7 +
 tools/tracing/rtla/src/timerlat.c             |  14 ++
 tools/tracing/rtla/src/timerlat_aa.c          | 109 ++++++++-
 tools/tracing/rtla/src/trace.c                | 226 ++++++++++++++++++
 tools/tracing/rtla/src/trace.h                |  10 +
 tools/tracing/rtla/tests/osnoise.t            |   4 +
 tools/tracing/rtla/tests/timerlat.t           |  13 +
 tools/tracing/rtla/tests/unit/actions.c       |  31 ++-
 14 files changed, 483 insertions(+), 26 deletions(-)

-- 
2.56.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-11-30 17:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 15:31 [RFC PATCH 00/10] rtla/timerlat: Add auto-analysis action and report spike timestamps Tomas Glozar
2026-11-27 15:31 ` [RFC PATCH 01/10] rtla: Support auto-analysis as an action Tomas Glozar
2026-11-27 16:01   ` sashiko-bot
2026-11-27 15:31 ` [RFC PATCH 02/10] rtla/tests: Add unit tests for aa action Tomas Glozar
2026-11-27 15:31 ` [RFC PATCH 03/10] rtla/tests: Add runtime " Tomas Glozar
2026-11-27 16:16   ` sashiko-bot
2026-11-27 15:32 ` [RFC PATCH 04/10] Documentation/rtla: Document " Tomas Glozar
2026-11-27 15:32 ` [RFC PATCH 05/10] rtla/trace: Add helper to read "now ts" stats field Tomas Glozar
2026-11-27 15:32 ` [RFC PATCH 06/10] rtla/trace: Add helper to gather "now ts" over a CPU set Tomas Glozar
2026-11-27 15:32 ` [RFC PATCH 07/10] rtla/trace: Allow storing start clock value of tracefs instances Tomas Glozar
2026-11-27 15:32 ` [RFC PATCH 08/10] rtla/timerlat: Save the trace clock at measurement start Tomas Glozar
2026-11-27 15:32 ` [RFC PATCH 09/10] rtla/timerlat_aa: Print time offset and seqnum of the spike Tomas Glozar
2026-11-27 15:32 ` [RFC PATCH 10/10] Documentation/rtla: Document auto-analysis timestamps Tomas Glozar
2026-11-30 17:00 ` [RFC PATCH 00/10] rtla/timerlat: Add auto-analysis action and report spike timestamps John Kacur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.