You are here: Home / Projects / OSADL Linux Add-on Patches / 
2024-11-30 - 13:32

Dates and Events:

OSADL Articles:

2024-10-02 12:00

Linux is now an RTOS!

PREEMPT_RT is mainline - What's next?


2023-11-12 12:00

Open Source License Obligations Checklists even better now

Import the checklists to other tools, create context diffs and merged lists


2023-03-01 12:00

Embedded Linux distributions

Results of the online "wish list"


2022-01-13 12:00

Phase #3 of OSADL project on OPC UA PubSub over TSN successfully completed

Another important milestone on the way to interoperable Open Source real-time Ethernet has been reached


2021-02-09 12:00

Open Source OPC UA PubSub over TSN project phase #3 launched

Letter of Intent with call for participation is now available



OSADL Projects

OSADL Linux Add-on Patch: Latency histograms with culprit/victim info

Ping SysRq - Latency histograms - NMI SysRq - Built-in kernel patchset - Precise load measurement - Bundle

What are latency histograms?

Linux kernel latency histograms are used to determine the duration of certain pathways that contribute to the preemption latency. As a side effect, the data stored along with the histogram data may allow to discover the source of an unusual long latency, since these data include the name and characteristic data of the previous and the next task of a delayed scheduling action. The original latency histograms were made available in the RT patch set in 2005; a number of additions were made since then:

  • Separate histograms of shared vs. non-shared priority tasks
  • Separate recording of “victim” and “culprit” of the highest latency
  • Additional histogram to record latency of missed timers
  • Additional histogram to record the sum of timer and wakeup latency
  • Additional histogram to record duration of context switch
  • Additional histogram to record the sum of timer, wakeup and context switch latency

Thus, the current version of the patch covers histograms to investigate the entire time span from the wake up trigger of an RT task to its execution continuation in user space as depicted below:

Configure, enable and use latency histograms

Configure

CONFIG_PREEMPT_OFF_HIST=y
CONFIG_INTERRUPT_OFF_HIST=y
CONFIG_MISSED_TIMER_OFFSETS_HIST=y
CONFIG_WAKEUP_LATENCY_HIST=y
CONFIG_SWITCHTIME_HIST=y

Enable

enabledir=/sys/kernel/debug/latency_hist/enable
for i in wakeup missed_timer_offsets timerandwakeup switchtime timerwakeupswitch
do
  enable=$enabledir/$i
  if test -f $enable
  then
    echo 1 >$enable
  fi
done

Usage example (core #0)

cd /sys/kernel/debug/latency_hist/timerwakeupswitch
cat CPU0
#Minimum latency: 0 microseconds
#Average latency: 0 microseconds
#Maximum latency: 42 microseconds
#Total samples: 917647
#There are 0 samples lower than 0 microseconds.
#There are 0 samples greater or equal than 10240 microseconds.
#usecs             samples
     0              784721
     1               80668
     2               37626
     3                6354
     4                3249
     5                1747
     6                 960
     7                 543
     8                 412
     9                 310
    10                 256
    11                 169
    12                 146
    13                 118
    14                  82
    15                  75
    16                  50
    17                  30
    18                  27
    19                  25
    20                  14
    21                  11
    22                  10
    23                  12
    24                   7
    25                   2
    26                   2
    27                   1
    28                   4
    29                   2
    30                   2
    31                   2
    32                   4
    34                   2
    35                   1
    39                   1
    41                   1
    42                   1

Display culprit and victim of longest latency (core #0)

cat /sys/kernel/debug/latency_hist/timerwakeupswitch/max_latency-CPU0
13457 99 42 (2,9) cyclictest <- 6681 5 alsa-sink-HDMI  1164604.885757 SyS_clock_nanosleep

News article on the use of latency histograms

This article may provide some more details on the usefulness of latency histograms.

Download patch

Latency histograms

  
Kernel versionViewDownload
4.16.7-rt1...4.16.15-rt7latency-histograms.patchlatency-histograms.patch
4.18.5-rt3...4.18.16-rt9latency-histograms.patchlatency-histograms.patch
4.19.1-rt3...4.19.25-rt16latency-histograms.patchlatency-histograms.patch
4.19.94-rt39...4.19.94-rt39latency-histograms.patchlatency-histograms.patch
4.19.98-rt40...4.19.98-rt40latency-histograms.patchlatency-histograms.patch
4.19.100-rt41...4.19.106-rt46latency-histograms.patchlatency-histograms.patch
4.19.115-rt50...4.19.115-rt50latency-histograms.patchlatency-histograms.patch
4.19.120-rt52...4.19.127-rt55latency-histograms.patchlatency-histograms.patch
4.19.132-rt59...4.19.132-rt59latency-histograms.patchlatency-histograms.patch
4.19.135-rt60...4.19.135-rt61latency-histograms.patchlatency-histograms.patch
4.19.142-rt63...4.19.152-rt66latency-histograms.patchlatency-histograms.patch
4.19.160-rt69...4.19.160-rt69latency-histograms.patchlatency-histograms.patch
4.19.165-rt70...4.19.165-rt70latency-histograms.patchlatency-histograms.patch
4.19.173-rt72...4.19.173-rt72latency-histograms.patchlatency-histograms.patch
4.19.180-rt73...4.19.180-rt73latency-histograms.patchlatency-histograms.patch
4.19.182-rt74...4.19.182-rt74latency-histograms.patchlatency-histograms.patch
4.19.184-rt75...4.19.185-rt76latency-histograms.patchlatency-histograms.patch
4.19.188-rt77...4.19.195-rt82latency-histograms.patchlatency-histograms.patch
4.19.196-rt83...4.19.206-rt87latency-histograms.patchlatency-histograms.patch
4.19.207-rt88...4.19.217-rt95latency-histograms.patchlatency-histograms.patch
4.19.218-rt96...4.19.233-rt105latency-histograms.patchlatency-histograms.patch
4.19.235-rt106...4.19.237-rt107latency-histograms.patchlatency-histograms.patch
4.19.240-rt108...4.19.240-rt108latency-histograms.patchlatency-histograms.patch
4.19.245-rt109...4.19.246-rt110latency-histograms.patchlatency-histograms.patch
4.19.252-rt112...4.19.255-rt114latency-histograms.patchlatency-histograms.patch
4.19.261-rt116...4.19.265-rt117latency-histograms.patchlatency-histograms.patch
4.19.269-rt119...4.19.277-rt122latency-histograms.patchlatency-histograms.patch
4.19.280-rt123...4.19.280-rt123latency-histograms.patchlatency-histograms.patch
4.19.283-rt124...4.19.306-rt132latency-histograms.patchlatency-histograms.patch
4.19.307-rt133...4.19.322-rt138latency-histograms.patchlatency-histograms.patch
5.0.3-rt1...5.0.19-rt11latency-histograms.patchlatency-histograms.patch
5.0.21-rt16...5.0.21-rt16latency-histograms.patchlatency-histograms.patch
5.2.0-rt1...5.2.21-rt15latency-histograms.patchlatency-histograms.patch
5.4.3-rt1...5.4.5-rt3latency-histograms.patchlatency-histograms.patch
5.4.10-rt4...5.4.10-rt5latency-histograms.patchlatency-histograms.patch
5.4.13-rt6...5.4.13-rt7latency-histograms.patchlatency-histograms.patch
5.4.17-rt8...5.4.19-rt11latency-histograms.patchlatency-histograms.patch
5.4.22-rt12...5.4.22-rt13latency-histograms.patchlatency-histograms.patch
5.4.24-rt14...5.4.28-rt19latency-histograms.patchlatency-histograms.patch
5.4.34-rt21...5.4.34-rt21latency-histograms.patchlatency-histograms.patch
5.4.39-rt23...5.4.39-rt23latency-histograms.patchlatency-histograms.patch
5.4.40-rt24...5.4.40-rt24latency-histograms.patchlatency-histograms.patch
5.4.43-rt25...5.4.47-rt28latency-histograms.patchlatency-histograms.patch
5.4.52-rt31...5.4.52-rt31latency-histograms.patchlatency-histograms.patch
5.4.54-rt32...5.4.54-rt32latency-histograms.patchlatency-histograms.patch
5.4.54-rt33...5.4.55-rt35latency-histograms.patchlatency-histograms.patch
5.4.59-rt36...5.4.59-rt36latency-histograms.patchlatency-histograms.patch
5.4.61-rt37...5.4.61-rt37latency-histograms.patchlatency-histograms.patch
5.4.66-rt38...5.4.66-rt38latency-histograms.patchlatency-histograms.patch
5.4.69-rt39...5.4.70-rt40latency-histograms.patchlatency-histograms.patch
5.4.74-rt41...5.4.84-rt47latency-histograms.patchlatency-histograms.patch
5.4.87-rt48...5.4.91-rt50latency-histograms.patchlatency-histograms.patch
5.4.93-rt51...5.4.93-rt51latency-histograms.patchlatency-histograms.patch
5.4.102-rt53...5.4.102-rt53latency-histograms.patchlatency-histograms.patch
5.4.106-rt54...5.4.106-rt54latency-histograms.patchlatency-histograms.patch
5.4.109-rt55...5.4.109-rt56latency-histograms.patchlatency-histograms.patch
5.4.115-rt57...5.4.115-rt57latency-histograms.patchlatency-histograms.patch
5.4.123-rt59...5.4.123-rt59latency-histograms.patchlatency-histograms.patch
5.4.129-rt61...5.4.143-rt64latency-histograms.patchlatency-histograms.patch
5.4.154-rt65...5.4.161-rt67latency-histograms.patchlatency-histograms.patch
5.4.170-rt68...5.4.182-rt70latency-histograms.patchlatency-histograms.patch
5.4.182-rt71...5.4.182-rt71latency-histograms.patchlatency-histograms.patch
5.4.182-rt72...5.4.188-rt73latency-histograms.patchlatency-histograms.patch
5.4.193-rt74...5.4.193-rt74latency-histograms.patchlatency-histograms.patch
5.4.209-rt77...5.4.209-rt77latency-histograms.patchlatency-histograms.patch
5.4.221-rt79...5.4.221-rt79latency-histograms.patchlatency-histograms.patch
5.4.230-rt80...5.4.230-rt80latency-histograms.patchlatency-histograms.patch
5.4.242-rt81...5.4.242-rt81latency-histograms.patchlatency-histograms.patch
5.4.248-rt83...5.4.248-rt83latency-histograms.patchlatency-histograms.patch
5.4.254-rt85...5.4.254-rt85latency-histograms.patchlatency-histograms.patch
5.4.257-rt87...5.4.257-rt87latency-histograms.patchlatency-histograms.patch
5.4.264-rt88...5.4.278-rt91latency-histograms.patchlatency-histograms.patch
5.6.2-rt1...5.6.2-rt1latency-histograms.patchlatency-histograms.patch
5.6.4-rt2...5.6.4-rt3latency-histograms.patchlatency-histograms.patch
5.6.10-rt5...5.6.10-rt5latency-histograms.patchlatency-histograms.patch
5.6.14-rt6...5.6.17-rt9latency-histograms.patchlatency-histograms.patch
5.6.17-rt10...5.6.19-rt12latency-histograms.patchlatency-histograms.patch
5.9.0-rt16...5.9.1-rt17latency-histograms.patchlatency-histograms.patch
5.9.1-rt18...5.9.1-rt18latency-histograms.patchlatency-histograms.patch
5.9.1-rt19...5.9.1-rt20latency-histograms.patchlatency-histograms.patch
5.10.1-rt19...5.10.1-rt20latency-histograms.patchlatency-histograms.patch
5.10.4-rt21...5.10.4-rt21latency-histograms.patchlatency-histograms.patch
5.10.4-rt22...5.10.8-rt24latency-histograms.patchlatency-histograms.patch
5.10.12-rt25...5.10.12-rt25latency-histograms.patchlatency-histograms.patch
5.10.12-rt26...5.10.12-rt26latency-histograms.patchlatency-histograms.patch
5.10.14-rt27...5.10.14-rt28latency-histograms.patchlatency-histograms.patch
5.10.16-rt29...5.10.17-rt33latency-histograms.patchlatency-histograms.patch
5.10.21-rt34...5.10.21-rt34latency-histograms.patchlatency-histograms.patch
5.10.25-rt35...5.10.25-rt35latency-histograms.patchlatency-histograms.patch
5.10.27-rt36...5.10.27-rt36latency-histograms.patchlatency-histograms.patch
5.10.30-rt37...5.10.35-rt39latency-histograms.patchlatency-histograms.patch
5.10.41-rt42...5.10.41-rt42latency-histograms.patchlatency-histograms.patch
5.10.47-rt45...5.10.47-rt45latency-histograms.patchlatency-histograms.patch
5.10.47-rt46...5.10.56-rt49latency-histograms.patchlatency-histograms.patch
5.10.59-rt51...5.10.59-rt52latency-histograms.patchlatency-histograms.patch
5.10.65-rt53...5.10.78-rt56latency-histograms.patchlatency-histograms.patch
5.10.83-rt58...5.10.90-rt60latency-histograms.patchlatency-histograms.patch
5.10.90-rt61...5.10.106-rt64latency-histograms.patchlatency-histograms.patch
5.10.115-rt67...5.10.115-rt67latency-histograms.patchlatency-histograms.patch
5.10.120-rt70...5.10.120-rt70latency-histograms.patchlatency-histograms.patch
5.10.131-rt72...5.10.131-rt72latency-histograms.patchlatency-histograms.patch
5.10.140-rt73...5.10.153-rt76latency-histograms.patchlatency-histograms.patch
5.10.158-rt77...5.10.158-rt77latency-histograms.patchlatency-histograms.patch
5.10.162-rt78...5.10.168-rt83latency-histograms.patchlatency-histograms.patch
5.10.175-rt84...5.10.176-rt86latency-histograms.patchlatency-histograms.patch
5.10.179-rt87...5.10.180-rt89latency-histograms.patchlatency-histograms.patch
5.10.184-rt90...5.10.186-rt91latency-histograms.patchlatency-histograms.patch
5.10.192-rt92...5.10.192-rt92latency-histograms.patchlatency-histograms.patch
5.10.194-rt94...5.10.194-rt95latency-histograms.patchlatency-histograms.patch
5.10.197-rt96...5.10.209-rt101latency-histograms.patchlatency-histograms.patch
5.10.210-rt102...5.10.216-rt108latency-histograms.patchlatency-histograms.patch
5.10.217-rt109...5.10.223-rt115latency-histograms.patchlatency-histograms.patch
5.10.224-rt116...5.10.224-rt116latency-histograms.patchlatency-histograms.patch
5.10.225-rt117...5.10.225-rt117latency-histograms.patchlatency-histograms.patch
5.11.0-rt4...5.11.0-rt5latency-histograms.patchlatency-histograms.patch
5.11.2-rt8...5.11.2-rt9latency-histograms.patchlatency-histograms.patch
5.14.1-rt19...5.14.2-rt21latency-histograms.patchlatency-histograms.patch
5.15.0-rt16...5.15.2-rt20latency-histograms.patchlatency-histograms.patch
5.15.3-rt21...5.15.3-rt21latency-histograms.patchlatency-histograms.patch
5.15.5-rt22...5.15.5-rt22latency-histograms.patchlatency-histograms.patch
5.15.7-rt23...5.15.26-rt34latency-histograms.patchlatency-histograms.patch
5.15.27-rt35...5.15.32-rt39latency-histograms.patchlatency-histograms.patch
5.15.34-rt40...5.15.34-rt40latency-histograms.patchlatency-histograms.patch
5.15.36-rt41...5.15.36-rt41latency-histograms.patchlatency-histograms.patch
5.15.39-rt42...5.15.43-rt45latency-histograms.patchlatency-histograms.patch
5.15.44-rt46...5.15.44-rt46latency-histograms.patchlatency-histograms.patch
5.15.49-rt47...5.15.49-rt47latency-histograms.patchlatency-histograms.patch
5.15.55-rt48...5.15.55-rt48latency-histograms.patchlatency-histograms.patch
5.15.65-rt49...5.15.76-rt53latency-histograms.patchlatency-histograms.patch
5.15.79-rt54...5.15.86-rt56latency-histograms.patchlatency-histograms.patch
5.15.92-rt57...5.15.95-rt60latency-histograms.patchlatency-histograms.patch
5.15.96-rt61...5.15.96-rt61latency-histograms.patchlatency-histograms.patch
5.15.107-rt62...5.15.107-rt62latency-histograms.patchlatency-histograms.patch
5.15.111-rt63...5.15.125-rt66latency-histograms.patchlatency-histograms.patch
5.15.129-rt67...5.15.136-rt71latency-histograms.patchlatency-histograms.patch
5.15.141-rt72...5.15.153-rt75latency-histograms.patchlatency-histograms.patch
5.15.158-rt76...5.15.158-rt76latency-histograms.patchlatency-histograms.patch
5.15.160-rt77...5.15.160-rt77latency-histograms.patchlatency-histograms.patch
5.16.0-rt15...5.16.1-rt17latency-histograms.patchlatency-histograms.patch
5.16.2-rt19...5.16.2-rt19latency-histograms.patchlatency-histograms.patch
5.17.1-rt17...5.17.1-rt17latency-histograms.patchlatency-histograms.patch
5.18.0-rt11...5.18.0-rt11latency-histograms.patchlatency-histograms.patch
6.0.0-rt11...6.0.5-rt14latency-histograms.patchlatency-histograms.patch
6.1.12-rt6...6.1.12-rt6latency-histograms.patchlatency-histograms.patch
6.1.12-rt7...6.1.12-rt7latency-histograms.patchlatency-histograms.patch
6.1.19-rt8...6.1.19-rt8latency-histograms.patchlatency-histograms.patch
6.1.26-rt8...6.1.27-rt9latency-histograms.patchlatency-histograms.patch
6.1.28-rt10...6.1.38-rt12latency-histograms.patchlatency-histograms.patch
6.1.46-rt13...6.1.46-rt13latency-histograms.patchlatency-histograms.patch
6.1.54-rt15...6.1.59-rt16latency-histograms.patchlatency-histograms.patch
6.1.64-rt17...6.1.77-rt24latency-histograms.patchlatency-histograms.patch
6.1.79-rt25...6.1.83-rt28latency-histograms.patchlatency-histograms.patch
6.1.90-rt30...6.1.92-rt32latency-histograms.patchlatency-histograms.patch
6.1.94-rt33...6.1.99-rt36latency-histograms.patchlatency-histograms.patch
6.1.102-rt37...6.1.102-rt37latency-histograms.patchlatency-histograms.patch
6.1.105-rt38...6.1.105-rt38latency-histograms.patchlatency-histograms.patch
6.1.107-rt39...6.1.107-rt39latency-histograms.patchlatency-histograms.patch
6.1.108-rt40...6.1.111-rt42latency-histograms.patchlatency-histograms.patch
6.2.0-rt2...6.2.0-rt3latency-histograms.patchlatency-histograms.patch
6.3.0-rt11...6.3.1-rt13latency-histograms.patchlatency-histograms.patch
6.3.3-rt15...6.3.3-rt15latency-histograms.patchlatency-histograms.patch
6.4.0-rt6...6.4.0-rt6latency-histograms.patchlatency-histograms.patch
6.4.6-rt8...6.4.6-rt8latency-histograms.patchlatency-histograms.patch
6.5.0-rt6...6.5.2-rt8latency-histograms.patchlatency-histograms.patch
6.6.0-rt12...6.6.0-rt14latency-histograms.patchlatency-histograms.patch
6.6.0-rt15...6.6.0-rt15latency-histograms.patchlatency-histograms.patch
6.6.5-rt16...6.6.5-rt16latency-histograms.patchlatency-histograms.patch
6.6.7-rt17...6.6.15-rt22latency-histograms.patchlatency-histograms.patch
6.6.18-rt23...6.6.25-rt29latency-histograms.patchlatency-histograms.patch
6.6.30-rt30...6.6.30-rt30latency-histograms.patchlatency-histograms.patch
6.6.31-rt31...6.6.32-rt32latency-histograms.patchlatency-histograms.patch
6.6.34-rt33...6.6.43-rt38latency-histograms.patchlatency-histograms.patch
6.6.44-rt39...6.6.44-rt39latency-histograms.patchlatency-histograms.patch
6.6.48-rt40...6.6.50-rt42latency-histograms.patchlatency-histograms.patch
6.6.52-rt43...6.6.53-rt44latency-histograms.patchlatency-histograms.patch
6.6.58-rt45...6.6.58-rt45latency-histograms.patchlatency-histograms.patch
6.7.0-rt6...6.7.0-rt6latency-histograms.patchlatency-histograms.patch
6.8.0-rt8...6.8.0-rt8latency-histograms.patchlatency-histograms.patch
6.8.2-rt10...6.8.2-rt10latency-histograms.patchlatency-histograms.patch
6.9.0-rt5...6.9.0-rt5latency-histograms.patchlatency-histograms.patch
6.10.2-rt12...6.10.2-rt14latency-histograms.patchlatency-histograms.patch
6.11.0-rt7...6.11.0-rt7latency-histograms.patchlatency-histograms.patch