-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add jiffies builtin with bpf_jiffies64 #2769
Conversation
ec0b684
to
e8bae34
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.
Thanks a lot for implementing this!
Looks good, a couple of things are missing, though:
- detection if the helper is present in the kernel, it should go to
BPFFeature
and then be called from semantic analyser with a proper error message if the helper is missing, - semantic analyser tests,
- runtime tests, although I'm not sure if we can come up with something useful here.
See e.g. my recent PR #2692 for inspiration how to implement the above points.
e8bae34
to
e94a931
Compare
I'm quite unfamiliar here, thanks for the advising! Pushed a new commit, fixed those things. As for the runtime tests, I want to compare the jiffies between bpftrace and |
Please fix the problems reported by clang-format. |
e94a931
to
369e3c5
Compare
Thanks! |
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, thanks!
Thanks for the cleanup! |
Could you squash the first two commits together? Thanks! |
166d6e0
to
642d14b
Compare
Done! |
Add jiffies builtin, one of the use case is to calculate the
sched_clock
indirectly within some old kernels.Result:
bpftrace --unsafe -e 'BEGIN { system("grep jiffies: /proc/timer_list | head -1"); print(jiffies); exit() }' Attaching 1 probe... jiffies: 4325204698 4325204697
Checklist
man/adoc/bpftrace.adoc
and if needed indocs/reference_guide.md
CHANGELOG.md