-
Notifications
You must be signed in to change notification settings - Fork 412
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
Fix ksymbols mem consumption #4095
Fix ksymbols mem consumption #4095
Conversation
fa45261
to
16e19b5
Compare
16e19b5
to
b210980
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.
Note the last comment in particular, that is an oversight I made in the original implementation.
@@ -862,6 +890,104 @@ func (t *Tracee) newConfig(cfg *policy.PoliciesConfig, version uint16) *Config { | |||
} | |||
} | |||
|
|||
func (t *Tracee) initKsymTableRequiredSyms() error { |
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.
We need to make sure we always initialize the text segment in relevant events. Perhaps we may want it as a symbol always present. WDYT?
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.
Shouldn't this be handled by event dependencies?
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.
It should, that's why the first part was about double-checking that.
Tested and the args from Related to the memory footprint this clearly brings a smaller initial mem consumption (RSS): This PR
main branch
|
b210980
to
c111214
Compare
@NDStrahilevitz I addressed some of your comments. The remainder is left for further consideration. |
My last comment still seems rather critical IMO, @yanivagman WDYT? I fear that if we don't address it we will introduce a performance regression while a |
0636aa9
to
ef12be7
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.
LGTM once e2e fixes are resolved.
The hooked_syscalls and do_init_module events require CAP_SYSLOG in order to refresh its symbol table when reading /proc/kallsyms. Add these missing dependencies.
ef12be7
to
6913d6b
Compare
@yanivagman @NDStrahilevitz ignore the wip (3cacd03). It can be overridden. |
3cacd03
to
c81d337
Compare
86bd02a
to
29b75af
Compare
2e1871a
to
646578f
Compare
pkg/ebpf/c/tracee.bpf.c
Outdated
kernel_new_mod_t new_mod = {.insert_time = insert_time}; | ||
u64 mod_addr = (u64) mod; | ||
// new_module_map - must be after the module is added to modules list, | ||
// otherwise there's a risk for race condition | ||
bpf_map_update_elem(&new_module_map, &mod_addr, &new_mod, BPF_ANY); |
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.
@OriGlassman Proposed this internally afaik, should we keep this?
646578f
to
425af51
Compare
Use modified ksymbols implementation. The new implementation may take a list of required symbols and addresses to track. If the list is given, symbol scanning will only save those symbols or addresses which were given in the list. If a new symbol is queried, then a rescan is needed. Refactor tracee initialization to find all necessary symbols to track ahead of runtime. Co-authored-by: Geyslan Gregório <geyslan@gmail.com> Co-authored-by: Yaniv Agman <yanivagman@gmail.com>
This commit refactors the refresh logic of KernelSymbolTable to be sequential, removing the use of goroutines and channels. The decision to simplify the code was made for the following reasons: 1. Simplicity: The sequential approach simplifies the codebase, making it easier to understand, maintain, and debug. 2. Less Relevant Concurrency: With the introduction of "required symbols", the need for concurrency has been reduced. We now skip memory allocation for symbols that are not required, which constitutes the majority of the symbols in /proc/kallsyms.
f436739
to
3879a21
Compare
1. Explain what the PR does
2. Explain how to test it
3. Other comments