---
title: "Scoped BPF_ENABLE_STATS accounting"
---

> Documentation Index
> Fetch the complete documentation index at: https://example.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scoped BPF_ENABLE_STATS accounting

Pillar 1 asks: *what did eBPF itself spend?* Instead of flipping global `sysctl kernel.bpf_stats_enabled=1` (which stays stuck on after crashes), open a scoped [BPF_ENABLE_STATS](https://example.com/ebpf-field-guide/glossary/#bpf_enable_stats) file descriptor.

The kernel records exact `run_time_ns`, `run_cnt`, `memlock`, and JIT bytes per loaded program ID—and turns stats off automatically the instant the profiler exits (or duty-cycles via `--stats-mode sample`).

Source: https://example.com/ebpf-field-guide/tracing-security-and-overhead/measuring-overhead/bpf-stats/index.mdx
