Implement deep stack unwinding via loop-based iteration #45
Merged
Conversation
431bad9 to
a3e0eac
Compare
Owner
|
For comparison purposes |
- Add DwarfUnwindState structure for per-CPU state storage - Add ProgramArray and UNWIND_STATE maps for tail-call support - Split dwarf_copy_stack into legacy (21 frames) and future tail-call version - Update MAX_DWARF_STACK_DEPTH to 165 frames (5 frames/call × 33 tail calls) - Keep LEGACY_MAX_DWARF_STACK_DEPTH at 21 for BPF verifier compatibility - Currently using legacy implementation (tail-call version to be enabled) Co-authored-by: zz85 <314997+zz85@users.noreply.github.com> Add comprehensive tail-call unwinding documentation - Create detailed design document for tail-call implementation - Document all phases: infrastructure, implementation, testing - Include code examples and architecture decisions - Update dwarf_correctness_issues.md with progress status - Specify Phase 1 (infrastructure) complete, Phase 2-3 pending - Document fallback strategy for kernel compatibility Co-authored-by: zz85 <314997+zz85@users.noreply.github.com> Implement Phase 2: Loop-based deep stack unwinding - Implement dwarf_unwind_one_frame() for single-frame DWARF unwinding - Implement dwarf_copy_stack_with_tail_calls() with 33-iteration loop - Support up to 165 frames (5 frames × 33 iterations) - Update dwarf_copy_stack() to use new implementation - Add FRAMES_PER_TAIL_CALL import from profile-bee-common - Maintain fallback to frame-pointer unwinding when DWARF unavailable - All tests passing: DWARF unit tests, builds successfully Co-authored-by: zz85 <314997+zz85@users.noreply.github.com>
…max) Wire up PROG_ARRAY tail-call chaining so the eBPF DWARF unwinder can capture stacks far beyond the previous 21-frame BPF verifier limit. collect_trace now initializes per-CPU DwarfUnwindState and tail-calls into dwarf_unwind_step, which unwinds 5 frames per invocation and tail-calls itself (up to 33 times, kernel limit) for a theoretical max of 165 frames. Legacy 21-frame inline path remains as fallback when tail calls are unavailable (kprobe/uprobe contexts, older kernels). Key changes: - eBPF: add dwarf_try_tail_call(), dwarf_finalize_stack(), dwarf_unwind_step_impl() in lib.rs; entry point in main.rs - Common: extend DwarfUnwindState with finalization context fields (stack_ids, cmd, cpu, initial regs) so step program can complete the work started by collect_trace - Userspace: add setup_tail_call_unwinding() to load the step program and register it in PROG_ARRAY; called from main when --dwarf enabled - Tests: add deepstack fixture (50-level recursion), now captures 57 frames vs 22 before; all 14 E2E tests pass - Docs: update design doc and tail-call doc with Phase 2 completion
Fix outdated depth claims across all documentation: - README: 32 frame depth -> 165 via tail-call chaining - Design doc: update pseudocode, verifier section, and limitations to describe tail-call architecture instead of legacy flat loop - Tail-call doc: mark Phases 2b and 3 as completed - Correctness issues: mark tail-call chaining as DONE - Literature doc: 32 frames -> 165 - Changelog: 11 test cases -> 14
a3e0eac to
56516f7
Compare
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.
Implements bpf_tail_call() chaining for DWARF stack unwinding, increasing max frame depth from 21 to 165 frames