Replies: 1 comment 3 replies
If you provide the script, maybe we can use it to create new tests. Regarding hardcoded kernel offsets, there's actually an open issue (#198) where stability tests are still missing. IMO, we can use this tool [little-vm-helper](https://github.com/cilium/little-vm-helper) to set up a CI job that triggers when a push is made to the Ensuring stability across kernel versions could pave the way for creating a standalone version of the
After that, we can publish standalone versions alongside the Ubuntu and Alpine versions.
I'll reply to this one directly in the #258 discussion because the decision should be made in the same discussion.
Same for this one. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I spent some time on main trying to understand the event numbers in #258 and ended up going through the whole metrics path. I tested on a 6.18.44 VM with root, BPF, tracepoints and uprobes, but no kprobes and no CONFIG_SCHEDSTATS. To count what actually comes out of
read_perf_bufferI used a small C program writing CpuIdle-shaped records into a PERF_EVENT_ARRAY, plus a C stand-in for the metrics_tracer object so I could run the realcortexflow-metricsbinary. I did this together with Claude, so the commits are co-authored.The main thing: every consumer reads one event per CPU per poll.
BufferSize::set_buffer()allocatesonline_cpus().iter().len()buffers, butonline_cpus()returns aResult<Vec<u32>, _>, so that isResult::iter()and the length is always 1.read_events()copies one event into each buffer, then the loop sleeps 5 s (100 ms in the Docker example). 10,000 events at 1k/s: 3 received with the 5 s default, 244 with 100 ms. With a real batch, draining each ring until it's empty and 100 ms as the default: 10,000 out of 10,000. This is probably part of #258 too, since with 100 ms polling the reader can't go above 10 events/s per CPU per map.Fixed in #261, together with:
kernel.sched_schedstats=1)Metadata::enrich()walked all of /host/sys/fs/cgroup and built a kube Client for every eventextract_pod_uid()returnedkubepods-pod<uid>for Guaranteed pods and nothing with the cgroupfs driverlast_stateinstead ofstatewith (u32)-1, so after its first exit event a CPU never emits againcfcli install simple-exampledownloads from feature/ebpf-core, which no longer existsThings I didn't touch and would like your opinion on.
Hardcoded kernel offsets. I compared them with pahole against the 6.18.44 BTF. In struct sock five of seven match, but sk_err_soft reads 600 (sk_ack_backlog here; sk_err_soft is at 372) and sk_ack_backlog reads 604 (sk_max_ack_backlog). In net_device only
statematches: nd_net is at 264 not 280, name at 280 not 304, and dev_addr is a pointer at 968, not 6 bytes at 1080. In struct net, ns is at 152 (not 120) and inum is at 24 in ns_common (not 16). sk_buff->data is at 200, not 208. Some of these depend on the kernel config more than the version, so any fixed number is right for one build. I'd resolve them at load time from /sys/kernel/btf/vmlinux and pass them in as globals, or move what we can to tp_btf/fentry. Same for the sched tracepoints: on 6.18commis a __data_loc string, so runtime/delay sit at offset 16, while with the oldchar comm[16]they are at 32. Reading the tracepoint format file at startup covers both.Two semantic problems in the probes. In tcp_v4_rcv, skb->data already points at the TCP header (ip_local_deliver_finish pulls the IP header), so reading the IP header from it gives TCP bytes; and tcp_v4_connect receives a struct sock, not an sk_buff. And pid/comm/cgroup read with the bpf_get_current_* helpers in the TC classifier, tcp_v4_rcv and sched_stat_wait belong to whatever task happened to be running, not to the packet or the task that waited.
The TC classifier returns TC_ACT_SHOT on its own parse errors, not only on blocklist hits. I'd let traffic through on errors; I left it alone because #259 is changing tc.rs.
On the metrics side, every instrument has tgid as an attribute, so we get one series per process, and with PID churn we end up in the SDK's overflow bucket (2000 series per instrument by default). And ssl_*_bytes and enter_mem_alloc are gauges, so only the last value of each export interval survives; counters or histograms would keep the totals.
What do you think about resolving offsets at load time? It's what I'd like to work on next, but I'd rather agree on the approach first.
All reactions