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
The Hardware Performance Counter Programs section had grown into full
reference material (constant table, grouping example, PMU-scheduling and
read-snapshot prose) that duplicates SPEC.md. Reduce it to a one-line
intro and the basic example, matching the other Language Overview
sections, and point to SPEC.md for the details.
Signed-off-by: Cong Wang <cwang@multikernel.io>
Copy file name to clipboardExpand all lines: README.md
+1-31Lines changed: 1 addition & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -294,7 +294,7 @@ fn main() -> i32 {
294
294
295
295
### Hardware Performance Counter Programs
296
296
297
-
Use `@perf_event` to attach eBPF programs to hardware or software performance counters. Each event is named by a single `event` value that carries both the kernel `perf_event_attr.type` tag and its config, so the type can never be mismatched with the config. Only `event`is required; all other fields have sensible defaults. Perf attaches return a first-class attachment value, so if you need the current count in userspace, call `read(att).scaled`:
297
+
Use `@perf_event` to attach eBPF programs to hardware or software performance counters. Only `event` is required; perf attaches return a first-class attachment whose count you read with `read(att).scaled`. Event grouping, the full `event`constant list, and the `perf_options` / `perf_read` field reference are in [`SPEC.md`](SPEC.md).
298
298
299
299
```kernelscript
300
300
// eBPF program fires on every hardware branch-miss sample
@@ -318,36 +318,6 @@ fn main() -> i32 {
318
318
}
319
319
```
320
320
321
-
Perf events can share a kernel scheduling group by passing the leader attachment with `group`:
322
-
323
-
```kernelscript
324
-
var cache = attach(prog, perf_options { event: cache_misses }, 0)
325
-
var branch = attach(prog, perf_options {
326
-
event: branch_misses,
327
-
group: cache,
328
-
}, 0)
329
-
```
330
-
331
-
Adding a member restarts the whole group from zero. Detaching a leader cascades to any live members. A group competes for PMU counters as one atomic unit: different groups can be multiplexed over time, but members inside one group are not independently multiplexed. A group that needs more hardware PMU counters than the running host provides is rejected by the kernel at `perf_event_open(2)`, and `attach()` surfaces the error at runtime — on the actual deployment host, where the real counter count is known. `read(att)` exposes up to 16 group entries (`perf_read`).
332
-
333
-
`read(att)` returns a `perf_read` snapshot with raw, multiplex-scaled, timing, and group fields. Use `read(att).scaled` for that attachment's counter value, `read(att).raw` for its unscaled value, and `read(att).values` / `read(att).ids` for a same-time group snapshot.
334
-
335
-
**Available `event` constants:**
336
-
337
-
Each constant packs its `perf_event_attr.type` tag in the high 32 bits and its config in the low 32 bits, so naming the event fixes both.
0 commit comments