Repository navigation
fix(memtrack): quiet expected libbpf warnings in a user namespace - #602
GuillaumeLagrange merged 2 commits into
Conversation
libbpf's own raise is disabled: it repeats ours and warns when denied without CAP_SYS_RESOURCE.
An rss_stat attach failure (tracefs unreadable in a user namespace) now logs at debug. Closes COD-3991
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryRoutes libbpf messages through the logger and quiets expected warnings when memtrack uses a delegated BPF token.
Acknowledgment: Reviews (1) · Last reviewed commit: "fix(memtrack): route libbpf output throu..." · Reviewed by Greptile |
Merging this PR will degrade performance by 13.04%2 warnings
Performance Changes
Comparing Footnotes
|
Stop memtrack from printing libbpf warnings when it runs inside a user namespace with a delegated BPF token.
In that setup, two expected failures each printed warnings at the default log level, although memtrack recovers from both:
kmem/rss_statis a classic tracepoint. libbpf reads its id from tracefs, which checks access against the init user namespace, so the read fails with EACCES even with CAP_BPF and CAP_PERFMON. The delegated token can't help, because this path never callsbpf(). Physical-memory peaks come from the rmap fentry probes, which still attach through the token. Losing rss_stat removes only its cross-check and thecur_rssseries.setrlimit(RLIM_INFINITY)memtrack already makes and tolerates failing. libbpf's attempt is now disabled (libbpf_set_memlock_rlim(0)). Memtrack's own raise moves from after the skeleton load, where it had no effect on kernels older than 5.11, to before it.libbpftarget, soCODSPEED_LOGfilters it (e.g.CODSPEED_LOG=warn,libbpf=debug). Before, it went straight to stderr at info level and above. During the rss_stat attach, libbpf messages are logged at debug, and so is memtrack's own message about the failure.I ran each step inside the sandboxed setup above with
codspeed exec -m memory -- /bin/true. AtCODSPEED_LOG=info, there are no libbpf lines and no warnings. AtCODSPEED_LOG=debug, there are about 4.2k[DEBUG libbpf]lines, and the same run collects about 3k events. The final revision, which logs at debug during the attach, compiles and passes clippy, but has not run in that environment.Closes COD-3991