Skip to content

Commit 72ed207

Browse files
committed
Trim README perf section to intro + example
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>
1 parent 68bbe2c commit 72ed207

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

README.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn main() -> i32 {
294294

295295
### Hardware Performance Counter Programs
296296

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).
298298

299299
```kernelscript
300300
// eBPF program fires on every hardware branch-miss sample
@@ -318,36 +318,6 @@ fn main() -> i32 {
318318
}
319319
```
320320

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.
338-
339-
| Constant | Kernel type | Linux config |
340-
|---|---|---|
341-
| `cpu_cycles` | `PERF_TYPE_HARDWARE` | `PERF_COUNT_HW_CPU_CYCLES` |
342-
| `instructions` | `PERF_TYPE_HARDWARE` | `PERF_COUNT_HW_INSTRUCTIONS` |
343-
| `cache_references` | `PERF_TYPE_HARDWARE` | `PERF_COUNT_HW_CACHE_REFERENCES` |
344-
| `cache_misses` | `PERF_TYPE_HARDWARE` | `PERF_COUNT_HW_CACHE_MISSES` |
345-
| `branch_instructions` | `PERF_TYPE_HARDWARE` | `PERF_COUNT_HW_BRANCH_INSTRUCTIONS` |
346-
| `branch_misses` | `PERF_TYPE_HARDWARE` | `PERF_COUNT_HW_BRANCH_MISSES` |
347-
| `page_faults` | `PERF_TYPE_SOFTWARE` | `PERF_COUNT_SW_PAGE_FAULTS` |
348-
| `context_switches` | `PERF_TYPE_SOFTWARE` | `PERF_COUNT_SW_CONTEXT_SWITCHES` |
349-
| `cpu_migrations` | `PERF_TYPE_SOFTWARE` | `PERF_COUNT_SW_CPU_MIGRATIONS` |
350-
351321
📖 **For detailed language specification, syntax reference, and advanced features, please read [`SPEC.md`](SPEC.md).**
352322

353323
🔧 **For complete builtin functions reference, see [`BUILTINS.md`](BUILTINS.md).**

0 commit comments

Comments
 (0)