Skip to content

Commit

Permalink
bcc: criticalstat: Add an atomic critical section tracer (iovisor#1801)
Browse files Browse the repository at this point in the history
This tool detects code sections in the kernel where IRQs or preemption
are disabled for a user-specified amount of time.

Requires a kernel built with CONFIG_DEBUG_PREEMPT and
CONFIG_PREEMPTIRQ_EVENTS.

Signed-off-by: Joel Fernandes <[email protected]>
  • Loading branch information
joelagnel authored and yonghong-song committed Jun 19, 2018
1 parent 116bb40 commit 0b813f8
Show file tree
Hide file tree
Showing 4 changed files with 545 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pair of .c and .py files, and some are directories of files.
- tools/[cachetop](tools/cachetop.py): Trace page cache hit/miss ratio by processes. [Examples](tools/cachetop_example.txt).
- tools/[cpudist](tools/cpudist.py): Summarize on- and off-CPU time per task as a histogram. [Examples](tools/cpudist_example.txt)
- tools/[cpuunclaimed](tools/cpuunclaimed.py): Sample CPU run queues and calculate unclaimed idle CPU. [Examples](tools/cpuunclaimed_example.txt)
- tools/[criticalstat](tools/criticalstat.py): Trace and report long atomic critical sections in the kernel. [Examples](tools/criticalstat_example.txt)
- tools/[dbslower](tools/dbslower.py): Trace MySQL/PostgreSQL queries slower than a threshold. [Examples](tools/dbslower_example.txt).
- tools/[dbstat](tools/dbstat.py): Summarize MySQL/PostgreSQL query latency as a histogram. [Examples](tools/dbstat_example.txt).
- tools/[dcsnoop](tools/dcsnoop.py): Trace directory entry cache (dcache) lookups. [Examples](tools/dcsnoop_example.txt).
Expand Down
74 changes: 74 additions & 0 deletions man/man8/criticalstat.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.TH criticalstat 8 "2018-06-07" "USER COMMANDS"
.SH NAME
criticalstat \- A tracer to find and report long atomic critical sections in kernel
.SH SYNOPSIS
.B criticalstat [\-h] [\-p] [\-i] [\-d DURATION]
.SH DESCRIPTION

criticalstat traces and reports occurences of atomic critical sections in the
kernel with useful stacktraces showing the origin of them. Such critical
sections frequently occur due to use of spinlocks, or if interrupts or
preemption were explicity disabled by a driver. IRQ routines in Linux are also
executed with interrupts disabled. There are many reasons. Such critical
sections are a source of long latency/responsive issues for real-time systems.

This works by probing the preempt/irq and cpuidle tracepoints in the kernel.
Since this uses BPF, only the root user can use this tool. Further, the kernel
has to be built with certain CONFIG options enabled. See below.

.SH REQUIREMENTS
Enable CONFIG_PREEMPTIRQ_EVENTS and CONFIG_DEBUG_PREEMPT. Additionally, the
following options should be DISABLED on older kernels: CONFIG_PROVE_LOCKING,
CONFIG_LOCKDEP.
.SH OPTIONS
.TP
\-h
Print usage message.
.TP
\-p
Find long sections where preemption was disabled on local CPU.
.TP
\-i
Find long sections where interrupt was disabled on local CPU.
.TP
\-d DURATION
Only identify sections that are longer than DURATION in microseconds.
.SH EXAMPLES
.TP
Run with default options: irq disabled for more than 100 uS
#
.B criticalstat
.TP
Find sections with preemption disabled for more than 100 uS.
#
.B criticalstat -p
.TP
Find sections with IRQ disabled for more than 500 uS.
#
.B criticalstat -d 500
.TP
Find sections with preemption disabled for more than 500 uS.
#
.B criticalstat -p -d 500
.SH OVERHEAD
This tool can cause overhead if the application is spending a lot of time in
kernel mode. The overhead is variable but can be 2-4% of performance
degradation. If overhead is seen to be too much, please pass a higher DURATION
to the -d option to filter more aggressively.

.SH SOURCE
This is from bcc.
.IP
https://github.com/iovisor/bcc
.PP
Also look in the bcc distribution for a companion _examples.txt file containing
example usage, output, and commentary for this tool.
.SH OS
Linux
.SH STABILITY
Unstable - in development.
.SH AUTHOR
Joel Fernandes
.SH SEE ALSO
Linux kernel's preemptoff and irqoff tracers.

Loading

0 comments on commit 0b813f8

Please sign in to comment.