8000 aya,aya-obj: expose run_time_ns & run_cnt fields, and add bpf_enable_stats util function by tyrone-wu · Pull Request #959 · aya-rs/aya · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 2 commits into from
Sep 1, 2024

Conversation

tyrone-wu
Copy link
Contributor
@tyrone-wu tyrone-wu commented May 29, 2024

Checklist:

  • Expose the run_time_ns & run_cnt fields in ProgramInfo.
  • Add util function for enabling eBPF runtime stats through the 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 since BPF_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 with BPF_OBJ_GET_INFO_BY_FD to monitor the run_time_ns & run_cnt fields.

More on it can be found in https://lore.kernel.org/bpf/20200430071506.1408910-2-songliubraving@fb.com/.

Copy link
netlify bot commented May 29, 2024

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a25f501
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/66c38e1c7b03ad0008a208e9
😎 Deploy Preview https://deploy-preview-959--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mergify mergify bot added aya This is about aya (userspace) test A PR that improves test cases or CI labels May 29, 2024
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch from 6f05b4a to 24c4e05 Compare May 29, 2024 14:35
Copy link
mergify bot commented May 29, 2024

Hey @alessandrod, this pull request changes the Aya Public API and requires your review.

@mergify mergify bot requested a review from alessandrod May 29, 2024 14:36
@mergify mergify bot added the api/needs-review Makes an API change that needs review label May 29, 2024
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch from 24c4e05 to 2fbab8c Compare June 2, 2024 00:37
@tyrone-wu tyrone-wu changed the title aya: expose run_time_ns & run_cnt fields, and add bpf_enable_stats util function aya,aya-obj: expose run_time_ns & run_cnt fields, and add bpf_enable_stats util function Jun 2, 2024
@mergify mergify bot added the aya-obj Relating to the aya-obj crate label Jun 2, 2024
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch 6 times, most recently from 2fd8493 to b8c2d3d Compare June 3, 2024 16:37
@tyrone-wu tyrone-wu marked this pull request as ready for review June 3, 2024 17:20
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch from b8c2d3d to fcb349d Compare June 3, 2024 21:39
@tyrone-wu tyrone-wu marked this pull request as draft June 6, 2024 22:43
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch 2 times, most recently from ab96ee7 to 2105541 Compare June 6, 2024 22:53
@tyrone-wu tyrone-wu marked this pull request as ready for review June 8, 2024 12:33
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch 2 times, most recently from 6eedb59 to 389a267 Compare June 29, 2024 03:46
RunTime,
}

impl From<BpfStatsType> for bpf_stats_type {
Copy link
Member

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?

Copy link
Contributor Author

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.

tyrone-wu added a commit to tyrone-wu/aya that referenced this pull request Jul 12, 2024
Added `bpf_stats_type` enum to codegen bindings.

Refs: aya-rs#959
Copy link
mergify bot commented Jul 13, 2024

@tyrone-wu, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Jul 13, 2024
@tyrone-wu tyrone-wu marked this pull request as draft July 15, 2024 17:30
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch from 389a267 to a73ed77 Compare July 19, 2024 17:10
@mergify mergify bot removed the needs-rebase label Jul 19, 2024
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch 4 times, most recently from e550973 to f08141c Compare July 22, 2024 03:38
@tyrone-wu tyrone-wu marked this pull request as ready for review July 22, 2024 20:52
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch 2 times, most recently from 038c465 to 55d57ad Compare July 31, 2024 18:52
Copy link
Collaborator
@alessandrod alessandrod left a 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!

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.
@tyrone-wu tyrone-wu force-pushed the aya/program_info_stats branch from a759a68 to a25f501 Compare August 19, 2024 18:25
@tyrone-wu tyrone-wu requested a review from alessandrod August 24, 2024 15:28
Copy link
Collaborator
@alessandrod alessandrod left a 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 :)

@alessandrod alessandrod merged commit ab000ad into aya-rs:main Sep 1, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/needs-review Makes an API change that needs review aya This is about aya (userspace) aya-obj Relating to the aya-obj crate test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0