compactsnoop(8) System Manager's Manual compactsnoop(8)

# [NAME](#NAME)

compactsnoop - Trace compact zone events. Uses Linux eBPF/bcc.

# [SYNOPSIS](#SYNOPSIS)

**compactsnoop \[-h] \[-T] \[-p PID] \[-d DURATION] \[-K] \[-e]**

# [DESCRIPTION](#DESCRIPTION)

compactsnoop traces the compact zone events, showing which processes are allocing pages with memory compaction. This can be useful for discovering when compact\_stall (/proc/vmstat) continues to increase, whether it is caused by some critical processes or not.

This works by tracing the compact zone events using raw\_tracepoints and one kretprobe.

For the Centos 7.6 (3.10.x kernel), see the version under tools/old, which uses an older memory compaction mechanism.

Since this uses BPF, only the root user can use this tool.

# [REQUIREMENTS](#REQUIREMENTS)

CONFIG\_BPF and bcc.

# [OPTIONS](#OPTIONS)

[-h](#h)

Print usage message.

[-T](#T)

Include a timestamp column.

[-p PID](#p)

Trace this process ID only (filtered in-kernel).

[-d DURATION](#d)

Total duration of trace in seconds.

[-K](#K)

Output kernel stack trace

[-e](#e)

Show extended fields.

# [EXAMPLES](#EXAMPLES)

[Trace all compact zone events:](#Trace)

\# **compactsnoop**

[Trace all compact zone events, for 10 seconds only:](#Trace~2)

\# **compactsnoop -d 10**

# [FIELDS](#FIELDS)

[TIME(s)](#TIME%28s%29)

Time of the call, in seconds.

[COMM](#COMM)

Process name

[PID](#PID)

Process ID

[NODE](#NODE)

Memory node

[ZONE](#ZONE)

Zone of the node (such as DMA, DMA32, NORMAL eg)

[ORDER](#ORDER)

Shows which order alloc cause memory compaction, -1 means all orders (eg: write to /proc/sys/vm/compact\_memory)

[MODE](#MODE)

SYNC OR ASYNC

[FRAGIDX (extra column)](#FRAGIDX)

The FRAGIDX is short for fragmentation index, which only makes sense if an allocation of a requested size would fail. If that is true, the fragmentation index indicates whether external fragmentation or a lack of memory was the problem. The value can be used to determine if page reclaim or compaction should be used.

Index is between 0 and 1 so return within 3 decimal places

0 =&gt; allocation would fail due to lack of memory

1 =&gt; allocation would fail due to fragmentation

[MIN (extra column)](#MIN)

The min watermark of the zone

[LOW (extra column)](#LOW)

The low watermark of the zone

[HIGH (extra column)](#HIGH)

The high watermark of the zone

[FREE (extra column)](#FREE)

The nr\_free\_pages of the zone

[LAT(ms)](#LAT%28ms%29)

compact zone's latency

[STATUS](#STATUS)

The compaction's result.

For (CentOS 7.6's kernel), the status include:

"skipped" (COMPACT\_SKIPPED): compaction didn't start as it was not possible or direct reclaim was more suitable

"continue" (COMPACT\_CONTINUE): compaction should continue 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):

"not\_suitable\_zone" (COMPACT\_NOT\_SUITABLE\_ZONE): For more detailed tracepoint output - internal to compaction

"skipped" (COMPACT\_SKIPPED): compaction didn't start as it was not possible or direct reclaim was more suitable

"deferred" (COMPACT\_DEFERRED): compaction didn't start as it was deferred due to past failures

"no\_suitable\_page" (COMPACT\_NOT\_SUITABLE\_PAGE): For more detailed tracepoint output - internal to compaction

"continue" (COMPACT\_CONTINUE): compaction should continue to another pageblock

"complete" (COMPACT\_COMPLETE): The full zone was compacted scanned but wasn't successful to compact suitable pages.

"partial\_skipped" (COMPACT\_PARTIAL\_SKIPPED): direct compaction has scanned part of the zone but wasn't successful to compact suitable pages.

"contended" (COMPACT\_CONTENDED): compaction terminated prematurely due to lock contentions

"success" (COMPACT\_SUCCESS): direct compaction terminated after concluding that the allocation should now succeed

# [OVERHEAD](#OVERHEAD)

This traces the kernel compact zone kprobe/kretprobe or raw\_tracepoints and prints output for each event. As the rate of this is generally expected to be low (&lt; 1000/s), the overhead is also expected to be negligible.

# [SOURCE](#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.

# [OS](#OS)

Linux

# [STABILITY](#STABILITY)

Unstable - in development.

# [AUTHOR](#AUTHOR)

Wenbo Zhang

2019-11-1 USER COMMANDS

---

Document: compactsnoop(8) from bcc 0.37.0-r3 (Chainguard OS)
Source: https://github.com/iovisor/bcc
