-
Notifications
You must be signed in to change notification settings - Fork 697
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 RecursionMisses to access ProgramInfo recursion misses counter #1465
Conversation
info.go
Outdated
// it keeps the return values pattern as the other stats accessors and returns | ||
// bool (allways true) together with the counter value. | ||
func (pi *ProgramInfo) RecursionMisses() (uint64, bool) { | ||
return pi.stats.recursionMisses, true |
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.
Which kernel did this appear on though? The boolean is meant to indicate whether the kernel exposes this flag in general, not whether stats were enabled (IIRC).
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.
it got in v5.11 9ed9e9ba2337 bpf: Count the number of times recursion was prevented
I'm actually not sure how is the availability detected, both Runtime and RunCount
return values if pi.stats != nil
which seems to be the case always AFAICS
I can keep the same checks as for the Runtime and RunCount
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'm actually not sure how is the availability detected, both Runtime and RunCount
return values if pi.stats != nil which seems to be the case always AFAICS
Can't remember who contributed it, but iirc they were planning to add a probe, and the bool was added to not have to break API later. Looks like the probe was never implemented, and looking back it hardly seems worth it to load a prog, call prog_run and verify if the run counter increases just so we can return that bool correctly.
In the case of RecursionMisses, that one feels unrealistic to try to reproduce reliably at all. I'd just drop the bool and add a comment about it being 5.11+.
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.
That breaks when using newProgramInfoFromProc. So unless we deprecate that we should just stick with the established pattern of returning a bool.
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.
ok, keeping the bool then, 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.
That breaks when using newProgramInfoFromProc. So unless we deprecate that we should just stick with the established pattern of returning a bool.
@lmb Could you elaborate on what breaks exactly?
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.
pi.stats is nil and therefore the line panics.
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! Left some feedback. Let's just drop the bool, fix up the comment and call it a day.
info.go
Outdated
// it keeps the return values pattern as the other stats accessors and returns | ||
// bool (allways true) together with the counter value. | ||
func (pi *ProgramInfo) RecursionMisses() (uint64, bool) { | ||
return pi.stats.recursionMisses, true |
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'm actually not sure how is the availability detected, both Runtime and RunCount
return values if pi.stats != nil which seems to be the case always AFAICS
Can't remember who contributed it, but iirc they were planning to add a probe, and the bool was added to not have to break API later. Looks like the probe was never implemented, and looking back it hardly seems worth it to load a prog, call prog_run and verify if the run counter increases just so we can return that bool correctly.
In the case of RecursionMisses, that one feels unrealistic to try to reproduce reliably at all. I'd just drop the bool and add a comment about it being 5.11+.
c320be3
to
1210b92
Compare
Pushed a fixup, PTAL. Looking at the upstream commit it's not clear to me where the idea that this is related to program statistics comes from? Seems easier to me to just treat these things as completely independent. Just returning |
hm, it's per program stats collected under same struct in kernel together with run count and run time
it's incremented through it makes sense to me to place it under |
74e9661
to
08e672b
Compare
I can see your point, moving it out of the struct doesn't really add value. I've changed it back, fixed the panic and added a comment. |
info.go
Outdated
@@ -83,6 +83,9 @@ type programStats struct { | |||
runtime time.Duration | |||
// Total number of times the program was called. | |||
runCount uint64 | |||
// Total number of timer the programm was NOT called. |
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.
// Total number of timer the programm was NOT called. | |
// Total number of times the program was NOT called. |
08e672b
to
ddc6323
Compare
Adding RecursionMisses to access ProgramInfo recursion misses counter. This value is always measured on supported kernels, regardless of statistics being enabled or not. Signed-off-by: Lorenz Bauer <lmb@isovalent.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
ddc6323
to
b4bd7f6
Compare
CI failures are due to unrelated upstream changes. |
Adding RecursionMisses to access ProgramInfo recursion misses counter.
It does not depend on whether collection of statistics is enabled, the value is always counted.