compactsnoop(8)
β¨ NAME β¨
compactsnoop(8) from the System Manager's Manual π
compactsnoop β Trace compact zone events. Uses Linux eBPF/bcc. π¦
πΈ SYNOPSIS πΈ
compactsnoop [-h] [-T] [-p PID] [-d DURATION] [-K] [-e]
π DESCRIPTION π
okay so compactsnoop traces the compact zone events and shows you which processes are allocing pages with memory compaction π this is lowkey so useful for figuring out when compact_stall (/proc/vmstat) keeps climbing, and whether some critical processes are the ones causing it π
it works by tracing the compact zone events using raw_tracepoints and one kretprobe β¨
π for the CentOS 7.6 (3.10.x kernel), check the version under tools/old, which uses an older memory compaction mechanism. different vibes, different code!
and since this uses BPF, only the root user can run this tool π
π§ REQUIREMENTS π§
you need CONFIG_BPF and bcc π
β¨ OPTIONS β¨
-hβ print the usage message π-Tβ add a timestamp column π°οΈ-p PIDβ only trace this process ID (filtered in-kernel) π―-d DURATIONβ how long the trace runs in total, in seconds β³-Kβ output a kernel stack trace π§±-eβ show the extended fields π
π EXAMPLES π
trace all compact zone events:
# compactsnoop
trace all compact zone events, but only for 10 seconds:
# compactsnoop -d 10
π₯ FIELDS π₯
TIME(s)β when the call happened, in seconds β°COMMβ the process name π§βπ»PIDβ the process ID πͺͺNODEβ the memory node π§ZONEβ the zone of the node (like DMA, DMA32, NORMAL, etc) πΊοΈORDERβ shows which order of allocation caused the memory compaction.-1means all orders (for example, a write to/proc/sys/vm/compact_memory) π¦MODEβ SYNC or ASYNC πFRAGIDX(extra column) β short for fragmentation index, and it only makes sense if an allocation of the requested size would fail. if that's the case, the fragmentation index tells you whether external fragmentation or a lack of memory was the problem π§© you can use it to decide if page reclaim or compaction should be used π€
the index comes back between 0 and 1, to 3 decimal places:
0=> the allocation would fail due to lack of memory π«1=> the allocation would fail due to fragmentation π§
MIN(extra column) β the min watermark of the zone π§LOW(extra column) β the low watermark of the zone πHIGH(extra column) β the high watermark of the zone πFREE(extra column) β thenr_free_pagesof the zone πLAT(ms)β the compact zone's latency, in milliseconds β‘STATUSβ the result of the compaction π
for the CentOS 7.6 kernel, the statuses are:
"skipped"(COMPACT_SKIPPED): compaction didn't start, because it wasn't possible or direct reclaim was the better choice π"continue"(COMPACT_CONTINUE): compaction should keep going to another pageblock β‘οΈ"partial"(COMPACT_PARTIAL): direct compaction partially compacted a zone and there are suitable pages π§©"complete"(COMPACT_COMPLETE): the full zone was compacted π
for kernel 4.7 and above, the statuses are:
"not_suitable_zone"(COMPACT_NOT_SUITABLE_ZONE): more detailed tracepoint output, internal to compaction π§"skipped"(COMPACT_SKIPPED): compaction didn't start, because it wasn't possible or direct reclaim was the better choice π"deferred"(COMPACT_DEFERRED): compaction didn't start because it got deferred due to past failures π΅βπ«"no_suitable_page"(COMPACT_NOT_SUITABLE_PAGE): more detailed tracepoint output, internal to compaction π§"continue"(COMPACT_CONTINUE): compaction should keep going to another pageblock β‘οΈ"complete"(COMPACT_COMPLETE): the full zone was scanned, but it wasn't successful at compacting suitable pages π€"partial_skipped"(COMPACT_PARTIAL_SKIPPED): direct compaction scanned part of the zone but wasn't successful at compacting suitable pages π₯²"contended"(COMPACT_CONTENDED): compaction ended early due to lock contention π"success"(COMPACT_SUCCESS): direct compaction ended after deciding the allocation should now succeed π
π OVERHEAD π
this traces the kernel compact zone kprobe/kretprobe or raw_tracepoints and prints output for each event. the rate of events is generally expected to be low (< 1000/s), so the overhead is also expected to be negligible π«Ά
π¦ SOURCE π¦
this is from bcc π
https://github.com/iovisor/bcc
also check the bcc distribution for a companion _examples.txt file, which has example usage, output, and commentary for this tool π
π» OS π»
Linux π§
π§ STABILITY π§
β οΈ Unstable β still in development, so don't be shocked if things shift π
π AUTHOR π
Wenbo Zhang π«‘
okay bestie that's the whole tea βπ this page is from the USER COMMANDS section, dated 2019-11-1, and it's all about compactsnoop(8) πβ¨ stay iconic π πΈ
π¦ where this page comes from
- debian bookworm: bpfcc-tools 0.26.0+ds-1 Β· Apache-2.0
- debian trixie: bpfcc-tools 0.31.0+ds-7 Β· Apache-2.0
- ubuntu noble: bpfcc-tools 0.29.1+ds-1ubuntu7 Β· Apache-2.0
- ubuntu questing: bpfcc-tools 0.31.0+ds-7ubuntu2 Β· Apache-2.0
- ubuntu resolute: bpfcc-tools 0.35.0+ds-1ubuntu2 Β· Apache-2.0
- ubuntu stonking: bpfcc-tools 0.35.0+ds-1ubuntu4 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms