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
Implicit casts from per-CPU integers into regular integers #3126
Labels
difficulty: medium
enhancement
New feature or request, changes on existing features
language
Changes to the bpftrace language
power-user
priority: high
Comments
ajor
added
enhancement
New feature or request, changes on existing features
priority: high
difficulty: medium
labels
Apr 17, 2024
We can use a Note: Open-coded iterators didn't make it in until kernel 6.4 |
jordalgo
pushed a commit
to jordalgo/bpftrace
that referenced
this issue
May 20, 2024
This utilizes 'map_lookup_percpu_elem' to iterate over the per-cpu maps that 'sum' and 'count' use to aggregate the values for each cpu so these maps can be used in kernel space for conditionals and arithmetic. Issue: bpftrace#3126 Note: We can do the same to support to 'avg', 'max', 'min' but those require the same user-space logic written in llvm ir.
jordalgo
pushed a commit
to jordalgo/bpftrace
that referenced
this issue
May 20, 2024
This utilizes 'map_lookup_percpu_elem' to iterate over the per-cpu maps that 'sum' and 'count' use to aggregate the values for each cpu so these maps can be used in kernel space for conditionals and arithmetic. Issue: bpftrace#3126 Note: We can do the same to support to 'avg', 'max', 'min' but those require the same user-space logic written in llvm ir.
3 tasks
jordalgo
pushed a commit
to jordalgo/bpftrace
that referenced
this issue
May 20, 2024
This utilizes 'map_lookup_percpu_elem' to iterate over the per-cpu maps that 'sum' and 'count' use to aggregate the values for each cpu so these maps can be used in kernel space for conditionals and arithmetic. Issue: bpftrace#3126 Note: We can do the same to support to 'avg', 'max', 'min' but those require the same user-space logic written in llvm ir.
jordalgo
pushed a commit
to jordalgo/bpftrace
that referenced
this issue
May 21, 2024
This utilizes 'map_lookup_percpu_elem' to iterate over the per-cpu maps that 'sum' and 'count' use to aggregate the values for each cpu so these maps can be used in kernel space for conditionals and arithmetic. Additionally, add explicit casting for printing or storing just the value for these types of maps. Issue: bpftrace#3126 Note: We can do the same to support to 'avg', 'max', 'min' but those require the same user-space logic written in llvm ir.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
difficulty: medium
enhancement
New feature or request, changes on existing features
language
Changes to the bpftrace language
power-user
priority: high
Example usage:
Current behaviour:
Per-CPU maps help to improve the performance of writes, but it is difficult to read their values. Currently they can only be aggregated and read in userspace, so people often fall back to using regular, non-per-cpu maps instead.
It'd be useful if we provided a mechanism to read the aggregated values of per-cpu maps from within BPF.
The
bpf_map_lookup_percpu_elem
helper can be used to look up a Per-CPU map's value from a different CPU.A cast from a per-CPU integer to a regular integer could be done with this pseudo-code:
The text was updated successfully, but these errors were encountered: