]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: add tracepoint for search slot restart tracking
authorLeo Martins <loemra.dev@gmail.com>
Thu, 26 Feb 2026 09:51:08 +0000 (01:51 -0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:56:00 +0000 (18:56 +0200)
commitcc970d21c4f37b7cbedd73e043b69faf2c66a6fe
tree06d63a845dda044e4fbeded1c57b210460fbf505
parentf9a48549a15aa369d42cebc08a6a72b71a53d547
btrfs: add tracepoint for search slot restart tracking

Add a btrfs_search_slot_restart tracepoint that fires at each restart
site in btrfs_search_slot(), recording the root, tree level, and
reason for the restart. This enables tracking search slot restarts
which contribute to COW amplification under memory pressure.

The four restart reasons are:
 - write_lock: insufficient write lock level, need to restart with
   higher lock
 - setup_nodes: node setup returned -EAGAIN
 - slot_zero: insertion at slot 0 requires higher write lock level
 - read_block: read_block_for_search returned -EAGAIN (block not
   cached or lock contention)

COW counts are already tracked by the existing trace_btrfs_cow_block()
tracepoint. The per-restart-site tracepoint avoids counter overhead
in the critical path when tracepoints are disabled, and provides
richer per-event information that bpftrace scripts can aggregate into
counts, histograms, and per-root breakdowns.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Leo Martins <loemra.dev@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
include/trace/events/btrfs.h