-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory optimizations: remove BTF and kallsyms caches #2937
Conversation
We use ksyms for checking the proper exit hooks when loading the base sensor. Furthermore, we use it when we add a kprobe policy for a function that is part of a kernel module. Having that always in memory, uses a lot of memory. This patch makes the read of ksyms when we need that. Signed-off-by: Anastasios Papagiannis <[email protected]>
247482f
to
59386c6
Compare
59386c6
to
573845f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! I converged to writing this independently today, thanks for doing it :)
var ( | ||
kernelSymbols *Ksyms | ||
setKernelSymbols sync.Once | ||
) | ||
|
||
func KernelSymbols() (*Ksyms, error) { | ||
var err error | ||
setKernelSymbols.Do(func() { | ||
kernelSymbols, err = NewKsyms(option.Config.ProcFS) | ||
}) | ||
return kernelSymbols, err | ||
return NewKsyms(option.Config.ProcFS) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could we add a comment there? it might be a little bit confusing why we had this function in the first place.
@@ -124,6 +125,9 @@ func (s *Sensor) Load(bpfDir string) error { | |||
progsAdd(s.Progs) | |||
AllMaps = append(AllMaps, s.Maps...) | |||
|
|||
// cleanup the BTF once we have loaded all sensor's program | |||
btf.FlushKernelSpec() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😻 perfect!
This patch flushes the BTF when we complete the loading of a sensor. Signed-off-by: Anastasios Papagiannis <[email protected]>
573845f
to
b04a57f
Compare
Do not cache large objects like the BTF and ksyms. Reload them when needed.
Before:
After: