Skip to content

Commit 08a30c4

Browse files
committed
add support for more attributes
1 parent 0e61a96 commit 08a30c4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/LinuxPerf.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ mutable struct EventGroup
192192

193193
function EventGroup(types::Vector{EventType};
194194
warn_unsupported = true,
195-
userspace_only = true
195+
userspace_only = true,
196+
pinned = false,
197+
exclusive = false,
196198
)
197199
my_types = EventType[]
198200
group = new(-1, Cint[], EventType[])
@@ -203,12 +205,24 @@ mutable struct EventGroup
203205
attr.size = sizeof(perf_event_attr)
204206
attr.config = evt_type.event
205207
attr.sample_period_or_freq = 0
206-
if userspace_only
207-
attr.flags = (1 << 5) # exclude kernel
208-
end
208+
attr.flags = 0
209+
# first attribute becomes group leader
209210
if group.leader_fd == -1
210211
attr.flags |= (1 << 0) # start disabled
211212
end
213+
if pinned
214+
attr.flags |= (1 << 2)
215+
end
216+
if exclusive
217+
attr.flags |= (1 << 3)
218+
end
219+
# (1 << 4) exclude_user
220+
if userspace_only
221+
attr.flags |= (1 << 5) # exclude kernel
222+
end
223+
# (1 << 6) exclude hypervisor
224+
# (1 << 7) exclude idle
225+
212226
attr.read_format =
213227
PERF_FORMAT_GROUP |
214228
PERF_FORMAT_TOTAL_TIME_ENABLED |

0 commit comments

Comments
 (0)