criticalstat(8)

πŸ“¦
version 0.36.1 Β· 2 versions
, in alpine 3.24, nixpkgs unstable

πŸ’… criticalstat(8): long atomic critical sections, but make it a whole vibe πŸ’…

okay so bestie, this is the criticalstat(8) page from the System Manager's Manual β€” section 8, and we are literally about to find long atomic critical sections in the kernel. slay. πŸ’–

🌸 NAME 🌸

criticalstat β€” a tracer that finds and reports long atomic critical sections in kernel. periodt. ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

criticalstat [-h] [-p] [-i] [-d DURATION]

πŸ”₯ DESCRIPTION πŸ”₯

criticalstat traces and reports occurrences of atomic critical sections in the kernel, with useful stacktraces showing the origin of them. iconic behavior, honestly. πŸ‘‘

Such critical sections frequently occur due to use of spinlocks, or if interrupts or preemption were explicitly disabled by a driver. IRQ routines in Linux are also executed with interrupts disabled. There are many reasons, bestie. Such critical sections are a source of long latency/responsive issues for real-time systems. not the vibe for real-time systems, lowkey. 😭

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. 🫢

🧚 REQUIREMENTS 🧚

Enable following kernel configurations based on which kernel version you use. config check time, bestie. πŸ› οΈ

  • CONFIG_DEBUG_PREEMPT
  • CONFIG_PREEMPT_TRACER

For kernel 4.19 and later:

  • CONFIG_PREEMPTIRQ_TRACEPOINTS
  • CONFIG_TRACE_IRQFLAGS
  • CONFIG_TRACE_PREEMPT_TOGGLE

For kernel 4.15 to 4.18:

  • CONFIG_PREEMPTIRQ_EVENTS
  • CONFIG_PROVE_LOCKING
  • CONFIG_DEBUG_PREEMPT

Additionally, the following options should be turned off on older kernels:

  • CONFIG_LOCKDEP

✨ OPTIONS ✨

  • -h β€” Print usage message. that's it, that's the whole gig. πŸ’…
  • -p β€” Find long sections where preemption was disabled on local CPU. preemption watch activated. πŸ‘€
  • -i β€” Find long sections where interrupt was disabled on local CPU. interrupt watch activated. ⚑
  • -d DURATION β€” Only identify sections that are longer than DURATION in microseconds. filter it, bestie. ⏱️

🌈 EXAMPLES 🌈

Run with default options: irq disabled for more than 100 uS

# criticalstat

Find sections with preemption disabled for more than 100 uS.

# criticalstat -p

Find sections with IRQ disabled for more than 500 uS.

# criticalstat -d 500

Find sections with preemption disabled for more than 500 uS.

# criticalstat -p -d 500

πŸ’€ OVERHEAD πŸ’€

Heads up, bestie: 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. 2-4% is not nothing, fr fr. 😭

πŸ“ SOURCE πŸ“

This is from bcc.

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. homework, but make it cute. πŸ“š

🌟 OS 🌟

Linux. obviously, bestie. 🐧

🚧 STABILITY 🚧

Unstable - in development. we are in our experimental era. πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Joel Fernandes. respect the author. πŸ’œ

πŸ” SEE ALSO πŸ”

Linux kernel's preemptoff and irqoff tracers. go read those next, iykyk. πŸ‘€


okay that's the whole criticalstat(8) page, bestie. This footer energy comes from USER COMMANDS, dated 2018-06-07, for criticalstat(8) β€” now go filter those long sections. πŸ’–βœ¨

πŸ“¦ where this page comes from