You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Updated the `perf_options` structure to require `perf_type` and `perf_config` instead of the previous `counter` field.
- Modified examples and tests to reflect the new `perf_type` and `perf_config` usage.
- Removed the `perf_print` function and its references, as it is no longer necessary with the new `perf_read` implementation.
- Enhanced the `ks_open_perf_event` and `ks_perf_read` functions to directly utilize the new `perf_type` and `perf_config` fields.
- Updated documentation in `SPEC.md` to clarify the changes in the `perf_options` structure and the new enums for `perf_type` and `perf_config`.
- Adjusted tests to ensure proper generation of helper functions based on the new `perf_event` API.
Co-authored-by: Copilot <copilot@github.com>
Copy file name to clipboardExpand all lines: README.md
+27-15Lines changed: 27 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -270,7 +270,7 @@ fn main() -> i32 {
270
270
271
271
### Hardware Performance Counter Programs
272
272
273
-
Use `@perf_event` to attach eBPF programs to hardware or software performance counters. Only `counter` is required in the `perf_options` struct; all other fields have sensible defaults. Call `attach(prog, perf_options { ... }, 0)` and read back the counter with `perf_read(prog)`:
273
+
Use `@perf_event` to attach eBPF programs to hardware or software performance counters. `perf_options` keeps the kernel's tagged `perf_type + perf_config` model, so adding new perf event families does not require flattening everything into one enum. Only `perf_type` and `perf_config` are required; all other fields have sensible defaults. If you need the current count in userspace, call `perf_read(prog)` after `attach(...)`:
274
274
275
275
```kernelscript
276
276
// eBPF program fires on every hardware branch-miss sample
@@ -284,29 +284,41 @@ fn main() -> i32 {
284
284
285
285
// Minimal form — defaults: pid=-1 (all procs), cpu=0,
For event families with a richer config space, such as `perf_type_hw_cache`, provide the encoded kernel `perf_config` value directly instead of relying on a flattened enum.
518
533
519
534
**Generated C helpers (emitted when `attach(prog, perf_options{...}, flags)` is used):**
520
535
@@ -524,7 +539,6 @@ fn main() -> i32 {
524
539
|`ks_attach_perf_event`|`int (int prog_fd, ks_perf_options, int flags)`| Full open-reset-attach-enable lifecycle |
525
540
|`ks_read_perf_count`|`int64_t (int perf_fd)`| Reads current 64-bit counter via `read()`|
526
541
|`ks_perf_read`|`int64_t (int prog_fd)`| High-level read via program handle |
527
-
|`ks_perf_print`|`void (int prog_fd, const char*)`| Prints `[perf] <name>: <count>` to stdout |
0 commit comments