SlideShare a Scribd company logo
© 2016 VMware Inc. All rights
reserved.
© 2016 VMware Inc. All rights
reserved.
Finding sources of Latency
In your system (via tracing tools)
Steven Rostedt
9/24/2018
What is Latency?
2
What is Latency?
3
“Latency is a time interval between the stimulation and
response, or, from a more general point of view, a time
delay between the cause and the effect of some physical
change in the system being observed.” - Wikipedia
What is Latency?
●
The time between
– When something needs to be done
– When that something actually gets done
4
“Latency is a time interval between the stimulation and
response, or, from a more general point of view, a time
delay between the cause and the effect of some physical
change in the system being observed.” - Wikipedia

Recommended for you

P4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC OffloadP4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC Offload

The webinar discussed accelerating P4 and eBPF programs on Netronome SmartNIC hardware. It covered the Linux kernel infrastructure like TC and XDP that supports offloading eBPF programs. It also explained how the NFP architecture is optimized for network flow processing with its multi-core design and memory hierarchy. The webinar demonstrated how eBPF programs can be translated to run efficiently on the NFP hardware by handling maps and applying optimizations.

netronomeopen-nfpebpf
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)

The document provides an overview of the initialization process in the Linux kernel from start_kernel to rest_init. It lists the functions called during this process organized by category including functions for initialization of multiprocessor support (SMP), memory management (MM), scheduling, timers, interrupts, and architecture specific setup. The setup_arch section focuses on x86 architecture specific initialization functions such as reserving memory regions, parsing boot parameters, initializing memory mapping and MTRRs.

linuxinitcallsinitialization
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture

The document discusses Linux networking architecture and covers several key topics in 3 paragraphs or less: It first describes the basic structure and layers of the Linux networking stack including the network device interface, network layer protocols like IP, transport layer, and sockets. It then discusses how network packets are managed in Linux through the use of socket buffers and associated functions. The document also provides an overview of the data link layer and protocols like Ethernet, PPP, and how they are implemented in Linux.

linux kernel networking
What is Latency?
●
The time between
– When something needs to be done
– When that something actually gets done
●
The time between
– When something happens
– When it is seen
5
“Latency is a time interval between the stimulation and
response, or, from a more general point of view, a time
delay between the cause and the effect of some physical
change in the system being observed.” - Wikipedia
There is ALWAYS Latency
●
Nothing happens instantaneously
●
There’s always going to be some “lag”
●
Real Time systems avoid “Unbounded Latency”
– When all latency is bound to a worse case scenario
– Any latency that is indeterminate can cause problems
●
Non Real-Time systems still care about latency
6
Why do we care about Latency?
●
For Real Time tasks, it is critical
– Need to know worse case latency
– Guarantee that it can achieve its objective
●
Don’t want airplane flaps to not react quick enough!
Why do we care about Latency?
●
Practically everyone/everything cares about Latency
– How long would you wait for ‘a’ to show up after clicking ‘a’?
– A search result that takes 5 minutes to answer!
– All systems are therefore “real time”!
●
Needs to be bounded to some arbitrary number
●
Latency adds up
– A system’s latency is the combination of its sub-components

Recommended for you

Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V

This document summarizes a presentation on static partitioning virtualization for RISC-V. It discusses the motivation for embedded virtualization, an overview of static partitioning hypervisors like Jailhouse and Xen, and the Bao hypervisor. It then provides an overview of the RISC-V hypervisor specification and extensions, including implemented features. It evaluates the performance overhead and interrupt latency of a prototype RISC-V hypervisor implementation with and without interference mitigations like cache partitioning.

risc-v summit 2020risc-v
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF

Using the new extended Berkley Packet Filter capabilities in Linux to the improve performance of auditing security relevant kernel events around network, file and process actions.

securitymonitoringlinux
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsJava Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs

This document discusses using Linux perf_events (perf) profiling tools to analyze Java performance on Linux. It describes how perf can provide complete visibility into Java, JVM, GC and system code but that Java profilers have limitations. It presents the solution of using perf to collect mixed-mode flame graphs that include Java method names and symbols. It also discusses fixing issues with broken Java stacks and missing symbols on x86 architectures in perf profiles.

javaperformance
Where is that Latency?
●
Latency adds up
– A system’s latency is the combination of its sub-components
●
It can be hard finding where your latency is
●
What causes it
– The application
– The libraries
– The operating system
– The hardware
Where is that Latency?
HARDWARE
Kernel
Library
Application
BIOS
Hardware Latency
●
Can’t get better than what the hardware gives you
●
Sources of HW latency
– System Management Interrupts (SMI)
●
The BIOS takes over the machine
– Clock frequency
●
The system slows down
– Cache line bouncing
●
Sharing the same variable among CPUs
Cyclictest
●
A tool to measure latency
●
Runs a simple loop (in a high priority task)
– Sleep for a specified time
– Get timestamp when wakes up
– Compare the difference
●
Best to use nanosleep
– Can also use signals, but that has high latency!
●
Favorite application of the Linux RT folks

Recommended for you

The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage

The arrival of flash storage introduced a radical change in performance profiles of direct attached devices. At the time, it was obvious that Linux I/O stack needed to be redesigned in order to support devices capable of millions of IOPs, and with extremely low latency. In this talk we revisit the changes the Linux block layer in the last decade or so, that made it what it is today - a performant, scalable, robust and NUMA-aware subsystem. In addition, we cover the new NVMe over Fabrics support in Linux. Sagi Grimberg Sagi is Principal Architect and co-founder at LightBits Labs.

scalingkernelkerneltlv
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel

Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).

linux kernelmemory mappingmmap
Velocity 2015 linux perf tools
Velocity 2015 linux perf toolsVelocity 2015 linux perf tools
Velocity 2015 linux perf tools

Video: https://www.youtube.com/watch?v=FJW8nGV4jxY and https://www.youtube.com/watch?v=zrr2nUln9Kk . Tutorial slides for O'Reilly Velocity SC 2015, by Brendan Gregg. There are many performance tools nowadays for Linux, but how do they all fit together, and when do we use them? This tutorial explains methodologies for using these tools, and provides a tour of four tool types: observability, benchmarking, tuning, and static tuning. Many tools will be discussed, including top, iostat, tcpdump, sar, perf_events, ftrace, SystemTap, sysdig, and others, as well observability frameworks in the Linux kernel: PMCs, tracepoints, kprobes, and uprobes. This tutorial is updated and extended on an earlier talk that summarizes the Linux performance tool landscape. The value of this tutorial is not just learning that these tools exist and what they do, but hearing when and how they are used by a performance engineer to solve real world problems — important context that is typically not included in the standard documentation.

linux performance tools tracing
Cyclictest
start = gettimeofday()
Sleep 250us
user-space
kernel
Put task to sleep
Set interrupt timer for 250us
Timer Interrupt goes off
Wake up Task
Schedule Taskend = gettimeofday()
jitter = (end - start) - 250us
250us
Cyclictest
start = gettimeofday()
Sleep 250us
user-space
kernel
Put task to sleep
Set interrupt timer for 250us
Timer Interrupt goes off
Wake up Task
Schedule Taskend = gettimeofday()
jitter = (end - start) - 250us
250us
latency (jitter)
Cyclictest
start = gettimeofday()
Sleep 250us
user-space
kernel
Put task to sleep
Set interrupt timer for 250us
Timer Interrupt goes off
Wake up Task
Schedule Taskend = gettimeofday()
jitter = (end - start) - 250us
250us
latency (jitter)
interrupt latency
Cyclictest
start = gettimeofday()
Sleep 250us
user-space
kernel
Put task to sleep
Set interrupt timer for 250us
Timer Interrupt goes off
Wake up Task
Schedule Taskend = gettimeofday()
jitter = (end - start) - 250us
250us
latency (jitter)
interrupt latency
wakeuplatency

Recommended for you

Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF Superpowers

Talk for USENIX LISA 2016 by Brendan Gregg. "Linux 4.x Tracing Tools: Using BPF Superpowers The Linux 4.x series heralds a new era of Linux performance analysis, with the long-awaited integration of a programmable tracer: Enhanced BPF (eBPF). Formally the Berkeley Packet Filter, BPF has been enhanced in Linux to provide system tracing capabilities, and integrates with dynamic tracing (kprobes and uprobes) and static tracing (tracepoints and USDT). This has allowed dozens of new observability tools to be developed so far: for example, measuring latency distributions for file system I/O and run queue latency, printing details of storage device I/O and TCP retransmits, investigating blocked stack traces and memory leaks, and a whole lot more. These lead to performance wins large and small, especially when instrumenting areas that previously had zero visibility. Tracing superpowers have finally arrived. In this talk I'll show you how to use BPF in the Linux 4.x series, and I'll summarize the different tools and front ends available, with a focus on iovisor bcc. bcc is an open source project to provide a Python front end for BPF, and comes with dozens of new observability tools (many of which I developed). These tools include new BPF versions of old classics, and many new tools, including: execsnoop, opensnoop, funccount, trace, biosnoop, bitesize, ext4slower, ext4dist, tcpconnect, tcpretrans, runqlat, offcputime, offwaketime, and many more. I'll also summarize use cases and some long-standing issues that can now be solved, and how we are using these capabilities at Netflix."

linux performance tracinglinuxperformance
Linux Profiling at Netflix
Linux Profiling at NetflixLinux Profiling at Netflix
Linux Profiling at Netflix

This talk discusses Linux profiling using perf_events (also called "perf") based on Netflix's use of it. It covers how to use perf to get CPU profiling working and overcome common issues. The speaker will give a tour of perf_events features and show how Netflix uses it to analyze performance across their massive Amazon EC2 Linux cloud. They rely on tools like perf for customer satisfaction, cost optimization, and developing open source tools like NetflixOSS. Key aspects covered include why profiling is needed, a crash course on perf, CPU profiling workflows, and common "gotchas" to address like missing stacks, symbols, or profiling certain languages and events.

BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)

USENIX LISA2021 talk by Brendan Gregg (https://www.youtube.com/watch?v=_5Z2AU7QTH4). This talk is a deep dive that describes how BPF (eBPF) works internally on Linux, and dissects some modern performance observability tools. Details covered include the kernel BPF implementation: the verifier, JIT compilation, and the BPF execution environment; the BPF instruction set; different event sources; and how BPF is used by user space, using bpftrace programs as an example. This includes showing how bpftrace is compiled to LLVM IR and then BPF bytecode, and how per-event data and aggregated map data are fetched from the kernel.

bpfebpflinux
Cyclictest
●
The options I am using here
– “-p80” : set the starting priority to 80
– “-i250” : set the starting interval to 250 microseconds
●
Sets nanosleep to the next 250 microsend interval
– “-n” : use nanosleep and not POSIX timers
●
POSIX timers will use signals, they have horrible latency
– “-a” : Set affinity of a task to each CPU
– “-t” : one thread per available processor (or logical CPU)
– “-q” : keep quiet while running
– “-d0” : Keep the interval the same for all threads (all at 250 microseconds)
The tools
●
Measuring latency
– cyclictest
●
Using Tracing tools can help find what’s happening
– Ftrace
●
hwlat
●
function and function graph tracer
●
event tracer
●
trace-cmd / KernelShark
– Lockdep (lock contention)
– Perf
●
profiling
●
statistics
– Many others (but I’m focusing on the Ftrace and and a bit of Lockdep)
Hardware Latency
●
Can’t get better than what the hardware gives you
●
Sources of HW latency
– System Management Interrupts (SMI)
●
The BIOS takes over the machine
– Clock frequency
●
The system slows down
– Cache line bouncing
●
Sharing the same variable among CPUs
Hardware Latency Detector
●
Part of Ftrace
– CONFIG_HWLAT_TRACER (in kernel .config build file)
●
cd /sys/kernel/tracing (tracefs directory)
– mount -t tracefs nodev /sys/kernel/tracing
●
echo hwlat > current_tracer
●
cat trace

Recommended for you

XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM SystemsXPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems

The motivation of hypervisor based CPUFreq is to enable the one of the main PM use-cases (Dynamic voltage and frequency scaling) in virtualized system powered by Xen hypervisor. Rationale behind this activity is that CPU virtualization is done by hypervisor and the guest OS doesn't actually know anything about physical CPUs because it is running on virtual CPUs. In this talk Oleksandr will briefly describe the possible approach of generic CPUFreq in Xen on ARM, the advantages and disadvantages of having DVFS support on ARM boards powered by Xen hypervisor and share results of his CPUFreq PoC which implies power consumption measurements with and without CPUFreq enabled on R-Car Gen3 based board as an example.

xenxppds18realtime
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and more

Video: https://www.youtube.com/watch?v=JRFNIKUROPE . Talk for linux.conf.au 2017 (LCA2017) by Brendan Gregg, about Linux enhanced BPF (eBPF). Abstract: A world of new capabilities is emerging for the Linux 4.x series, thanks to enhancements that have been included in Linux for to Berkeley Packet Filter (BPF): an in-kernel virtual machine that can execute user space-defined programs. It is finding uses for security auditing and enforcement, enhancing networking (including eXpress Data Path), and performance observability and troubleshooting. Many new open source tools that have been written in the past 12 months for performance analysis that use BPF. Tracing superpowers have finally arrived for Linux! For its use with tracing, BPF provides the programmable capabilities to the existing tracing frameworks: kprobes, uprobes, and tracepoints. In particular, BPF allows timestamps to be recorded and compared from custom events, allowing latency to be studied in many new places: kernel and application internals. It also allows data to be efficiently summarized in-kernel, including as histograms. This has allowed dozens of new observability tools to be developed so far, including measuring latency distributions for file system I/O and run queue latency, printing details of storage device I/O and TCP retransmits, investigating blocked stack traces and memory leaks, and a whole lot more. This talk will summarize BPF capabilities and use cases so far, and then focus on its use to enhance Linux tracing, especially with the open source bcc collection. bcc includes BPF versions of old classics, and many new tools, including execsnoop, opensnoop, funcccount, ext4slower, and more (many of which I developed). Perhaps you'd like to develop new tools, or use the existing tools to find performance wins large and small, especially when instrumenting areas that previously had zero visibility. I'll also summarize how we intend to use these new capabilities to enhance systems analysis at Netflix.

linuxperformancebpf
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver

This document provides an overview of the data structures and functions used to implement ethernet drivers in the Linux kernel. It discusses the net_device and sk_buff structures that represent network interfaces and packets. It also describes how the driver interacts with the kernel via polling, interrupts, and NAPI to handle reception and transmission of frames. Finally, it provides an example of the key components needed for a simple ethernet driver, including initialization, setup, open/close, transmission, and reception functions.

ethernetlinuxkernel
Hardware Latency Detector
# cd /sys/kernel/tracing
# echo hwlat > current_tracer
# sleep 10
# cat trace
# tracer: hwlat
#
# entries-in-buffer/entries-written: 7/7 #P:4
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
<...>-824 [001] d... 32.550243: #1 inner/outer(us): 59/53 ts:1537661092.117956843
<...>-824 [003] d... 34.562563: #3 inner/outer(us): 57/56 ts:1537661094.127959000
<...>-824 [000] d... 35.570670: #4 inner/outer(us): 55/55 ts:1537661095.138960084
<...>-824 [001] d... 36.578486: #5 inner/outer(us): 58/187 ts:1537661096.130961148
<...>-824 [003] d... 38.594465: #7 inner/outer(us): 27/26 ts:1537661098.156963322
<...>-824 [000] d... 39.602465: #8 inner/outer(us): 28/70 ts:1537661099.157964396
<...>-824 [001] d... 40.610903: #9 inner/outer(us): 1743/204 ts:1537661100.139965450
#
Hardware Latency Detector
# cd /sys/kernel/tracing
# echo hwlat > current_tracer
# sleep 10
# cat trace
# tracer: hwlat
#
# entries-in-buffer/entries-written: 7/7 #P:4
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
<...>-824 [001] d... 32.550243: #1 inner/outer(us): 59/53 ts:1537661092.117956843
<...>-824 [003] d... 34.562563: #3 inner/outer(us): 57/56 ts:1537661094.127959000
<...>-824 [000] d... 35.570670: #4 inner/outer(us): 55/55 ts:1537661095.138960084
<...>-824 [001] d... 36.578486: #5 inner/outer(us): 58/187 ts:1537661096.130961148
<...>-824 [003] d... 38.594465: #7 inner/outer(us): 27/26 ts:1537661098.156963322
<...>-824 [000] d... 39.602465: #8 inner/outer(us): 28/70 ts:1537661099.157964396
<...>-824 [001] d... 40.610903: #9 inner/outer(us): 1743/204 ts:1537661100.139965450
#
Hardware Latency Detector
# cd /sys/kernel/tracing
# echo hwlat > current_tracer
# sleep 10
# cat trace
# tracer: hwlat
#
# entries-in-buffer/entries-written: 7/7 #P:4
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
<...>-824 [001] d... 32.550243: #1 inner/outer(us): 59/53 ts:1537661092.117956843
<...>-824 [003] d... 34.562563: #3 inner/outer(us): 57/56 ts:1537661094.127959000
<...>-824 [000] d... 35.570670: #4 inner/outer(us): 55/55 ts:1537661095.138960084
<...>-824 [001] d... 36.578486: #5 inner/outer(us): 58/187 ts:1537661096.130961148
<...>-824 [003] d... 38.594465: #7 inner/outer(us): 27/26 ts:1537661098.156963322
<...>-824 [000] d... 39.602465: #8 inner/outer(us): 28/70 ts:1537661099.157964396
<...>-824 [001] d... 40.610903: #9 inner/outer(us): 1743/204 ts:1537661100.139965450
#
Hardware Latency Algorithm
●
Runs a kernel thread
●
Does a tight loop for a period of time
●
Interrupts are disabled (during the loop)
●
Moves around all CPUs
●
Records when the timestamp happened
●
Denotes if it happened inside or outside the double timestamp

Recommended for you

Memory Compaction in Linux Kernel.pdf
Memory Compaction in Linux Kernel.pdfMemory Compaction in Linux Kernel.pdf
Memory Compaction in Linux Kernel.pdf

Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).

linux kernelphysical memory managementmemory compaction
eBPF Perf Tools 2019
eBPF Perf Tools 2019eBPF Perf Tools 2019
eBPF Perf Tools 2019

The document describes a biolatency tool that traces block device I/O latency using eBPF. It discusses how the tool was originally written in the bcc framework using C/BPF, but has since been rewritten in the bpftrace framework using a simpler one-liner script. It provides examples of the bcc and bpftrace implementations of biolatency.

ebpfbpfperformance
Using Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance TroublesUsing Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance Troubles

Trying to figure out why your application is responding late can be difficult, especially if it is because of interference from the operating system. This talk will briefly go over how to write a C program that can analyze what in the Linux system is interfering with your application. It will use trace-cmd to enable kernel trace events as well as tracing lock functions, and it will then go over a quick tutorial on how to use libtracecmd to read the created trace.dat file to uncover what is the cause of interference to you application.

t1 = time_get()
t2 = time_get()
last_t2 == 0
last_t2 = 0
diff = t1 - last_t2
diff > outer
diff = t2 - t1
diff > inner
outer = diff
inner = diff
time < width
exit loop
Hardware Latency Detector
# cd /sys/kernel/tracing
# cat hwlat_detector/width
500000
# cat hwlat_detector/window
1000000
# cat tracing_thresh
10
●
Spin for “width” microseconds
●
Every “window” microseconds
●
Record a trace if the diff is greater than “tracing_thresh” microseconds
Hardware Latency Detector (with NMIs)
●
It checks if an NMI triggered
●
NMIs are not hardware, but software controlled (in most cases)
●
nmi-total - The total time in NMI during the loop
●
nmi-count - The number of NMIs that were triggered
Hardware Latency Detector (With NMIs)
# cd /sys/kernel/tracing
# echo hwlat > current_tracer
# sleep 10
# cat trace
# tracer: hwlat
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
<...>-3808 [002] d... 123.942240: #1 inner/outer(us): 16/16 ts:1537718580.955027586
<...>-3808 [003] d... 124.962222: #2 inner/outer(us): 1/270 ts:1537718581.975050306
<...>-3808 [002] dn.. 128.034081: #3 inner/outer(us): 15/17 ts:1537718585.047027453
<...>-3808 [000] d... 130.082010: #4 inner/outer(us): 17/16 ts:1537718587.095030248 nmi-total:3 nmi-count:1
<...>-3808 [002] d... 132.129965: #5 inner/outer(us): 17/17 ts:1537718589.143062081
<...>-3808 [003] dn.. 133.153926: #6 inner/outer(us): 0/12 ts:1537718590.167059283
<...>-3808 [002] d... 136.225843: #8 inner/outer(us): 18/16 ts:1537718593.239082103
<...>-3808 [000] d... 138.273758: #9 inner/outer(us): 16/20 ts:1537718595.287066663
<...>-3808 [001] dn.. 139.297681: #10 inner/outer(us): 267/0 ts:1537718596.311023829
<...>-3808 [002] dn.. 140.321648: #11 inner/outer(us): 16/24 ts:1537718597.335024977
<...>-3808 [000] d... 142.369656: #12 inner/outer(us): 13/17 ts:1537718599.383044893
<...>-3808 [002] d... 144.417670: #13 inner/outer(us): 18/13 ts:1537718601.431050150
<...>-3808 [003] dn.. 145.441679: #14 inner/outer(us): 18/18 ts:1537718602.455056453
<...>-3808 [000] dn.. 146.465671: #15 inner/outer(us): 17/13 ts:1537718603.479046139
<...>-3808 [001] d... 147.489654: #16 inner/outer(us): 0/13 ts:1537718604.503027858
<...>-3808 [003] d... 149.537637: #17 inner/outer(us): 18/11 ts:1537718606.551010895
<...>-3808 [002] dn.. 152.609690: #18 inner/outer(us): 18/18 ts:1537718609.623070128
<...>-3808 [003] d... 153.633627: #19 inner/outer(us): 0/18 ts:1537718610.647010083 nmi-total:4 nmi-count:1
<...>-3808 [001] d... 155.685648: #20 inner/outer(us): 1/12 ts:1537718612.699039876
#

Recommended for you

10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX Security

In this PowerPoint, learn how a security policy can be your first line of defense. Servers running AIX and other operating systems are frequent targets of cyberattacks, according to the Data Breach Investigations Report. From DoS attacks to malware, attackers have a variety of strategies at their disposal. Having a security policy in place makes it easier to ensure you have appropriate controls in place to protect mission-critical data.

aixpassword policysecurity software
BUD17-309: IRQ prediction
BUD17-309: IRQ prediction BUD17-309: IRQ prediction
BUD17-309: IRQ prediction

"Session ID: BUD17-309 Session Name: IRQ prediction - BUD17-309 Speaker: Daniel Lezcano Track: Power Management ★ Session Summary ★ The CPUidle is one component of the power management framework. It behaves in an opportunistic way when there is nothing to do on the system, by trying to predict the next CPU wake up and select an idle state. But the current design has some weaknesses as it mixes the different sources of wakeup, resulting in an already non-deterministic situation getting worse. This presentation will describe the issues faced with the current approach and will show another approach to predict the next wake up event with a better accuracy, leading, under some circumstances, to 100% right predictions. --------------------------------------------------- ★ Resources ★ Event Page: http://connect.linaro.org/resource/bud17/bud17-309/ Presentation: https://www.slideshare.net/linaroorg/bud17309-irq-prediction Video: https://youtu.be/krFAyi1ietI --------------------------------------------------- ★ Event Details ★ Linaro Connect Budapest 2017 (BUD17) 6-10 March 2017 Corinthia Hotel, Budapest, Erzsébet krt. 43-49, 1073 Hungary --------------------------------------------------- Keyword: IRQ, power-management, CPUidle http://www.linaro.org http://connect.linaro.org --------------------------------------------------- Follow us on Social Media https://www.facebook.com/LinaroOrg https://twitter.com/linaroorg https://www.youtube.com/user/linaroorg?sub_confirmation=1 https://www.linkedin.com/company/1026961"

linaroconnectbud17-309bud17
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?

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 application. Moreover, hardware-related jobs can also cause noise, for example, via SMIs. HPC users and developers that care about every microsecond stolen by the OS need not only a precise way to measure the osnoise but mainly to figure out who is stealing cpu time so that they can pursue the perfect tune of the system. These users and developers are the inspiration of Linux's osnoise tracer. The osnoise tracer runs an in-kernel loop measuring how much time is available. It does it with preemption, softirq and IRQs enabled, thus allowing all the sources of osnoise during its execution. The osnoise tracer takes note of the entry and exit point of any source of interferences. When the noise happens without any interference from the operating system level, the tracer can safely point to a hardware-related noise. In this way, osnoise can account for any source of interference. The osnoise tracer also adds new kernel tracepoints that auxiliaries the user to point to the culprits of the noise in a precise and intuitive way. At the end of a 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, serving as a benchmark tool.

p99 latencyp99 confhigh throughput and low latency
If that’s not the problem?
●
What if the hardware is fine?
●
What else could it be?
●
The Kernel?
●
Your application?
Kernel Entry Tracing (more than strace)
# echo 1 > /sys/kernel/tracing/options/function-fork
# trace-cmd record -F -c -p function_graph --max-graph-depth 1 -e syscalls 
./cyclictest -p80 -i250 -n -a -t -q -d 0
plugin 'function_graph'
# /dev/cpu_dma_latency set to 0us
^C
T: 0 ( 9645) P:80 I:250 C: 45482 Min: 4 Act: 10 Avg: 6 Max: 1189
T: 1 ( 9646) P:80 I:250 C: 45486 Min: 5 Act: 10 Avg: 5 Max: 297
T: 2 ( 9647) P:80 I:250 C: 45491 Min: 5 Act: 9 Avg: 6 Max: 106
T: 3 ( 9648) P:80 I:250 C: 45491 Min: 5 Act: 11 Avg: 5 Max: 69
CPU0 data recorded at offset=0x60c000
10473472 bytes in size
CPU1 data recorded at offset=0x1009000
10416128 bytes in size
CPU2 data recorded at offset=0x19f8000
10432512 bytes in size
CPU3 data recorded at offset=0x23eb000
10366976 bytes in size
Kernel Entry Tracing (more than strace)
# echo 1 > /sys/kernel/tracing/options/function-fork
# trace-cmd record -F -c -p function_graph --max-graph-depth 1 -e syscalls 
./cyclictest -p80 -i250 -n -a -t -q -d 0
plugin 'function_graph'
# /dev/cpu_dma_latency set to 0us
^C
T: 0 ( 9645) P:80 I:250 C: 45482 Min: 4 Act: 10 Avg: 6 Max: 1189
T: 1 ( 9646) P:80 I:250 C: 45486 Min: 5 Act: 10 Avg: 5 Max: 297
T: 2 ( 9647) P:80 I:250 C: 45491 Min: 5 Act: 9 Avg: 6 Max: 106
T: 3 ( 9648) P:80 I:250 C: 45491 Min: 5 Act: 11 Avg: 5 Max: 69
CPU0 data recorded at offset=0x60c000
10473472 bytes in size
CPU1 data recorded at offset=0x1009000
10416128 bytes in size
CPU2 data recorded at offset=0x19f8000
10432512 bytes in size
CPU3 data recorded at offset=0x23eb000
10366976 bytes in size
More Efficient Trace
# trace-cmd report -F 'funcgraph_entry'| cut -d'|' -f 2 | cut -d'(' -f1 | sort -u
cpus=4
do_IRQ
__do_page_fault
do_syscall_64
exit_to_usermode_loop
fsnotify
__fsnotify_parent
__f_unlock_pos
mutex_unlock
__sb_end_write
schedule_tail
smp_apic_timer_interrupt
smp_irq_work_interrupt
syscall_slow_exit_work

Recommended for you

Let's write a Debugger!
Let's write a Debugger!Let's write a Debugger!
Let's write a Debugger!

A short, introductory talk to the world of debuggers. During the talk, we write a simple debugger application in Rust. Video at: https://www.youtube.com/watch?v=qS51kIHWARM

rustdebuggertalk
Interrupts.ppt
Interrupts.pptInterrupts.ppt
Interrupts.ppt

This document discusses interrupts, exceptions, and system calls in operating systems. It begins by explaining that the OS is event-driven and only executes when there is an interrupt, trap, or system call. It then describes the different event types - interrupts, exceptions, and how hardware interrupts are handled using interrupt controllers like the 8259 PIC and APIC. It discusses interrupt vectors, interrupt descriptor tables, and how the CPU switches to the interrupt handler. Finally, it covers system calls and exceptions as a type of software interrupt, providing an example of the write system call.

Servers and Processes: Behavior and Analysis
Servers and Processes: Behavior and AnalysisServers and Processes: Behavior and Analysis
Servers and Processes: Behavior and Analysis

This document provides an overview of servers, processes, and system administration. It discusses servers as machines made up of components like RAM, CPU, and I/O. It then covers these components and their capacities, as well as processes and how they interact with servers through system calls. Hands-on examples are provided to demonstrate monitoring servers and investigating processes using tools like top, lsof, strace, and vmstat.

More Efficient Trace (I need to make this easier)
# trace-cmd record -F -c -p function_graph --max-graph-depth 1 -e syscalls 
-l do_IRQ -l __do_page_fault -l do_syscall_64 -l exit_to_usermode_loop -l fsnotify 
-l __fsnotify_parent -l __f_unlock_pos -l mutex_unlock -l __sb_end_write 
-l schedule_tail -l smp_apic_timer_interrupt -l smp_irq_work_interrupt 
-l syscall_slow_exit_work 
./cyclictest -p80 -i250 -n -a -t -q -d 0
plugin 'function_graph'
# /dev/cpu_dma_latency set to 0us
^C
T: 0 ( 2216) P:80 I:250 C: 195012 Min: 2 Act: 13 Avg: 4 Max: 309
T: 1 ( 2217) P:80 I:250 C: 195015 Min: 2 Act: 5 Avg: 3 Max: 227
T: 2 ( 2218) P:80 I:250 C: 195014 Min: 2 Act: 5 Avg: 3 Max: 283
T: 3 ( 2219) P:80 I:250 C: 195014 Min: 2 Act: 5 Avg: 3 Max: 276
CPU0 data recorded at offset=0x60c000
15847424 bytes in size
CPU1 data recorded at offset=0x1529000
15884288 bytes in size
CPU2 data recorded at offset=0x244f000
15859712 bytes in size
CPU3 data recorded at offset=0x336f000
15884288 bytes in size
More Accurate Trace
# trace-cmd report | less
cpus=4
cyclictest-10668 [003] 16938.997362: funcgraph_entry: | mutex_unlock() {
cyclictest-10668 [003] 16938.997366: funcgraph_entry: 8.785 us | smp_irq_work_interrupt();
cyclictest-10668 [003] 16938.997377: funcgraph_exit: 0.142 us | }
cyclictest-10668 [003] 16938.997378: funcgraph_entry: 0.215 us | __fsnotify_parent();
cyclictest-10668 [003] 16938.997379: funcgraph_entry: 0.218 us | fsnotify();
cyclictest-10668 [003] 16938.997380: funcgraph_entry: 0.298 us | __sb_end_write();
cyclictest-10668 [003] 16938.997382: funcgraph_entry: 0.284 us | __f_unlock_pos();
cyclictest-10668 [003] 16938.997383: funcgraph_entry: | syscall_slow_exit_work() {
cyclictest-10668 [003] 16938.997384: sys_exit_write: 0x1
cyclictest-10668 [003] 16938.997388: funcgraph_exit: 4.939 us | }
cyclictest-10668 [003] 16938.997396: funcgraph_entry: 8.209 us | __do_page_fault();
cyclictest-10668 [003] 16938.997411: funcgraph_entry: | do_syscall_64() {
cyclictest-10668 [003] 16938.997412: sys_enter_execve: filename: 0x7fff9e60de96, argv:
0x7fff9e60c028, envp: 0x7fff9e60c078
cyclictest-10668 [003] 16938.997777: sys_exit_execve: 0x0
cyclictest-10668 [003] 16938.997782: funcgraph_exit: ! 370.796 us | }
cyclictest-10668 [003] 16938.997786: funcgraph_entry: 5.508 us | __do_page_fault();
cyclictest-10668 [003] 16938.997795: funcgraph_entry: 1.665 us | __do_page_fault();
cyclictest-10668 [003] 16938.997799: funcgraph_entry: 5.009 us | __do_page_fault();
cyclictest-10668 [003] 16938.997808: funcgraph_entry: 1.277 us | __do_page_fault();
cyclictest-10668 [003] 16938.997813: funcgraph_entry: 2.288 us | __do_page_fault();
cyclictest-10668 [003] 16938.997819: funcgraph_entry: 4.597 us | __do_page_fault();
cyclictest-10668 [003] 16938.997827: funcgraph_entry: 5.344 us | __do_page_fault();
cyclictest-10668 [003] 16938.997843: funcgraph_entry: | do_syscall_64() {
cyclictest-10668 [003] 16938.997844: sys_enter_brk: brk: 0x00000000
More Accurate Trace
cyclictest-10670 [001] 16939.002227: funcgraph_entry: | do_syscall_64() {
cyclictest-10670 [001] 16939.002228: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags:
0x00000001, rqtp: 0x7fe7d41b4920, rmtp: 0x00000000
cyclictest-10671 [002] 16939.002315: sys_exit_clock_nanosleep: 0x0
cyclictest-10671 [002] 16939.002316: funcgraph_exit: ! 247.647 us | }
cyclictest-10671 [002] 16939.002317: funcgraph_entry: | do_syscall_64() {
cyclictest-10671 [002] 16939.002318: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags:
0x00000001, rqtp: 0x7fe7d39b3920, rmtp: 0x00000000
cyclictest-10672 [003] 16939.002400: sys_exit_clock_nanosleep: 0x0
cyclictest-10672 [003] 16939.002400: funcgraph_exit: ! 247.792 us | }
cyclictest-10672 [003] 16939.002402: funcgraph_entry: | do_syscall_64() {
cyclictest-10672 [003] 16939.002403: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags:
0x00000001, rqtp: 0x7fe7d31b2920, rmtp: 0x00000000
cyclictest-10669 [000] 16939.002416: sys_exit_clock_nanosleep: 0x0
cyclictest-10669 [000] 16939.002417: funcgraph_exit: ! 247.622 us | }
cyclictest-10669 [000] 16939.002418: funcgraph_entry: | do_syscall_64() {
cyclictest-10669 [000] 16939.002419: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags:
0x00000001, rqtp: 0x7fe7d49b5920, rmtp: 0x00000000
cyclictest-10670 [001] 16939.002475: sys_exit_clock_nanosleep: 0x0
cyclictest-10670 [001] 16939.002475: funcgraph_exit: ! 247.777 us | }
cyclictest-10670 [001] 16939.002477: funcgraph_entry: | do_syscall_64() {
cyclictest-10670 [001] 16939.002478: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags:
0x00000001, rqtp: 0x7fe7d41b4920, rmtp: 0x00000000
cyclictest-10671 [002] 16939.002565: sys_exit_clock_nanosleep: 0x0
cyclictest-10671 [002] 16939.002566: funcgraph_exit: ! 247.713 us | }
Wakeup Latency
●
The time a task wakes up, to the time it is scheduled
●
“wakeup” tracer
– Traces the time of the highest priority task (RT or Not)
– Interesting, but not very useful (hides RT task latency)
●
“wakeup_rt” tracer
– Only monitors RT tasks
●
trace-cmd record -p wakeup_rt -d -e all
– “-d” - disable function tracing
– “-e all” enable all events
36

Recommended for you

When the OS gets in the way
When the OS gets in the wayWhen the OS gets in the way
When the OS gets in the way

Modern operating systems are complex beasts, responsible for sharing hardware resources between many competing programs. For low-latency systems, sometimes it's necessary to subvert the OS to grab back the resources your program needs. In this talk, we will explore what is actually going on when you run a program, how much time it actually gets on CPU, and strategies to help make your code run as fast as possible. By the end of this talk, you will know how to tune your software and the linux kernel to get the most from your hardware, and more importantly, how to validate that your changes have worked.

performance tuning low-latency
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn

While probably the most prominent, Docker is not the only tool for building and managing containers. Originally meant to be a "chroot on steroids" to help debug systemd, systemd-nspawn provides a fairly uncomplicated approach to work with containers. Being part of systemd, it is available on most recent distributions out-of-the-box and requires no additional dependencies. This deck will introduce a few concepts involved in containers and will guide you through the steps of building a container from scratch. The payload will be a simple service, which will be automatically activated by systemd when the first request arrives.

linuxsystemdcontainers
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdfWeek 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf

This document discusses time measurement in embedded systems. It explains that most embedded applications need to measure time for functions like auto power off, playing media, and measuring elapsed time. It also discusses real-time systems and the difference between hard and soft real-time constraints. Examples of needing real-time measurement include missile control and autonomous vehicles. The document then talks about different ways to measure time on embedded platforms like Arduino and ESP32 using millis(), micros(), and interrupts. It provides examples of using delays or interrupts to trigger a task repeatedly every second. Finally, it provides homework questions involving measuring elapsed time and triggering tasks using delays or interrupts on Arduino or C/C++.

Wakeup Latency
# trace-cmd start -p wakeup_rt -d -e all
# ./cyclictest -p80 -i250 -n -a -t -q -d 0
# /dev/cpu_dma_latency set to 0us
^C
T: 0 (12864) P:80 I:250 C:1237799 Min: 7 Act: 12 Avg: 9 Max: 433
T: 1 (12865) P:80 I:250 C:1237794 Min: 4 Act: 15 Avg: 9 Max: 285
T: 2 (12866) P:80 I:250 C:1237790 Min: 7 Act: 12 Avg: 9 Max: 325
T: 3 (12867) P:80 I:250 C:1237798 Min: 6 Act: 12 Avg: 9 Max: 276
Wakeup Latency
# trace-cmd show | less
# tracer: wakeup_rt
#
# wakeup_rt latency trace v1.1.5 on 4.19.0-rc4-test+
# --------------------------------------------------------------------
# latency: 319 us, #2072/2072, CPU#2 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4)
# -----------------
# | task: cyclictest-12866 (uid:0 nice:0 policy:1 rt_prio:80)
# -----------------
#
# _------=> CPU#
# / _-----=> irqs-off
# | / _----=> need-resched
# || / _---=> hardirq/softirq
# ||| / _--=> preempt-depth
# |||| / delay
# cmd pid ||||| time | caller
#  / |||||  | /
Chrome_I-6675 3...1 0us : preempt_enable: caller=__sb_start_write+0x89/0xc0 parent=__sb_start_write+0x89/0xc0
<...>-42 2dNh4 0us : 42:139:R + [002] 12866: 19:R <...>
Chrome_I-6675 3d..2 0us : irq_disable: caller=rcu_irq_exit_irqson+0x1c/0x50 parent= (null)
<...>-42 2dNh4 0us : 0
<idle>-0 0dN.1 0us : rcu_utilization: Start context switch
Chrome_I-6675 3d..2 0us : irq_enable: caller=rcu_irq_exit_irqson+0x40/0x50 parent= (null)
<...>-42 2dNh1 0us : hrtimer_expire_exit: hrtimer=00000000f472f709
<idle>-0 0dN.1 0us : rcu_utilization: End context switch
<...>-42 2dNh1 1us : write_msr: 6e0, value 2e20f26e6f4a
Chrome_I-6675 3d..2 1us : irq_disable: caller=rcu_irq_enter_irqson+0x1c/0x50 parent= (null)
<...>-42 2dNh1 1us : local_timer_exit: vector=236
Chrome_I-6675 3d..2 1us : irq_enable: caller=rcu_irq_enter_irqson+0x40/0x50 parent= (null)
Wakeup Latency
<...>-42 2dN.1 102us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 102us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 103us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 103us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 103us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 103us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 104us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 104us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 104us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 105us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 105us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 105us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 105us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 106us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 106us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 106us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 107us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 107us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 107us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 107us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 108us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 108us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 108us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 109us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 109us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 109us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 110us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 110us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 110us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 110us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
<...>-42 2dN.1 111us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null)
<...>-42 2dN.2 111us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
Wakeup Latency
# trace-cmd start -p wakeup_rt -l ‘*spin*’ -e all
# ./cyclictest -p80 -i250 -n -a -t -q -d 0
# /dev/cpu_dma_latency set to 0us
^C
T: 0 (13264) P:80 I:250 C: 756984 Min: 7 Act: 12 Avg: 9 Max: 292
T: 1 (13265) P:80 I:250 C: 756970 Min: 4 Act: 13 Avg: 9 Max: 301
T: 2 (13266) P:80 I:250 C: 756980 Min: 7 Act: 10 Avg: 10 Max: 304
T: 3 (13267) P:80 I:250 C: 756981 Min: 6 Act: 14 Avg: 9 Max: 281

Recommended for you

Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt

Ftrace is the official tracer of the Linux kernel. It has been apart of Linux since 2.6.31, and has grown tremendously ever since. Ftrace’s name comes from its most powerful feature: function tracing. But the ftrace infrastructure is much more than that. It also encompasses the trace events that are used by perf, as well as kprobes that can dynamically add trace events that the user defines. This talk will focus on learning how the kernel works by using the ftrace infrastructure. It will show how to see what happens within the kernel during a system call; learn how interrupts work; see how ones processes are being scheduled, and more. A quick introduction to some tools like trace-cmd and KernelShark will also be demonstrated. Steven Rostedt, VMware

linux kernelftrace
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance

Talk for YOW! by Brendan Gregg. "Systems performance studies the performance of computing systems, including all physical components and the full software stack to help you find performance wins for your application and kernel. However, most of us are not performance or kernel engineers, and have limited time to study this topic. This talk summarizes the topic for everyone, touring six important areas: observability tools, methodologies, benchmarking, profiling, tracing, and tuning. Included are recipes for Linux performance analysis and tuning (using vmstat, mpstat, iostat, etc), overviews of complex areas including profiling (perf_events) and tracing (ftrace, bcc/BPF, and bpftrace/BPF), advice about what is and isn't important to learn, and case studies to see how it is applied. This talk is aimed at everyone: developers, operations, sysadmins, etc, and in any environment running Linux, bare metal or the cloud. "

linuxperformance
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)

The PREEMPT_RT patch turns Linux into a hard Real-Time designed operating system. But it takes more than just a kernel to make sure you can meet all your requirements. This talk explains all aspects of the system that is being used for a mission critical project that must be considered. Creating a Real-Time environment is difficult and there is no simple solution to make sure that your system is capable to fulfill its needs. One must be vigilant with all aspects of the system to make sure there are no surprises. This talk will discuss most of the “gotchas” that come with putting together a Real-Time system. You don’t need to be a developer to enjoy this talk. If you are curious to know how your computer is an unpredictable mess you should definitely come to this talk. Steven Rostedt - Red Hat

linuxkernel
Wakeup Latency
Xorg-747 2.N.2 274us : _raw_spin_lock_irqsave <-pagevec_lru_move_fn
Xorg-747 2dN.3 274us : irq_enable: caller=wakeup_tracer_call+0xcf/0xe0 parent= (null)
Xorg-747 2dN.2 275us : irq_disable: caller=_raw_spin_lock_irqsave+0x20/0x50 parent= (null)
Xorg-747 2dN.3 275us : mm_lru_activate: page=00000000d262fdc6 pfn=2466257
Xorg-747 2dN.3 276us : mm_lru_activate: page=000000008b725f88 pfn=2875792
Xorg-747 2dN.3 276us : mm_lru_activate: page=000000008e31e070 pfn=3064073
Xorg-747 2dN.3 276us : mm_lru_activate: page=00000000774be734 pfn=2917451
Xorg-747 2dN.3 276us : mm_lru_activate: page=00000000c945de9c pfn=2021174
Xorg-747 2dN.3 277us : mm_lru_activate: page=0000000062d8ec6a pfn=2744545
Xorg-747 2dN.3 277us : mm_lru_activate: page=0000000080bc2df3 pfn=1899247
Xorg-747 2dN.3 277us : mm_lru_activate: page=00000000248a1143 pfn=2886580
Xorg-747 2dN.3 277us : mm_lru_activate: page=00000000ab7567ef pfn=2708231
Xorg-747 2dN.3 278us : mm_lru_activate: page=00000000c8601ee2 pfn=2031604
Xorg-747 2dN.3 278us : mm_lru_activate: page=0000000073cddaf3 pfn=2775238
Xorg-747 2dN.3 278us : mm_lru_activate: page=00000000b558f9cf pfn=2937059
Xorg-747 2dN.3 278us : mm_lru_activate: page=00000000fedc94ed pfn=2732924
Xorg-747 2dN.3 279us : mm_lru_activate: page=00000000d304f759 pfn=2319768
Xorg-747 2dN.3 279us : mm_lru_activate: page=000000000f98cd55 pfn=2336125
Xorg-747 2dN.3 279us : _raw_spin_unlock_irqrestore <-pagevec_lru_move_fn
Xorg-747 2dN.3 279us : irq_enable: caller=_raw_spin_unlock_irqrestore+0x40/0x60 parent= (null)
Xorg-747 2dN.2 280us : irq_disable: caller=free_unref_page_list+0xc1/0x220 parent= (null)
Xorg-747 2dN.2 280us : irq_enable: caller=free_unref_page_list+0x204/0x220 parent= (null)
Xorg-747 2dN.3 283us : irq_disable: caller=wakeup_tracer_call+0x7d/0xe0 parent= (null)
Xorg-747 2.N.2 283us : _raw_spin_lock_irqsave <-pagevec_lru_move_fn
Xorg-747 2dN.3 284us : irq_enable: caller=wakeup_tracer_call+0xcf/0xe0 parent= (null)
Xorg-747 2dN.2 284us : irq_disable: caller=_raw_spin_lock_irqsave+0x20/0x50 parent= (null)
Xorg-747 2dN.3 284us : mm_lru_activate: page=0000000049c0942d pfn=2422419
Xorg-747 2dN.3 285us : mm_lru_activate: page=00000000e64c4c24 pfn=2651893
Xorg-747 2dN.3 285us : mm_lru_activate: page=000000005ca129cc pfn=2002176
IRQ and Preemption Latency
●
When interrupts or preemption is disabled
– Other tasks can not be scheduled in
●
Tracers:
– irqsoff
●
Interesting info
– preemptoff
●
interesting info
– preemptirqsoff
●
Useful info
●
The only one I use
42
Preempt and IRQs Off Latency
# trace-cmd start -p preemptirqsoff -d
# trace-cmd show | less
# tracer: preemptirqsoff
#
# preemptirqsoff latency trace v1.1.5 on 4.19.0-rc4-test+
# --------------------------------------------------------------------
# latency: 1100 us, #4/4, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4)
# -----------------
# | task: Xorg-747 (uid:0 nice:0 policy:0 rt_prio:0)
# -----------------
# => started at: __mutex_lock.isra.5
# => ended at: __mutex_lock.isra.5
#
#
# _------=> CPU#
# / _-----=> irqs-off
# | / _----=> need-resched
# || / _---=> hardirq/softirq
# ||| / _--=> preempt-depth
# |||| / delay
# cmd pid ||||| time | caller
#  / |||||  | /
Xorg-747 1...1 0us#: __mutex_lock.isra.5 <-__mutex_lock.isra.5
Xorg-747 1...1 1100us : __mutex_lock.isra.5 <-__mutex_lock.isra.5
Xorg-747 1...1 1101us+: tracer_preempt_on <-__mutex_lock.isra.5
Xorg-747 1...1 1138us : <stack trace>
=> i915_gem_fault
=> __do_fault
=> __handle_mm_fault
=> handle_mm_fault
=> __do_page_fault
=> page_fault
Preempt and IRQs Off Latency
# echo 1 > /sys/kernel/debug/tracing/options/sym-offset
# trace-cmd show | less
# tracer: preemptirqsoff
#
# preemptirqsoff latency trace v1.1.5 on 4.19.0-rc4-test+
# --------------------------------------------------------------------
# latency: 1100 us, #4/4, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4)
# -----------------
# | task: Xorg-747 (uid:0 nice:0 policy:0 rt_prio:0)
# -----------------
# => started at: __mutex_lock.isra.5+0x3a/0x4e0
# => ended at: __mutex_lock.isra.5+0x1d6/0x4e0
#
#
# _------=> CPU#
# / _-----=> irqs-off
# | / _----=> need-resched
# || / _---=> hardirq/softirq
# ||| / _--=> preempt-depth
# |||| / delay
# cmd pid ||||| time | caller
#  / |||||  | /
Xorg-747 1...1 0us#: __mutex_lock.isra.5+0x3a/0x4e0 <-__mutex_lock.isra.5+0x3a/0x4e0
Xorg-747 1...1 1100us : __mutex_lock.isra.5+0x1d6/0x4e0 <-__mutex_lock.isra.5+0x1d6/0x4e0
Xorg-747 1...1 1101us+: tracer_preempt_on+0xf4/0x110 <-__mutex_lock.isra.5+0x1d6/0x4e0
Xorg-747 1...1 1138us : <stack trace>
=> i915_gem_fault+0xc7/0x550 [i915]
=> __do_fault+0x20/0xe0
=> __handle_mm_fault+0xdf7/0x15a0
=> handle_mm_fault+0x11e/0x260
=> __do_page_fault+0x283/0x580
=> page_fault+0x1e/0x30

Recommended for you

GOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUsGOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUs

Complexity is increasing. Trust eroding. In the wake of Spectre and Meltdown, when it seems that things cannot get any darker for processor security, the last light goes out. This talk will demonstrate what everyone has long feared but never proven: there are hardware backdoors in x86 processors, and they’re buried deeper than we ever imagined possible. In this talk, we walk through how we discovered a privilege escalation backdoor in a family of x86 CPUs, that allows an unprivileged user, on an unmodified system, to circumvent all processor security checks and escalate from ring 3 to ring 0 – permitting an unprivileged, arbitrary userland program to directly modify and execute code inside of the kernel, regardless of the operating system, security patches, antivirus, firmware, etc. Speakers: Christopher Domas, Cyber Security Researcher

hardware backdoors in x86 cpushardware security
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d method

The document discusses analyzing database systems using a 3D method for performance analysis. It introduces the 3D method, which looks at performance from the perspectives of the operating system (OS), Oracle database, and applications. The 3D method provides a holistic view of the system that can help identify issues and direct solutions. It also covers topics like time-based analysis in Oracle, how wait events are classified, and having a diagnostic framework for quick troubleshooting using tools like the Automatic Workload Repository report.

Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010

This document discusses concurrency in SystemC simulations. It explains that SystemC uses events and processes to model concurrent systems. There are two main types of processes: threads and methods. Threads can wait for events using wait() and methods use next_trigger() to establish dynamic sensitivity. Events have no duration and are used to trigger processes. Notifying an event using notify() moves waiting processes to the ready queue. The SystemC kernel is event-driven and executes ready processes in non-deterministic order.

systemcsc_eventesl
IRQ and Preemption Latency
●
When interrupts or preemption is disabled
– Other tasks can not be scheduled in
●
Tracers:
– irqsoff
●
Interesting info
– preemptoff
●
interesting info
– preemptirqsoff
●
Useful info
●
The only one I use
45
The “trace_marker” and “tracing_on” files
●
/sys/kernel/tracing/trace_marker
– Let’s userspace write into the kernel ring buffer
– Application can write into it to tag where it discovered an issue
●
/sys/kernel/tracing/tracing_on
– Can enable or disable writing to the ring buffer
– Note, when off, it also prevents new “max latency” from being recorded
●
by the wakeup, and preempt/irqs off tracers
46
Using trace_marker and tracing_on in C code
static int marker_fd = -1;
static int tracing_fd = -1;
static __thread char buff[BUFSIZ+1];
static void write_marker(const char *fmt, ...)
{
va_list ap;
int n;
if (marker_fd < 0)
return;
va_start(ap, fmt);
n = vsnprintf(buff, BUFSIZ, fmt, ap);
va_end(ap);
write(marker_fd, buff, n);
}
static void set_tracing (int on)
{
char val[1];
if (tracing_fd < 0)
return;
val[0] = ‘0’ + on;
write(tracing_fd, val, 1);
}
[..]
// On error
write_marker(“Detected a latency of %d microsecondsn”, latency);
set_tracing(0);
Having cyclictest stop on max threshold
●
cyclictest is aware of the tracing infrastructure
– “-b 500” : break on if latency is greater than 500 microseconds
●
More options that we are not using but could have (All require -b option)
– “-E” enable all events
– “-f” enable function tracing
– “-I” enable irqsoff tracer
– “-P” enable preemptoff tracer
– “-w” enable wakeup tracer
– “-W” enable wakeup_rt tracer
48

Recommended for you

OS scheduling and The anatomy of a context switch
OS scheduling and The anatomy of a context switchOS scheduling and The anatomy of a context switch
OS scheduling and The anatomy of a context switch

A general overview and some in depth about how operation systems schedule tasks and how much does it really cost?

osprocessesirq
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)

The document discusses process management in operating systems. It covers control blocks, interrupts, process states, scheduling algorithms like FIFO, SJF, SRTF, Round Robin and priority scheduling. It also discusses queuing, multiprogramming vs time sharing and scheduling criteria like CPU utilization, throughput, turnaround time and waiting time. Scheduling can be long, medium or short term and algorithms include priority queues and multilevel feedback queues.

Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...

In this intermediate training session we look at resolving issues that may occur with replication (Tungsten Replicator) and clustering (Tungsten Clustering). This training is for all engineers using Continuent Tungsten solutions, as the tools we use will apply to any of our products and topologies. Some MySQL replication knowledge is assumed. AGENDA - How to identify an issue when scanning logs - Tools to help identify issues - Identifying replication lag / diagnosing replication latency - Resolving common replication issues - Resolving common clustering issues

trainingcontinuentcontinuent tungsten
Preempt and IRQs Off Latency
# ./cyclictest -p80 -i250 -n -a -t -q -d 0 -b 500
# /dev/cpu_dma_latency set to 0us
INFO: debugfs mountpoint: /sys/kernel/debug/tracing/
T: 0 (15126) P:80 I:250 C: 169015 Min: 2 Act: 8 Avg: 9 Max: 267
T: 1 (15127) P:80 I:250 C: 169011 Min: 1 Act: 11 Avg: 9 Max: 305
T: 2 (15128) P:80 I:250 C: 169014 Min: 1 Act: 7 Avg: 9 Max: 248
T: 3 (15129) P:80 I:250 C: 169009 Min: 1 Act: 560 Avg: 9 Max: 560
# Thread Ids: 15126 15127 15128 15129
# Break thread: 15129
# Break value: 560
=> page_fault
# ./cyclictest -p80 -i250 -n -a -t -q -d 0 -b 500
# trace-cmd start -p function -e all -l '*lock*' -l '*mutex*'
The issue has been record (we hope)
●
The trace buffer has the issue (with a marker tag)
●
Save the text files (just to keep them around)
50
# cp /sys/kernel/tracing/trace /some/path/save_trace_dir/trace
# for file in /sys/kernel/tracing/per_cpu/cpu*/trace; do
cpu=${file/%/trace}
cp $file /some/path/save_trace_dir/`basename $cpu`
done
# ls /some/path/save_trace_dir
cpu0 cpu1 cpu2 cpu3 trace
For full power of trace-cmd
●
trace-cmd extract retrieves the kernel buffer into a trace.dat file
●
Can now do all sorts of filtering
51
# trace-cmd extract
# trace-cmd report 2>/dev/null |grep print
cyclictest-15129 [003] 23346.433979: print: tracing_mark_write: hit latency threshold (560 > 500)
For full power of trace-cmd
●
trace-cmd extract retrieves the kernel buffer into a trace.dat file
●
Can now do all sorts of filtering
52
# trace-cmd extract
# trace-cmd report 2>/dev/null |grep print
cyclictest-15129 [003] 23346.433979: print: tracing_mark_write: hit latency threshold (560 > 500)

Recommended for you

Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time

This presentation covers the general concepts about real-time systems, how Linux kernel works for preemption, the latency in Linux, rt-preempt, and Xenomai, the real-time extension as the dual kernel approach.

rtairealtimexenomai
Kernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream firstKernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream first

This document discusses the benefits of contributing device drivers and other code to the Linux kernel upstream first instead of maintaining private branches. It outlines Chrome OS's strategy of picking long-term stable kernels and contributing hardware support to upstream. While challenging, working upstream provides many benefits like free code reviews, bugfixes, and easier updates. The document shows that Chrome OS contributions have helped increase upstream support for vendors' devices and that there is still work remaining to upstream GPU and other drivers. It demos mainlining the Samsung Chromebook Plus by using the open source Panfrost GPU driver instead of a vendor driver.

linux kernelopen source
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIKernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI

As the name would suggest, a Non-Maskable Interrupt (NMI) is an interrupt-like feature that is unaffected by the disabling of classic interrupts. In Linux, NMIs are involved in some features such as performance event monitoring, hard-lockup detector, on demand state dumping, etc… Their potential to fire when least expected can fill the most seasoned kernel hackers with dread. AArch64 (aka arm64 in the Linux tree) does not provide architected NMIs, a consequence being that features benefiting from NMIs see their use limited on AArch64. However, the Arm Generic Interrupt Controller (GIC) supports interrupt prioritization and masking, which, among other things, provides a way to control whether or not a set of interrupts can be signaled to a CPU. This talk will cover how, using the GIC interrupt priorities, we provide a way to configure some interrupts to behave in an NMI-like manner on AArch64. We’ll discuss the implementation, some of the complications that ensued and also some of the benefits obtained from it. Julien Thierry

linux kernelopen source
# trace-cmd report -l --cpu 3 -O parent | less
cyclicte-15129 3.... 23346.433176: hrtimer_init: hrtimer=0xffffb45f4290be70 clockid=CLOCK_MONOTONIC mode=0x0
[..]
cyclicte-15129 3d..1 23346.433178: hrtimer_start: hrtimer=0xffffb45f4290be70 function=hrtimer_wakeup/0x0
expires=23346275012026 softexpires=23346275012026
[ 23346275013 - 23346175012 = 1us (from below) ]
[.. cyclictest is in nanosleep here ..]
Xorg-747 3d.h3 23346.433403: local_timer_entry: vector=236
Xorg-747 3d.h3 23346.433403: function: _raw_spin_lock_irqsave <-- hrtimer_interrupt
Xorg-747 3d.h4 23346.433403: hrtimer_cancel: hrtimer=0xffffb45f4290be70
Xorg-747 3d.h4 23346.433403: function: _raw_spin_unlock_irqrestore <-- __hrtimer_run_queues
Xorg-747 3d.h3 23346.433403: hrtimer_expire_entry: hrtimer=0xffffb45f4290be70 now=23346275013126
function=hrtimer_wakeup/0x0
[ 23346433403 - 23346275013 = 158390 (offset) ]
Xorg-747 3d.h3 23346.433403: function: _raw_spin_lock_irqsave <-- try_to_wake_up
[..]
Xorg-747 3dNh5 23346.433403: sched_wakeup: cyclictest:15129 [19] success=1 CPU:003
Xorg-747 3dNh5 23346.433403: function: __lock_text_start <-- try_to_wake_up
Xorg-747 3dNh4 23346.433403: function: _raw_spin_unlock_irqrestore <-- try_to_wake_up
Xorg-747 3dNh3 23346.433403: hrtimer_expire_exit: hrtimer=0xffffb45f4290be70
[..]
Xorg-747 3dNh3 23346.433403: local_timer_exit: vector=236
Xorg-747 3.N.1 23346.433409: function: lock_page_memcg <-- page_remove_rmap
Xorg-747 3dN.2 23346.433956: function: __rcu_read_lock <-- cpuacct_charge
Xorg-747 3dN.2 23346.433957: function: __rcu_read_unlock <-- update_curr
Xorg-747 3dN.2 23346.433957: function: __rcu_read_lock <-- update_curr
Xorg-747 3dN.2 23346.433957: function: __rcu_read_unlock <-- update_curr
Xorg-747 3d..2 23346.433958: sched_switch: Xorg:747 [120] R ==> cyclictest:15129 [19]
[..]
cyclicte-15129 3.... 23346.433979: print: tracing_mark_write: hit latency threshold (560 > 500)
Lock Stats (based off of Lockdep)
●
lockdep - checks correctness of locking
– Avoids various deadlock scenarios
●
lockstat - built off of lockdep
– Records when a task waits on a lock
– Records how much time it waited
– Records contention between different CPUs
– Records acquisitions too
●
See Documentation/locking/lockstats.txt
54
The /proc/lockstat file
●
The headers
– con-bounces : How many times contended across CPUs
– contentions : Number of locks acquisitions that had to wait
– wait time
●
min: Shortest (non-zero) wait time
●
max: Longest wait time
●
total: Total amount of time tasks had to wait
●
avg: The average time a task waited
– acq-bounces : Number of acquisitions that crossed CPUs
– acquisitions: The number of times the lock was acquired
– hold time - min: max: total: avg: Same as wait time but for time lock was held
55
trylock(lock) record lock contetion(&lock)
record lock acquisition(&lock)
lock(&lock)
How lockstats work

Recommended for you

Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernelKernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel

At a rate of almost 9 changes per hour (24/7), the Linux kernel is definitely a scary beast. Bugs are introduced on a daily basis and, through the use of multiple code analyzers, *some* of them are detected and fixed before they hit mainline. Over the course of the last few years, Gustavo has been fixing such bugs and many different issues in every corner of the Linux kernel. Recently, he was in charge of leading the efforts to globally enable -Wimplicit-fallthrough; which appears by default in Linux v5.3. This presentation is a report on all the stuff Gustavo has found and fixed in the kernel with the support of the Core Infrastructure Initiative. Gustavo A.R. Silva

linux kernelopen source
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money

In I.T. we all use all kinds of metrics. Operations teams rely heavily on these, especially when things go south. These metrics are sometimes overrated. Let’s dive into a few real life stories together. Aurélien Rougemont

linux kernelopen source
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureKernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and future

This document discusses the current state and future plans for Linux kernel documentation. It notes that documentation has transitioned from DocBook to Sphinx/RST, improving formatting and integration. There are now over 3,000 documentation files and many kerneldoc comments. Future plans include converting remaining text files, updating ancient documents, improving organization by topic, integrating documentation better, and enhancing the documentation toolchain. The goal is to improve documentation to better help kernel developers, users and the community.

open sourcelinux kernel
lock_stat version 0.4
-------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------
class name con-bounces contentions waittime-min waittime-max waittime-total waittime-avg acq-bounces
acquisitions holdtime-min holdtime-max holdtime-total holdtime-avg
-------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------
&(&n->list_lock)->rlock: 1332195 1334443 0.07 9686.41 2573984.58 1.93 3643104
26288751 0.00 21988.08 15069393.95 0.57
-----------------------
&(&n->list_lock)->rlock 210234 [<000000001b722b79>] get_partial_node.isra.69.part.70+0x38/0x3b0
&(&n->list_lock)->rlock 147421 [<00000000a298aeee>] deactivate_slab.isra.67+0x500/0x6e0
&(&n->list_lock)->rlock 683236 [<000000008a6cb3ab>] free_debug_processing+0x3f/0x270
&(&n->list_lock)->rlock 246105 [<000000007fc36e41>] __slab_free+0xc5/0x3f0
-----------------------
&(&n->list_lock)->rlock 1008985 [<000000008a6cb3ab>] free_debug_processing+0x3f/0x270
&(&n->list_lock)->rlock 77749 [<00000000a298aeee>] deactivate_slab.isra.67+0x500/0x6e0
&(&n->list_lock)->rlock 137428 [<000000001b722b79>] get_partial_node.isra.69.part.70+0x38/0x3b0
&(&n->list_lock)->rlock 83846 [<000000007fc36e41>] __slab_free+0xc5/0x3f0
.......................................................................................................................................................
......................................................................
kmemleak_lock-W: 340821 341229 0.06 10471.90 535946.05 1.57 1944828
8016988 0.00 4676.63 4406716.68 0.55
kmemleak_lock-R: 4624 4652 0.10 73.34 4135.42 0.89 4887
999302 0.00 681.39 1320770.44 1.32
---------------
kmemleak_lock 169288 [<00000000795f3b3d>] find_and_remove_object+0x1b/0x90
kmemleak_lock 171942 [<000000000071b79a>] create_object+0x161/0x2c0
kmemleak_lock 4453 [<00000000554658c3>] find_and_get_object+0x45/0xb0
kmemleak_lock 199 [<00000000dfc7b05b>] scan_block+0x2a/0x110
---------------
kmemleak_lock 198499 [<000000000071b79a>] create_object+0x161/0x2c0
kmemleak_lock 145759 [<00000000795f3b3d>] find_and_remove_object+0x1b/0x90
kmemleak_lock 1445 [<00000000554658c3>] find_and_get_object+0x45/0xb0
kmemleak_lock 179 [<00000000dfc7b05b>] scan_block+0x2a/0x110
.......................................................................................................................................................
......................................................................
Questions?

More Related Content

What's hot

Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
Adrien Mahieux
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
Raghu Udiyar
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
P4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC OffloadP4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC Offload
Open-NFP
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
shimosawa
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
RISC-V International
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
Alex Maestretti
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsJava Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs
Brendan Gregg
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
Adrian Huang
 
Velocity 2015 linux perf tools
Velocity 2015 linux perf toolsVelocity 2015 linux perf tools
Velocity 2015 linux perf tools
Brendan Gregg
 
Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF Superpowers
Brendan Gregg
 
Linux Profiling at Netflix
Linux Profiling at NetflixLinux Profiling at Netflix
Linux Profiling at Netflix
Brendan Gregg
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
Brendan Gregg
 
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM SystemsXPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
The Linux Foundation
 
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and more
Brendan Gregg
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
SUSE Labs Taipei
 
Memory Compaction in Linux Kernel.pdf
Memory Compaction in Linux Kernel.pdfMemory Compaction in Linux Kernel.pdf
Memory Compaction in Linux Kernel.pdf
Adrian Huang
 
eBPF Perf Tools 2019
eBPF Perf Tools 2019eBPF Perf Tools 2019
eBPF Perf Tools 2019
Brendan Gregg
 

What's hot (20)

Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
P4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC OffloadP4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC Offload
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsJava Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
 
Velocity 2015 linux perf tools
Velocity 2015 linux perf toolsVelocity 2015 linux perf tools
Velocity 2015 linux perf tools
 
Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF Superpowers
 
Linux Profiling at Netflix
Linux Profiling at NetflixLinux Profiling at Netflix
Linux Profiling at Netflix
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
 
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM SystemsXPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
 
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and more
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
Memory Compaction in Linux Kernel.pdf
Memory Compaction in Linux Kernel.pdfMemory Compaction in Linux Kernel.pdf
Memory Compaction in Linux Kernel.pdf
 
eBPF Perf Tools 2019
eBPF Perf Tools 2019eBPF Perf Tools 2019
eBPF Perf Tools 2019
 

Similar to Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Rostedt

Using Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance TroublesUsing Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance Troubles
ScyllaDB
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX Security
HelpSystems
 
BUD17-309: IRQ prediction
BUD17-309: IRQ prediction BUD17-309: IRQ prediction
BUD17-309: IRQ prediction
Linaro
 
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?
ScyllaDB
 
Let's write a Debugger!
Let's write a Debugger!Let's write a Debugger!
Let's write a Debugger!
Levente Kurusa
 
Interrupts.ppt
Interrupts.pptInterrupts.ppt
Interrupts.ppt
SasiBhushan22
 
Servers and Processes: Behavior and Analysis
Servers and Processes: Behavior and AnalysisServers and Processes: Behavior and Analysis
Servers and Processes: Behavior and Analysis
dreamwidth
 
When the OS gets in the way
When the OS gets in the wayWhen the OS gets in the way
When the OS gets in the way
Mark Price
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
Gábor Nyers
 
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdfWeek 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
devinezekiel2003
 
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Anne Nicolas
 
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance
Brendan Gregg
 
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Anne Nicolas
 
GOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUsGOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUs
Priyanka Aash
 
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d method
Ajith Narayanan
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010
敬倫 林
 
OS scheduling and The anatomy of a context switch
OS scheduling and The anatomy of a context switchOS scheduling and The anatomy of a context switch
OS scheduling and The anatomy of a context switch
Daniel Ben-Zvi
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
rohassanie
 
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Continuent
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
National Cheng Kung University
 

Similar to Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Rostedt (20)

Using Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance TroublesUsing Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance Troubles
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX Security
 
BUD17-309: IRQ prediction
BUD17-309: IRQ prediction BUD17-309: IRQ prediction
BUD17-309: IRQ prediction
 
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?
 
Let's write a Debugger!
Let's write a Debugger!Let's write a Debugger!
Let's write a Debugger!
 
Interrupts.ppt
Interrupts.pptInterrupts.ppt
Interrupts.ppt
 
Servers and Processes: Behavior and Analysis
Servers and Processes: Behavior and AnalysisServers and Processes: Behavior and Analysis
Servers and Processes: Behavior and Analysis
 
When the OS gets in the way
When the OS gets in the wayWhen the OS gets in the way
When the OS gets in the way
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdfWeek 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf
 
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
 
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance
 
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
 
GOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUsGOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUs
 
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d method
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010
 
OS scheduling and The anatomy of a context switch
OS scheduling and The anatomy of a context switchOS scheduling and The anatomy of a context switch
OS scheduling and The anatomy of a context switch
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
Training Slides: Intermediate 204: Identifying and Resolving Issues with Tung...
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 

More from Anne Nicolas

Kernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream firstKernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream first
Anne Nicolas
 
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIKernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Anne Nicolas
 
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernelKernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Anne Nicolas
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money
Anne Nicolas
 
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureKernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Anne Nicolas
 
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Anne Nicolas
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Anne Nicolas
 
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Anne Nicolas
 
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and BareboxEmbedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Anne Nicolas
 
Embedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less specialEmbedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less special
Anne Nicolas
 
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre SiliconEmbedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Anne Nicolas
 
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) pictureEmbedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Anne Nicolas
 
Embedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops wayEmbedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops way
Anne Nicolas
 
Embedded Recipes 2019 - Herd your socs become a matchmaker
Embedded Recipes 2019 - Herd your socs become a matchmakerEmbedded Recipes 2019 - Herd your socs become a matchmaker
Embedded Recipes 2019 - Herd your socs become a matchmaker
Anne Nicolas
 
Embedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationEmbedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integration
Anne Nicolas
 
Embedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debuggingEmbedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debugging
Anne Nicolas
 
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimediaEmbedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Anne Nicolas
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Anne Nicolas
 
Kernel Recipes 2019 - Suricata and XDP
Kernel Recipes 2019 - Suricata and XDPKernel Recipes 2019 - Suricata and XDP
Kernel Recipes 2019 - Suricata and XDP
Anne Nicolas
 
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Anne Nicolas
 

More from Anne Nicolas (20)

Kernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream firstKernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream first
 
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIKernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
 
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernelKernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money
 
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureKernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and future
 
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
 
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
 
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and BareboxEmbedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
 
Embedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less specialEmbedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less special
 
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre SiliconEmbedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
 
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) pictureEmbedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
 
Embedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops wayEmbedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops way
 
Embedded Recipes 2019 - Herd your socs become a matchmaker
Embedded Recipes 2019 - Herd your socs become a matchmakerEmbedded Recipes 2019 - Herd your socs become a matchmaker
Embedded Recipes 2019 - Herd your socs become a matchmaker
 
Embedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationEmbedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integration
 
Embedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debuggingEmbedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debugging
 
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimediaEmbedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
 
Kernel Recipes 2019 - Suricata and XDP
Kernel Recipes 2019 - Suricata and XDPKernel Recipes 2019 - Suricata and XDP
Kernel Recipes 2019 - Suricata and XDP
 
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
 

Recently uploaded

Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
taskroupseo
 
Cultural Shifts: Embracing DevOps for Organizational Transformation
Cultural Shifts: Embracing DevOps for Organizational TransformationCultural Shifts: Embracing DevOps for Organizational Transformation
Cultural Shifts: Embracing DevOps for Organizational Transformation
Mindfire Solution
 
A Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdfA Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdf
kalichargn70th171
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
Ortus Solutions, Corp
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Trackobit
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
908dutch
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Livetecs LLC
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
Mitchell Marsh
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
Roshan Dwivedi
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
Ortus Solutions, Corp
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
Semiosis Software Private Limited
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
SSTech System
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
Severalnines
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
karim wahed
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
Hironori Washizaki
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
onemonitarsoftware
 

Recently uploaded (20)

Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
 
Cultural Shifts: Embracing DevOps for Organizational Transformation
Cultural Shifts: Embracing DevOps for Organizational TransformationCultural Shifts: Embracing DevOps for Organizational Transformation
Cultural Shifts: Embracing DevOps for Organizational Transformation
 
A Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdfA Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdf
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
 

Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Rostedt

  • 1. © 2016 VMware Inc. All rights reserved. © 2016 VMware Inc. All rights reserved. Finding sources of Latency In your system (via tracing tools) Steven Rostedt 9/24/2018
  • 3. What is Latency? 3 “Latency is a time interval between the stimulation and response, or, from a more general point of view, a time delay between the cause and the effect of some physical change in the system being observed.” - Wikipedia
  • 4. What is Latency? ● The time between – When something needs to be done – When that something actually gets done 4 “Latency is a time interval between the stimulation and response, or, from a more general point of view, a time delay between the cause and the effect of some physical change in the system being observed.” - Wikipedia
  • 5. What is Latency? ● The time between – When something needs to be done – When that something actually gets done ● The time between – When something happens – When it is seen 5 “Latency is a time interval between the stimulation and response, or, from a more general point of view, a time delay between the cause and the effect of some physical change in the system being observed.” - Wikipedia
  • 6. There is ALWAYS Latency ● Nothing happens instantaneously ● There’s always going to be some “lag” ● Real Time systems avoid “Unbounded Latency” – When all latency is bound to a worse case scenario – Any latency that is indeterminate can cause problems ● Non Real-Time systems still care about latency 6
  • 7. Why do we care about Latency? ● For Real Time tasks, it is critical – Need to know worse case latency – Guarantee that it can achieve its objective ● Don’t want airplane flaps to not react quick enough!
  • 8. Why do we care about Latency? ● Practically everyone/everything cares about Latency – How long would you wait for ‘a’ to show up after clicking ‘a’? – A search result that takes 5 minutes to answer! – All systems are therefore “real time”! ● Needs to be bounded to some arbitrary number ● Latency adds up – A system’s latency is the combination of its sub-components
  • 9. Where is that Latency? ● Latency adds up – A system’s latency is the combination of its sub-components ● It can be hard finding where your latency is ● What causes it – The application – The libraries – The operating system – The hardware
  • 10. Where is that Latency? HARDWARE Kernel Library Application BIOS
  • 11. Hardware Latency ● Can’t get better than what the hardware gives you ● Sources of HW latency – System Management Interrupts (SMI) ● The BIOS takes over the machine – Clock frequency ● The system slows down – Cache line bouncing ● Sharing the same variable among CPUs
  • 12. Cyclictest ● A tool to measure latency ● Runs a simple loop (in a high priority task) – Sleep for a specified time – Get timestamp when wakes up – Compare the difference ● Best to use nanosleep – Can also use signals, but that has high latency! ● Favorite application of the Linux RT folks
  • 13. Cyclictest start = gettimeofday() Sleep 250us user-space kernel Put task to sleep Set interrupt timer for 250us Timer Interrupt goes off Wake up Task Schedule Taskend = gettimeofday() jitter = (end - start) - 250us 250us
  • 14. Cyclictest start = gettimeofday() Sleep 250us user-space kernel Put task to sleep Set interrupt timer for 250us Timer Interrupt goes off Wake up Task Schedule Taskend = gettimeofday() jitter = (end - start) - 250us 250us latency (jitter)
  • 15. Cyclictest start = gettimeofday() Sleep 250us user-space kernel Put task to sleep Set interrupt timer for 250us Timer Interrupt goes off Wake up Task Schedule Taskend = gettimeofday() jitter = (end - start) - 250us 250us latency (jitter) interrupt latency
  • 16. Cyclictest start = gettimeofday() Sleep 250us user-space kernel Put task to sleep Set interrupt timer for 250us Timer Interrupt goes off Wake up Task Schedule Taskend = gettimeofday() jitter = (end - start) - 250us 250us latency (jitter) interrupt latency wakeuplatency
  • 17. Cyclictest ● The options I am using here – “-p80” : set the starting priority to 80 – “-i250” : set the starting interval to 250 microseconds ● Sets nanosleep to the next 250 microsend interval – “-n” : use nanosleep and not POSIX timers ● POSIX timers will use signals, they have horrible latency – “-a” : Set affinity of a task to each CPU – “-t” : one thread per available processor (or logical CPU) – “-q” : keep quiet while running – “-d0” : Keep the interval the same for all threads (all at 250 microseconds)
  • 18. The tools ● Measuring latency – cyclictest ● Using Tracing tools can help find what’s happening – Ftrace ● hwlat ● function and function graph tracer ● event tracer ● trace-cmd / KernelShark – Lockdep (lock contention) – Perf ● profiling ● statistics – Many others (but I’m focusing on the Ftrace and and a bit of Lockdep)
  • 19. Hardware Latency ● Can’t get better than what the hardware gives you ● Sources of HW latency – System Management Interrupts (SMI) ● The BIOS takes over the machine – Clock frequency ● The system slows down – Cache line bouncing ● Sharing the same variable among CPUs
  • 20. Hardware Latency Detector ● Part of Ftrace – CONFIG_HWLAT_TRACER (in kernel .config build file) ● cd /sys/kernel/tracing (tracefs directory) – mount -t tracefs nodev /sys/kernel/tracing ● echo hwlat > current_tracer ● cat trace
  • 21. Hardware Latency Detector # cd /sys/kernel/tracing # echo hwlat > current_tracer # sleep 10 # cat trace # tracer: hwlat # # entries-in-buffer/entries-written: 7/7 #P:4 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | <...>-824 [001] d... 32.550243: #1 inner/outer(us): 59/53 ts:1537661092.117956843 <...>-824 [003] d... 34.562563: #3 inner/outer(us): 57/56 ts:1537661094.127959000 <...>-824 [000] d... 35.570670: #4 inner/outer(us): 55/55 ts:1537661095.138960084 <...>-824 [001] d... 36.578486: #5 inner/outer(us): 58/187 ts:1537661096.130961148 <...>-824 [003] d... 38.594465: #7 inner/outer(us): 27/26 ts:1537661098.156963322 <...>-824 [000] d... 39.602465: #8 inner/outer(us): 28/70 ts:1537661099.157964396 <...>-824 [001] d... 40.610903: #9 inner/outer(us): 1743/204 ts:1537661100.139965450 #
  • 22. Hardware Latency Detector # cd /sys/kernel/tracing # echo hwlat > current_tracer # sleep 10 # cat trace # tracer: hwlat # # entries-in-buffer/entries-written: 7/7 #P:4 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | <...>-824 [001] d... 32.550243: #1 inner/outer(us): 59/53 ts:1537661092.117956843 <...>-824 [003] d... 34.562563: #3 inner/outer(us): 57/56 ts:1537661094.127959000 <...>-824 [000] d... 35.570670: #4 inner/outer(us): 55/55 ts:1537661095.138960084 <...>-824 [001] d... 36.578486: #5 inner/outer(us): 58/187 ts:1537661096.130961148 <...>-824 [003] d... 38.594465: #7 inner/outer(us): 27/26 ts:1537661098.156963322 <...>-824 [000] d... 39.602465: #8 inner/outer(us): 28/70 ts:1537661099.157964396 <...>-824 [001] d... 40.610903: #9 inner/outer(us): 1743/204 ts:1537661100.139965450 #
  • 23. Hardware Latency Detector # cd /sys/kernel/tracing # echo hwlat > current_tracer # sleep 10 # cat trace # tracer: hwlat # # entries-in-buffer/entries-written: 7/7 #P:4 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | <...>-824 [001] d... 32.550243: #1 inner/outer(us): 59/53 ts:1537661092.117956843 <...>-824 [003] d... 34.562563: #3 inner/outer(us): 57/56 ts:1537661094.127959000 <...>-824 [000] d... 35.570670: #4 inner/outer(us): 55/55 ts:1537661095.138960084 <...>-824 [001] d... 36.578486: #5 inner/outer(us): 58/187 ts:1537661096.130961148 <...>-824 [003] d... 38.594465: #7 inner/outer(us): 27/26 ts:1537661098.156963322 <...>-824 [000] d... 39.602465: #8 inner/outer(us): 28/70 ts:1537661099.157964396 <...>-824 [001] d... 40.610903: #9 inner/outer(us): 1743/204 ts:1537661100.139965450 #
  • 24. Hardware Latency Algorithm ● Runs a kernel thread ● Does a tight loop for a period of time ● Interrupts are disabled (during the loop) ● Moves around all CPUs ● Records when the timestamp happened ● Denotes if it happened inside or outside the double timestamp
  • 25. t1 = time_get() t2 = time_get() last_t2 == 0 last_t2 = 0 diff = t1 - last_t2 diff > outer diff = t2 - t1 diff > inner outer = diff inner = diff time < width exit loop
  • 26. Hardware Latency Detector # cd /sys/kernel/tracing # cat hwlat_detector/width 500000 # cat hwlat_detector/window 1000000 # cat tracing_thresh 10 ● Spin for “width” microseconds ● Every “window” microseconds ● Record a trace if the diff is greater than “tracing_thresh” microseconds
  • 27. Hardware Latency Detector (with NMIs) ● It checks if an NMI triggered ● NMIs are not hardware, but software controlled (in most cases) ● nmi-total - The total time in NMI during the loop ● nmi-count - The number of NMIs that were triggered
  • 28. Hardware Latency Detector (With NMIs) # cd /sys/kernel/tracing # echo hwlat > current_tracer # sleep 10 # cat trace # tracer: hwlat # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | <...>-3808 [002] d... 123.942240: #1 inner/outer(us): 16/16 ts:1537718580.955027586 <...>-3808 [003] d... 124.962222: #2 inner/outer(us): 1/270 ts:1537718581.975050306 <...>-3808 [002] dn.. 128.034081: #3 inner/outer(us): 15/17 ts:1537718585.047027453 <...>-3808 [000] d... 130.082010: #4 inner/outer(us): 17/16 ts:1537718587.095030248 nmi-total:3 nmi-count:1 <...>-3808 [002] d... 132.129965: #5 inner/outer(us): 17/17 ts:1537718589.143062081 <...>-3808 [003] dn.. 133.153926: #6 inner/outer(us): 0/12 ts:1537718590.167059283 <...>-3808 [002] d... 136.225843: #8 inner/outer(us): 18/16 ts:1537718593.239082103 <...>-3808 [000] d... 138.273758: #9 inner/outer(us): 16/20 ts:1537718595.287066663 <...>-3808 [001] dn.. 139.297681: #10 inner/outer(us): 267/0 ts:1537718596.311023829 <...>-3808 [002] dn.. 140.321648: #11 inner/outer(us): 16/24 ts:1537718597.335024977 <...>-3808 [000] d... 142.369656: #12 inner/outer(us): 13/17 ts:1537718599.383044893 <...>-3808 [002] d... 144.417670: #13 inner/outer(us): 18/13 ts:1537718601.431050150 <...>-3808 [003] dn.. 145.441679: #14 inner/outer(us): 18/18 ts:1537718602.455056453 <...>-3808 [000] dn.. 146.465671: #15 inner/outer(us): 17/13 ts:1537718603.479046139 <...>-3808 [001] d... 147.489654: #16 inner/outer(us): 0/13 ts:1537718604.503027858 <...>-3808 [003] d... 149.537637: #17 inner/outer(us): 18/11 ts:1537718606.551010895 <...>-3808 [002] dn.. 152.609690: #18 inner/outer(us): 18/18 ts:1537718609.623070128 <...>-3808 [003] d... 153.633627: #19 inner/outer(us): 0/18 ts:1537718610.647010083 nmi-total:4 nmi-count:1 <...>-3808 [001] d... 155.685648: #20 inner/outer(us): 1/12 ts:1537718612.699039876 #
  • 29. If that’s not the problem? ● What if the hardware is fine? ● What else could it be? ● The Kernel? ● Your application?
  • 30. Kernel Entry Tracing (more than strace) # echo 1 > /sys/kernel/tracing/options/function-fork # trace-cmd record -F -c -p function_graph --max-graph-depth 1 -e syscalls ./cyclictest -p80 -i250 -n -a -t -q -d 0 plugin 'function_graph' # /dev/cpu_dma_latency set to 0us ^C T: 0 ( 9645) P:80 I:250 C: 45482 Min: 4 Act: 10 Avg: 6 Max: 1189 T: 1 ( 9646) P:80 I:250 C: 45486 Min: 5 Act: 10 Avg: 5 Max: 297 T: 2 ( 9647) P:80 I:250 C: 45491 Min: 5 Act: 9 Avg: 6 Max: 106 T: 3 ( 9648) P:80 I:250 C: 45491 Min: 5 Act: 11 Avg: 5 Max: 69 CPU0 data recorded at offset=0x60c000 10473472 bytes in size CPU1 data recorded at offset=0x1009000 10416128 bytes in size CPU2 data recorded at offset=0x19f8000 10432512 bytes in size CPU3 data recorded at offset=0x23eb000 10366976 bytes in size
  • 31. Kernel Entry Tracing (more than strace) # echo 1 > /sys/kernel/tracing/options/function-fork # trace-cmd record -F -c -p function_graph --max-graph-depth 1 -e syscalls ./cyclictest -p80 -i250 -n -a -t -q -d 0 plugin 'function_graph' # /dev/cpu_dma_latency set to 0us ^C T: 0 ( 9645) P:80 I:250 C: 45482 Min: 4 Act: 10 Avg: 6 Max: 1189 T: 1 ( 9646) P:80 I:250 C: 45486 Min: 5 Act: 10 Avg: 5 Max: 297 T: 2 ( 9647) P:80 I:250 C: 45491 Min: 5 Act: 9 Avg: 6 Max: 106 T: 3 ( 9648) P:80 I:250 C: 45491 Min: 5 Act: 11 Avg: 5 Max: 69 CPU0 data recorded at offset=0x60c000 10473472 bytes in size CPU1 data recorded at offset=0x1009000 10416128 bytes in size CPU2 data recorded at offset=0x19f8000 10432512 bytes in size CPU3 data recorded at offset=0x23eb000 10366976 bytes in size
  • 32. More Efficient Trace # trace-cmd report -F 'funcgraph_entry'| cut -d'|' -f 2 | cut -d'(' -f1 | sort -u cpus=4 do_IRQ __do_page_fault do_syscall_64 exit_to_usermode_loop fsnotify __fsnotify_parent __f_unlock_pos mutex_unlock __sb_end_write schedule_tail smp_apic_timer_interrupt smp_irq_work_interrupt syscall_slow_exit_work
  • 33. More Efficient Trace (I need to make this easier) # trace-cmd record -F -c -p function_graph --max-graph-depth 1 -e syscalls -l do_IRQ -l __do_page_fault -l do_syscall_64 -l exit_to_usermode_loop -l fsnotify -l __fsnotify_parent -l __f_unlock_pos -l mutex_unlock -l __sb_end_write -l schedule_tail -l smp_apic_timer_interrupt -l smp_irq_work_interrupt -l syscall_slow_exit_work ./cyclictest -p80 -i250 -n -a -t -q -d 0 plugin 'function_graph' # /dev/cpu_dma_latency set to 0us ^C T: 0 ( 2216) P:80 I:250 C: 195012 Min: 2 Act: 13 Avg: 4 Max: 309 T: 1 ( 2217) P:80 I:250 C: 195015 Min: 2 Act: 5 Avg: 3 Max: 227 T: 2 ( 2218) P:80 I:250 C: 195014 Min: 2 Act: 5 Avg: 3 Max: 283 T: 3 ( 2219) P:80 I:250 C: 195014 Min: 2 Act: 5 Avg: 3 Max: 276 CPU0 data recorded at offset=0x60c000 15847424 bytes in size CPU1 data recorded at offset=0x1529000 15884288 bytes in size CPU2 data recorded at offset=0x244f000 15859712 bytes in size CPU3 data recorded at offset=0x336f000 15884288 bytes in size
  • 34. More Accurate Trace # trace-cmd report | less cpus=4 cyclictest-10668 [003] 16938.997362: funcgraph_entry: | mutex_unlock() { cyclictest-10668 [003] 16938.997366: funcgraph_entry: 8.785 us | smp_irq_work_interrupt(); cyclictest-10668 [003] 16938.997377: funcgraph_exit: 0.142 us | } cyclictest-10668 [003] 16938.997378: funcgraph_entry: 0.215 us | __fsnotify_parent(); cyclictest-10668 [003] 16938.997379: funcgraph_entry: 0.218 us | fsnotify(); cyclictest-10668 [003] 16938.997380: funcgraph_entry: 0.298 us | __sb_end_write(); cyclictest-10668 [003] 16938.997382: funcgraph_entry: 0.284 us | __f_unlock_pos(); cyclictest-10668 [003] 16938.997383: funcgraph_entry: | syscall_slow_exit_work() { cyclictest-10668 [003] 16938.997384: sys_exit_write: 0x1 cyclictest-10668 [003] 16938.997388: funcgraph_exit: 4.939 us | } cyclictest-10668 [003] 16938.997396: funcgraph_entry: 8.209 us | __do_page_fault(); cyclictest-10668 [003] 16938.997411: funcgraph_entry: | do_syscall_64() { cyclictest-10668 [003] 16938.997412: sys_enter_execve: filename: 0x7fff9e60de96, argv: 0x7fff9e60c028, envp: 0x7fff9e60c078 cyclictest-10668 [003] 16938.997777: sys_exit_execve: 0x0 cyclictest-10668 [003] 16938.997782: funcgraph_exit: ! 370.796 us | } cyclictest-10668 [003] 16938.997786: funcgraph_entry: 5.508 us | __do_page_fault(); cyclictest-10668 [003] 16938.997795: funcgraph_entry: 1.665 us | __do_page_fault(); cyclictest-10668 [003] 16938.997799: funcgraph_entry: 5.009 us | __do_page_fault(); cyclictest-10668 [003] 16938.997808: funcgraph_entry: 1.277 us | __do_page_fault(); cyclictest-10668 [003] 16938.997813: funcgraph_entry: 2.288 us | __do_page_fault(); cyclictest-10668 [003] 16938.997819: funcgraph_entry: 4.597 us | __do_page_fault(); cyclictest-10668 [003] 16938.997827: funcgraph_entry: 5.344 us | __do_page_fault(); cyclictest-10668 [003] 16938.997843: funcgraph_entry: | do_syscall_64() { cyclictest-10668 [003] 16938.997844: sys_enter_brk: brk: 0x00000000
  • 35. More Accurate Trace cyclictest-10670 [001] 16939.002227: funcgraph_entry: | do_syscall_64() { cyclictest-10670 [001] 16939.002228: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags: 0x00000001, rqtp: 0x7fe7d41b4920, rmtp: 0x00000000 cyclictest-10671 [002] 16939.002315: sys_exit_clock_nanosleep: 0x0 cyclictest-10671 [002] 16939.002316: funcgraph_exit: ! 247.647 us | } cyclictest-10671 [002] 16939.002317: funcgraph_entry: | do_syscall_64() { cyclictest-10671 [002] 16939.002318: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags: 0x00000001, rqtp: 0x7fe7d39b3920, rmtp: 0x00000000 cyclictest-10672 [003] 16939.002400: sys_exit_clock_nanosleep: 0x0 cyclictest-10672 [003] 16939.002400: funcgraph_exit: ! 247.792 us | } cyclictest-10672 [003] 16939.002402: funcgraph_entry: | do_syscall_64() { cyclictest-10672 [003] 16939.002403: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags: 0x00000001, rqtp: 0x7fe7d31b2920, rmtp: 0x00000000 cyclictest-10669 [000] 16939.002416: sys_exit_clock_nanosleep: 0x0 cyclictest-10669 [000] 16939.002417: funcgraph_exit: ! 247.622 us | } cyclictest-10669 [000] 16939.002418: funcgraph_entry: | do_syscall_64() { cyclictest-10669 [000] 16939.002419: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags: 0x00000001, rqtp: 0x7fe7d49b5920, rmtp: 0x00000000 cyclictest-10670 [001] 16939.002475: sys_exit_clock_nanosleep: 0x0 cyclictest-10670 [001] 16939.002475: funcgraph_exit: ! 247.777 us | } cyclictest-10670 [001] 16939.002477: funcgraph_entry: | do_syscall_64() { cyclictest-10670 [001] 16939.002478: sys_enter_clock_nanosleep: which_clock: 0x00000001, flags: 0x00000001, rqtp: 0x7fe7d41b4920, rmtp: 0x00000000 cyclictest-10671 [002] 16939.002565: sys_exit_clock_nanosleep: 0x0 cyclictest-10671 [002] 16939.002566: funcgraph_exit: ! 247.713 us | }
  • 36. Wakeup Latency ● The time a task wakes up, to the time it is scheduled ● “wakeup” tracer – Traces the time of the highest priority task (RT or Not) – Interesting, but not very useful (hides RT task latency) ● “wakeup_rt” tracer – Only monitors RT tasks ● trace-cmd record -p wakeup_rt -d -e all – “-d” - disable function tracing – “-e all” enable all events 36
  • 37. Wakeup Latency # trace-cmd start -p wakeup_rt -d -e all # ./cyclictest -p80 -i250 -n -a -t -q -d 0 # /dev/cpu_dma_latency set to 0us ^C T: 0 (12864) P:80 I:250 C:1237799 Min: 7 Act: 12 Avg: 9 Max: 433 T: 1 (12865) P:80 I:250 C:1237794 Min: 4 Act: 15 Avg: 9 Max: 285 T: 2 (12866) P:80 I:250 C:1237790 Min: 7 Act: 12 Avg: 9 Max: 325 T: 3 (12867) P:80 I:250 C:1237798 Min: 6 Act: 12 Avg: 9 Max: 276
  • 38. Wakeup Latency # trace-cmd show | less # tracer: wakeup_rt # # wakeup_rt latency trace v1.1.5 on 4.19.0-rc4-test+ # -------------------------------------------------------------------- # latency: 319 us, #2072/2072, CPU#2 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4) # ----------------- # | task: cyclictest-12866 (uid:0 nice:0 policy:1 rt_prio:80) # ----------------- # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # / ||||| | / Chrome_I-6675 3...1 0us : preempt_enable: caller=__sb_start_write+0x89/0xc0 parent=__sb_start_write+0x89/0xc0 <...>-42 2dNh4 0us : 42:139:R + [002] 12866: 19:R <...> Chrome_I-6675 3d..2 0us : irq_disable: caller=rcu_irq_exit_irqson+0x1c/0x50 parent= (null) <...>-42 2dNh4 0us : 0 <idle>-0 0dN.1 0us : rcu_utilization: Start context switch Chrome_I-6675 3d..2 0us : irq_enable: caller=rcu_irq_exit_irqson+0x40/0x50 parent= (null) <...>-42 2dNh1 0us : hrtimer_expire_exit: hrtimer=00000000f472f709 <idle>-0 0dN.1 0us : rcu_utilization: End context switch <...>-42 2dNh1 1us : write_msr: 6e0, value 2e20f26e6f4a Chrome_I-6675 3d..2 1us : irq_disable: caller=rcu_irq_enter_irqson+0x1c/0x50 parent= (null) <...>-42 2dNh1 1us : local_timer_exit: vector=236 Chrome_I-6675 3d..2 1us : irq_enable: caller=rcu_irq_enter_irqson+0x40/0x50 parent= (null)
  • 39. Wakeup Latency <...>-42 2dN.1 102us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 102us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 103us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 103us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 103us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 103us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 104us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 104us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 104us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 105us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 105us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 105us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 105us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 106us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 106us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 106us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 107us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 107us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 107us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 107us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 108us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 108us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 108us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 109us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 109us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 109us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 110us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 110us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 110us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 110us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null) <...>-42 2dN.1 111us : irq_disable: caller=_raw_spin_lock_irq+0x15/0x40 parent= (null) <...>-42 2dN.2 111us : irq_enable: caller=_raw_spin_unlock_irq+0x11/0x40 parent= (null)
  • 40. Wakeup Latency # trace-cmd start -p wakeup_rt -l ‘*spin*’ -e all # ./cyclictest -p80 -i250 -n -a -t -q -d 0 # /dev/cpu_dma_latency set to 0us ^C T: 0 (13264) P:80 I:250 C: 756984 Min: 7 Act: 12 Avg: 9 Max: 292 T: 1 (13265) P:80 I:250 C: 756970 Min: 4 Act: 13 Avg: 9 Max: 301 T: 2 (13266) P:80 I:250 C: 756980 Min: 7 Act: 10 Avg: 10 Max: 304 T: 3 (13267) P:80 I:250 C: 756981 Min: 6 Act: 14 Avg: 9 Max: 281
  • 41. Wakeup Latency Xorg-747 2.N.2 274us : _raw_spin_lock_irqsave <-pagevec_lru_move_fn Xorg-747 2dN.3 274us : irq_enable: caller=wakeup_tracer_call+0xcf/0xe0 parent= (null) Xorg-747 2dN.2 275us : irq_disable: caller=_raw_spin_lock_irqsave+0x20/0x50 parent= (null) Xorg-747 2dN.3 275us : mm_lru_activate: page=00000000d262fdc6 pfn=2466257 Xorg-747 2dN.3 276us : mm_lru_activate: page=000000008b725f88 pfn=2875792 Xorg-747 2dN.3 276us : mm_lru_activate: page=000000008e31e070 pfn=3064073 Xorg-747 2dN.3 276us : mm_lru_activate: page=00000000774be734 pfn=2917451 Xorg-747 2dN.3 276us : mm_lru_activate: page=00000000c945de9c pfn=2021174 Xorg-747 2dN.3 277us : mm_lru_activate: page=0000000062d8ec6a pfn=2744545 Xorg-747 2dN.3 277us : mm_lru_activate: page=0000000080bc2df3 pfn=1899247 Xorg-747 2dN.3 277us : mm_lru_activate: page=00000000248a1143 pfn=2886580 Xorg-747 2dN.3 277us : mm_lru_activate: page=00000000ab7567ef pfn=2708231 Xorg-747 2dN.3 278us : mm_lru_activate: page=00000000c8601ee2 pfn=2031604 Xorg-747 2dN.3 278us : mm_lru_activate: page=0000000073cddaf3 pfn=2775238 Xorg-747 2dN.3 278us : mm_lru_activate: page=00000000b558f9cf pfn=2937059 Xorg-747 2dN.3 278us : mm_lru_activate: page=00000000fedc94ed pfn=2732924 Xorg-747 2dN.3 279us : mm_lru_activate: page=00000000d304f759 pfn=2319768 Xorg-747 2dN.3 279us : mm_lru_activate: page=000000000f98cd55 pfn=2336125 Xorg-747 2dN.3 279us : _raw_spin_unlock_irqrestore <-pagevec_lru_move_fn Xorg-747 2dN.3 279us : irq_enable: caller=_raw_spin_unlock_irqrestore+0x40/0x60 parent= (null) Xorg-747 2dN.2 280us : irq_disable: caller=free_unref_page_list+0xc1/0x220 parent= (null) Xorg-747 2dN.2 280us : irq_enable: caller=free_unref_page_list+0x204/0x220 parent= (null) Xorg-747 2dN.3 283us : irq_disable: caller=wakeup_tracer_call+0x7d/0xe0 parent= (null) Xorg-747 2.N.2 283us : _raw_spin_lock_irqsave <-pagevec_lru_move_fn Xorg-747 2dN.3 284us : irq_enable: caller=wakeup_tracer_call+0xcf/0xe0 parent= (null) Xorg-747 2dN.2 284us : irq_disable: caller=_raw_spin_lock_irqsave+0x20/0x50 parent= (null) Xorg-747 2dN.3 284us : mm_lru_activate: page=0000000049c0942d pfn=2422419 Xorg-747 2dN.3 285us : mm_lru_activate: page=00000000e64c4c24 pfn=2651893 Xorg-747 2dN.3 285us : mm_lru_activate: page=000000005ca129cc pfn=2002176
  • 42. IRQ and Preemption Latency ● When interrupts or preemption is disabled – Other tasks can not be scheduled in ● Tracers: – irqsoff ● Interesting info – preemptoff ● interesting info – preemptirqsoff ● Useful info ● The only one I use 42
  • 43. Preempt and IRQs Off Latency # trace-cmd start -p preemptirqsoff -d # trace-cmd show | less # tracer: preemptirqsoff # # preemptirqsoff latency trace v1.1.5 on 4.19.0-rc4-test+ # -------------------------------------------------------------------- # latency: 1100 us, #4/4, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4) # ----------------- # | task: Xorg-747 (uid:0 nice:0 policy:0 rt_prio:0) # ----------------- # => started at: __mutex_lock.isra.5 # => ended at: __mutex_lock.isra.5 # # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # / ||||| | / Xorg-747 1...1 0us#: __mutex_lock.isra.5 <-__mutex_lock.isra.5 Xorg-747 1...1 1100us : __mutex_lock.isra.5 <-__mutex_lock.isra.5 Xorg-747 1...1 1101us+: tracer_preempt_on <-__mutex_lock.isra.5 Xorg-747 1...1 1138us : <stack trace> => i915_gem_fault => __do_fault => __handle_mm_fault => handle_mm_fault => __do_page_fault => page_fault
  • 44. Preempt and IRQs Off Latency # echo 1 > /sys/kernel/debug/tracing/options/sym-offset # trace-cmd show | less # tracer: preemptirqsoff # # preemptirqsoff latency trace v1.1.5 on 4.19.0-rc4-test+ # -------------------------------------------------------------------- # latency: 1100 us, #4/4, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4) # ----------------- # | task: Xorg-747 (uid:0 nice:0 policy:0 rt_prio:0) # ----------------- # => started at: __mutex_lock.isra.5+0x3a/0x4e0 # => ended at: __mutex_lock.isra.5+0x1d6/0x4e0 # # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # / ||||| | / Xorg-747 1...1 0us#: __mutex_lock.isra.5+0x3a/0x4e0 <-__mutex_lock.isra.5+0x3a/0x4e0 Xorg-747 1...1 1100us : __mutex_lock.isra.5+0x1d6/0x4e0 <-__mutex_lock.isra.5+0x1d6/0x4e0 Xorg-747 1...1 1101us+: tracer_preempt_on+0xf4/0x110 <-__mutex_lock.isra.5+0x1d6/0x4e0 Xorg-747 1...1 1138us : <stack trace> => i915_gem_fault+0xc7/0x550 [i915] => __do_fault+0x20/0xe0 => __handle_mm_fault+0xdf7/0x15a0 => handle_mm_fault+0x11e/0x260 => __do_page_fault+0x283/0x580 => page_fault+0x1e/0x30
  • 45. IRQ and Preemption Latency ● When interrupts or preemption is disabled – Other tasks can not be scheduled in ● Tracers: – irqsoff ● Interesting info – preemptoff ● interesting info – preemptirqsoff ● Useful info ● The only one I use 45
  • 46. The “trace_marker” and “tracing_on” files ● /sys/kernel/tracing/trace_marker – Let’s userspace write into the kernel ring buffer – Application can write into it to tag where it discovered an issue ● /sys/kernel/tracing/tracing_on – Can enable or disable writing to the ring buffer – Note, when off, it also prevents new “max latency” from being recorded ● by the wakeup, and preempt/irqs off tracers 46
  • 47. Using trace_marker and tracing_on in C code static int marker_fd = -1; static int tracing_fd = -1; static __thread char buff[BUFSIZ+1]; static void write_marker(const char *fmt, ...) { va_list ap; int n; if (marker_fd < 0) return; va_start(ap, fmt); n = vsnprintf(buff, BUFSIZ, fmt, ap); va_end(ap); write(marker_fd, buff, n); } static void set_tracing (int on) { char val[1]; if (tracing_fd < 0) return; val[0] = ‘0’ + on; write(tracing_fd, val, 1); } [..] // On error write_marker(“Detected a latency of %d microsecondsn”, latency); set_tracing(0);
  • 48. Having cyclictest stop on max threshold ● cyclictest is aware of the tracing infrastructure – “-b 500” : break on if latency is greater than 500 microseconds ● More options that we are not using but could have (All require -b option) – “-E” enable all events – “-f” enable function tracing – “-I” enable irqsoff tracer – “-P” enable preemptoff tracer – “-w” enable wakeup tracer – “-W” enable wakeup_rt tracer 48
  • 49. Preempt and IRQs Off Latency # ./cyclictest -p80 -i250 -n -a -t -q -d 0 -b 500 # /dev/cpu_dma_latency set to 0us INFO: debugfs mountpoint: /sys/kernel/debug/tracing/ T: 0 (15126) P:80 I:250 C: 169015 Min: 2 Act: 8 Avg: 9 Max: 267 T: 1 (15127) P:80 I:250 C: 169011 Min: 1 Act: 11 Avg: 9 Max: 305 T: 2 (15128) P:80 I:250 C: 169014 Min: 1 Act: 7 Avg: 9 Max: 248 T: 3 (15129) P:80 I:250 C: 169009 Min: 1 Act: 560 Avg: 9 Max: 560 # Thread Ids: 15126 15127 15128 15129 # Break thread: 15129 # Break value: 560 => page_fault # ./cyclictest -p80 -i250 -n -a -t -q -d 0 -b 500 # trace-cmd start -p function -e all -l '*lock*' -l '*mutex*'
  • 50. The issue has been record (we hope) ● The trace buffer has the issue (with a marker tag) ● Save the text files (just to keep them around) 50 # cp /sys/kernel/tracing/trace /some/path/save_trace_dir/trace # for file in /sys/kernel/tracing/per_cpu/cpu*/trace; do cpu=${file/%/trace} cp $file /some/path/save_trace_dir/`basename $cpu` done # ls /some/path/save_trace_dir cpu0 cpu1 cpu2 cpu3 trace
  • 51. For full power of trace-cmd ● trace-cmd extract retrieves the kernel buffer into a trace.dat file ● Can now do all sorts of filtering 51 # trace-cmd extract # trace-cmd report 2>/dev/null |grep print cyclictest-15129 [003] 23346.433979: print: tracing_mark_write: hit latency threshold (560 > 500)
  • 52. For full power of trace-cmd ● trace-cmd extract retrieves the kernel buffer into a trace.dat file ● Can now do all sorts of filtering 52 # trace-cmd extract # trace-cmd report 2>/dev/null |grep print cyclictest-15129 [003] 23346.433979: print: tracing_mark_write: hit latency threshold (560 > 500)
  • 53. # trace-cmd report -l --cpu 3 -O parent | less cyclicte-15129 3.... 23346.433176: hrtimer_init: hrtimer=0xffffb45f4290be70 clockid=CLOCK_MONOTONIC mode=0x0 [..] cyclicte-15129 3d..1 23346.433178: hrtimer_start: hrtimer=0xffffb45f4290be70 function=hrtimer_wakeup/0x0 expires=23346275012026 softexpires=23346275012026 [ 23346275013 - 23346175012 = 1us (from below) ] [.. cyclictest is in nanosleep here ..] Xorg-747 3d.h3 23346.433403: local_timer_entry: vector=236 Xorg-747 3d.h3 23346.433403: function: _raw_spin_lock_irqsave <-- hrtimer_interrupt Xorg-747 3d.h4 23346.433403: hrtimer_cancel: hrtimer=0xffffb45f4290be70 Xorg-747 3d.h4 23346.433403: function: _raw_spin_unlock_irqrestore <-- __hrtimer_run_queues Xorg-747 3d.h3 23346.433403: hrtimer_expire_entry: hrtimer=0xffffb45f4290be70 now=23346275013126 function=hrtimer_wakeup/0x0 [ 23346433403 - 23346275013 = 158390 (offset) ] Xorg-747 3d.h3 23346.433403: function: _raw_spin_lock_irqsave <-- try_to_wake_up [..] Xorg-747 3dNh5 23346.433403: sched_wakeup: cyclictest:15129 [19] success=1 CPU:003 Xorg-747 3dNh5 23346.433403: function: __lock_text_start <-- try_to_wake_up Xorg-747 3dNh4 23346.433403: function: _raw_spin_unlock_irqrestore <-- try_to_wake_up Xorg-747 3dNh3 23346.433403: hrtimer_expire_exit: hrtimer=0xffffb45f4290be70 [..] Xorg-747 3dNh3 23346.433403: local_timer_exit: vector=236 Xorg-747 3.N.1 23346.433409: function: lock_page_memcg <-- page_remove_rmap Xorg-747 3dN.2 23346.433956: function: __rcu_read_lock <-- cpuacct_charge Xorg-747 3dN.2 23346.433957: function: __rcu_read_unlock <-- update_curr Xorg-747 3dN.2 23346.433957: function: __rcu_read_lock <-- update_curr Xorg-747 3dN.2 23346.433957: function: __rcu_read_unlock <-- update_curr Xorg-747 3d..2 23346.433958: sched_switch: Xorg:747 [120] R ==> cyclictest:15129 [19] [..] cyclicte-15129 3.... 23346.433979: print: tracing_mark_write: hit latency threshold (560 > 500)
  • 54. Lock Stats (based off of Lockdep) ● lockdep - checks correctness of locking – Avoids various deadlock scenarios ● lockstat - built off of lockdep – Records when a task waits on a lock – Records how much time it waited – Records contention between different CPUs – Records acquisitions too ● See Documentation/locking/lockstats.txt 54
  • 55. The /proc/lockstat file ● The headers – con-bounces : How many times contended across CPUs – contentions : Number of locks acquisitions that had to wait – wait time ● min: Shortest (non-zero) wait time ● max: Longest wait time ● total: Total amount of time tasks had to wait ● avg: The average time a task waited – acq-bounces : Number of acquisitions that crossed CPUs – acquisitions: The number of times the lock was acquired – hold time - min: max: total: avg: Same as wait time but for time lock was held 55
  • 56. trylock(lock) record lock contetion(&lock) record lock acquisition(&lock) lock(&lock) How lockstats work
  • 57. lock_stat version 0.4 ------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------- class name con-bounces contentions waittime-min waittime-max waittime-total waittime-avg acq-bounces acquisitions holdtime-min holdtime-max holdtime-total holdtime-avg ------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------- &(&n->list_lock)->rlock: 1332195 1334443 0.07 9686.41 2573984.58 1.93 3643104 26288751 0.00 21988.08 15069393.95 0.57 ----------------------- &(&n->list_lock)->rlock 210234 [<000000001b722b79>] get_partial_node.isra.69.part.70+0x38/0x3b0 &(&n->list_lock)->rlock 147421 [<00000000a298aeee>] deactivate_slab.isra.67+0x500/0x6e0 &(&n->list_lock)->rlock 683236 [<000000008a6cb3ab>] free_debug_processing+0x3f/0x270 &(&n->list_lock)->rlock 246105 [<000000007fc36e41>] __slab_free+0xc5/0x3f0 ----------------------- &(&n->list_lock)->rlock 1008985 [<000000008a6cb3ab>] free_debug_processing+0x3f/0x270 &(&n->list_lock)->rlock 77749 [<00000000a298aeee>] deactivate_slab.isra.67+0x500/0x6e0 &(&n->list_lock)->rlock 137428 [<000000001b722b79>] get_partial_node.isra.69.part.70+0x38/0x3b0 &(&n->list_lock)->rlock 83846 [<000000007fc36e41>] __slab_free+0xc5/0x3f0 ....................................................................................................................................................... ...................................................................... kmemleak_lock-W: 340821 341229 0.06 10471.90 535946.05 1.57 1944828 8016988 0.00 4676.63 4406716.68 0.55 kmemleak_lock-R: 4624 4652 0.10 73.34 4135.42 0.89 4887 999302 0.00 681.39 1320770.44 1.32 --------------- kmemleak_lock 169288 [<00000000795f3b3d>] find_and_remove_object+0x1b/0x90 kmemleak_lock 171942 [<000000000071b79a>] create_object+0x161/0x2c0 kmemleak_lock 4453 [<00000000554658c3>] find_and_get_object+0x45/0xb0 kmemleak_lock 199 [<00000000dfc7b05b>] scan_block+0x2a/0x110 --------------- kmemleak_lock 198499 [<000000000071b79a>] create_object+0x161/0x2c0 kmemleak_lock 145759 [<00000000795f3b3d>] find_and_remove_object+0x1b/0x90 kmemleak_lock 1445 [<00000000554658c3>] find_and_get_object+0x45/0xb0 kmemleak_lock 179 [<00000000dfc7b05b>] scan_block+0x2a/0x110 ....................................................................................................................................................... ......................................................................