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
Add support for perf event group management in BPF
- Introduced `group_fd` field in the perf options structure to allow
attaching BPF programs to a group of perf events.
- Updated the `ks_open_perf_event` function to accept `group_fd` and
handle group event management.
- Implemented helper functions for managing active members of perf
event groups, ensuring that group leaders cannot be detached while
active members exist.
- Enhanced the generated code to include necessary checks and
structures for handling multiplexed perf events.
- Added tests to validate the new group management features and
ensure correct code generation for group-related operations.
**Description:** Read the current hardware/software counter value from a perf attachment.
176
+
**Description:** Read the current hardware/software counter value from a perf attachment. If the kernel multiplexed the event, the value is scaled with `time_enabled / time_running`.
167
177
168
178
**Parameters:**
169
179
-`handle`: Perf attachment returned from `attach(handle, perf_options, flags)`
170
180
171
181
**Return Value:**
172
-
- Returns the raw 64-bit counter value on success
182
+
- Returns the raw 64-bit counter value when no multiplexing occurred
183
+
- Returns a scaled value when `time_running < time_enabled`
173
184
- Returns `-1` on invalid/stale attachment or read failure
174
185
- Reads use the attachment's `perf_fd` directly; the internal token detects copied handles used after detach.
186
+
- Group snapshot reads are not supported yet; read grouped attachments individually.
Adding a member restarts the whole group from zero. Detach members before detaching their leader. `read(att)` still reads one attachment at a time; it returns a multiplex-scaled count when the kernel reports `time_running < time_enabled`. Group snapshot reads are not part of this first-stage API.
@@ -559,7 +582,7 @@ For event families with a richer config space, such as `perf_type_hw_cache`, pro
559
582
- Returns a first-class `PerfAttachment` value for perf attaches so one program can hold multiple live counters
560
583
-`PerfAttachment` carries `perf_fd` plus an internal generation token; `read(attachment)` avoids global attachment-list scans and rejects copied handles after detach
0 commit comments