Caching policy lookups per inode cuts eBPF security agent CPU cost ~90%

JeremyCMorgan · x · 2026-09-25

Developer Nathan Naveen details an optimization to his open-source eBPF security agent (github.com/bomfather/agent).

Problem: using an LSM hook on file open, the agent reconstructs the path and walks up parent dentries to find which path-based policy applies. Deciding which policy applies — not enforcing it — dominated kernel CPU cost, especially with repeated access to the same subtrees (e.g. Postgres reading its data directory).

Fix: memoize the resulting policy per inode. Kernel CPU cost dropped about 90%.

Key lesson: the hard part is the cache key and invalidation under Linux filesystem semantics. The author notes the code is hand-written, not AI-generated.

Original post →

More from coding & agent

coding & agent channel →