Repository navigation
fix(memtrack): quiet expected libbpf warnings in a user namespace - #602
GuillaumeLagrange wants to merge 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
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
| /// Route libbpf's output through the logger, so `CODSPEED_LOG` filters it like | ||
| /// any other target (e.g. `libbpf=debug`). The minimum level follows the | ||
| /// logger's so libbpf skips formatting messages that would be dropped. | ||
| pub fn init_libbpf_logging() { |
There was a problem hiding this comment.
we don't really need this anymore after we merge #531, right?
There was a problem hiding this comment.
I think we do though, it's for libbpf loggin not really memtrack logging
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