-
Notifications
You must be signed in to change notification settings - Fork 331
aya,aya-obj: expose run_time_ns & run_cnt fields, and add bpf_enable_stats util function #959
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
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
6f05b4a
to
24c4e05
Compare
Hey @alessandrod, this pull request changes the Aya Public API and requires your review. |
24c4e05
to
2fbab8c
Compare
2fd8493
to
b8c2d3d
Compare
b8c2d3d
to
fcb349d
Compare
ab96ee7
to
2105541
Compare
6eedb59
to
389a267
Compare
aya-obj/src/stats.rs
Outdated
RunTime, | ||
} | ||
|
||
impl From<BpfStatsType> for bpf_stats_type { |
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.
Given there's only one possible value here (BPF_STATS_RUN_TIME) do we need this?
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.
I included a idiomatic Rust wrapper for bpf_enable_stats
when I initially had enable_stats
param require the type.
I understand that aya-obj
is meant for object parsing. Does it also function as a "rusty" API for the FFI? If not, then I suppose enable_stats
can directly use bpf_stats_type::BPF_STATS_RUN_TIME
.
Added `bpf_stats_type` enum to codegen bindings. Refs: aya-rs#959
@tyrone-wu, this pull request is now in conflict and requires a rebase. |
389a267
to
a73ed77
Compare
e550973
to
f08141c
Compare
038c465
to
55d57ad
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.
Sorry for the uber late review!
55d57ad
to
8b7ee9a
Compare
8b7ee9a
to
a759a68
Compare
Add bpf syscall function for BPF_ENABLE_STATS to enable stats tracking for benchmarking purposes. Additionally, move `#[cfg(test)]` annotation around the `Drop` trait instead. Having separate functions causes some complications when needing ownership/moving of the inner value `OwnedFd` when `Drop` is manually implemented.
Added functions to expose `run_time_ns` & `run_cnt` statistics from ProgramInfo/bpf_prog_info.
a759a68
to
a25f501
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, and thanks for the great docs :)
Checklist:
run_time_ns
&run_cnt
fields inProgramInfo
.BPF_ENABLE_STATS
syscall command that returns a file descriptor of the handler.- [ ] Maybe? Add another util function for enabling runtime stats through sysctl procfs sinceBPF_ENABLE_STATS
is a kernel 5.8+ feature.These can be used for monitoring/benchmarking runtime statistics for programs. The
BPF_ENABLE_STATS
bpf command can be used in conjunction withBPF_OBJ_GET_INFO_BY_FD
to monitor therun_time_ns
&run_cnt
fields.More on it can be found in https://lore.kernel.org/bpf/20200430071506.1408910-2-songliubraving@fb.com/.