Repository navigation
Perf improvement and misc fixes - #27
Merged
Merged
Conversation
bpf_get_stack() zero-fills whatever part of the buffer the stack does not reach, and the buffer is sized from kernel.perf_event_max_stack, so raising that sysctl made every traced allocation pay for clearing the whole buffer: with the limit at 4095 frames a kmalloc()/kfree() pair cost 430 ns under tracing against 190 ns at the default of 127, with the difference entirely in memset. Capture into the first 127 frames of the buffer first and repeat the capture with the whole buffer only when the stack filled it. At the default limit nothing changes and the second capture never runs; at 4095 the pair is back to 192 ns, and only stacks deeper than 127 frames are unwound twice.
The allocs map holds a million entries and an update that fails because it is full was ignored, so a module with more outstanding allocations than that had the excess silently untracked and their leaks missed. Count the failures and print a warning after the report, as is done for truncated stacks, and have every test check that nothing was dropped.
record_free() printed the size of the freed allocation, under -t, from the map entry it had just deleted. Hash map entries are recycled through the BPF allocator and can be handed to another CPU's update as soon as they are deleted, so the printed size could be that of an unrelated allocation. Copy it out first.
The text ranges stayed set after module_free, so until userspace had read the report and detached, allocations from any module loaded into the same addresses were attributed to the traced one. Clear the ranges in the module_free handler; frees are still matched by address.
The percpu_alloc_percpu tracepoint only gained its bytes_alloc field, which the handler reads, in 5.19, so -P fails to load on older kernels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.