feat: improve struct_ops codegen lifecycle and test coverage#17
Open
SiyuanSun0736 wants to merge 3 commits intomultikernel:mainfrom
Open
feat: improve struct_ops codegen lifecycle and test coverage#17SiyuanSun0736 wants to merge 3 commits intomultikernel:mainfrom
SiyuanSun0736 wants to merge 3 commits intomultikernel:mainfrom
Conversation
… tests - Added `undo_cwnd` function to `minimal_congestion_control` implementation. - Updated test for struct_ops compilation completeness to verify direct calls. - Introduced new test for ensuring internal calls remain direct instead of tail calls.
There was a problem hiding this comment.
Pull request overview
This PR refines struct_ops code generation to better preserve intended call semantics (direct internal calls), auto-fill missing instance metadata (default .name), and generate a more reliable userspace registration/attach/wait/detach lifecycle, with expanded regression tests across both eBPF and userspace outputs.
Changes:
- Preserve direct calls for internal
struct_opsmethod-to-method invocations and avoid lowering them into implicit tail calls. - Synthesize a stable default
struct_opsinstance name when the kernel struct has anamefield and the impl omits it. - Improve userspace
main()lifecycle generation forstruct_ops(runtime checks, link lifetime, attach/wait/detach/cleanup) and expand tests accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/ir_generator.ml |
Tracks current program type to prevent implicit tail-call lowering for struct_ops, and synthesizes a default instance name when omitted. |
src/userspace_codegen.ml |
Reworks struct_ops registration to use generated attach/detach helpers, adds runtime helpers/cleanup/wait flow, and adds EPERM diagnostics. |
tests/test_struct_ops.ml |
Expands userspace lifecycle assertions, adds synthesized-name coverage, and adds a regression test ensuring internal calls stay direct. |
examples/struct_ops_simple.ks |
Updates the example to include an internal helper-style call path (undo_cwnd -> ssthresh). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s for runtime helpers and cleanup functions
congwang-mk
reviewed
Apr 22, 2026
Contributor
Author
|
Added |
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.
Summary
This PR improves struct_ops code generation and strengthens regression coverage across both eBPF and userspace paths.
Key changes:
Details
In IR generation:
In userspace code generation:
In examples and tests:
Testing