kallsyms: add update trigger on bpf_ksym_add#1019
kallsyms: add update trigger on bpf_ksym_add#1019christos68k merged 25 commits intoopen-telemetry:mainfrom
Conversation
Notify Symbolizer for kallsyms about changes to eBPF programs. Fixes open-telemetry#938 Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
fabled
left a comment
There was a problem hiding this comment.
Thanks this seems leanest implementation to me.
I think the reload triggering needs more work.
I'd also avoid the kernel version check (and related changes to package moving). Mostly because redhat (and some others) maintain their own stuff and pure version check can result in wrong behavior.
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
| } | ||
|
|
||
| if err = t.attachToKallsymsUpdates(); err != nil { | ||
| return err |
There was a problem hiding this comment.
We should cleanup/disable the perfEvents here (as nobody is calling Tracer.Close if AttachTracer fails).
There was a problem hiding this comment.
Tracer.Close() is called via ctlr.Shutdown().
So, if AttachTracer() fails then ctlr.Start() fails and it will trigger the cleanup.
There was a problem hiding this comment.
AFAICT from reading this code, this is not executed when the profiler is running as a receiver inside OTel collector.
It's also better to deal with the in-between private state inside the method -as it's the method that created it-, rather than propagate this private state outside and depend on an external caller of a different method (as we're then introducing a time-window where there's invalid private state that depends on further action for cleanup).
There was a problem hiding this comment.
This code path is executed by the OTel collector, as BuildProfilesReceiver() (and xreceiver.Profiles) satisfies the component.Factory interface with its Shutdown(context.Context) error function. Here we implement it.
There was a problem hiding this comment.
When reading the interface docstring, I don't see anything that mentions Shutdown being called when Start fails.
Regardless of that, it's not right to delay cleanup in this case and introduce implicit dependencies on external components: it violates encapsulation and the principle of single responsibility, thus making the code harder to reason about.
It's this method that introduces this in-between state and it should be this method that cleans it up when it fails (this is similar to RAII).
There was a problem hiding this comment.
Addded terminatePerfEvents() as cleanup routine for failures with d391075
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
|
Yes, reading full kallsyms is very cpu heavy. Tracking and queueing the probes can be problematic too. I wonder if kallsyms can be seeked, and we could just read the non-module portion of it from the end directly. |
|
It's interesting that I cross-checked it with just perf: I wonder if there's something quadratic going on there and we just need to fix the kernel itself as the first step. |
|
I took a stab at fixing it upstream:
|
Could you open an issue to track this instead of this merged PR. I suspect your use case is quite special from most other use cases so its not immediate issue. But the solution would require quite a bit of work to make it robust and work without too much overhead. I think the design and further points should be discussed in a new issue. Thanks. |
|
I made #1151 for this. |



Notify Symbolizer for kallsyms about changes to eBPF programs.
Fixes #938