Skip to content

Commit 25ec2d7

Browse files
committed
add support for more attributes
1 parent 57b84ac commit 25ec2d7

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
@@ -194,7 +194,9 @@ mutable struct EventGroup
194194

195195
function EventGroup(types::Vector{EventType};
196196
warn_unsupported = true,
197-
userspace_only = true
197+
userspace_only = true,
198+
pinned = false,
199+
exclusive = false,
198200
)
199201
my_types = EventType[]
200202
group = new(-1, Cint[], EventType[])
@@ -205,12 +207,24 @@ mutable struct EventGroup
205207
attr.size = sizeof(perf_event_attr)
206208
attr.config = evt_type.event
207209
attr.sample_period_or_freq = 0
208-
if userspace_only
209-
attr.flags = (1 << 5) # exclude kernel
210-
end
210+
attr.flags = 0
211+
# first attribute becomes group leader
211212
if group.leader_fd == -1
212213
attr.flags |= (1 << 0) # start disabled
213214
end
215+
if pinned
216+
attr.flags |= (1 << 2)
217+
end
218+
if exclusive
219+
attr.flags |= (1 << 3)
220+
end
221+
# (1 << 4) exclude_user
222+
if userspace_only
223+
attr.flags |= (1 << 5) # exclude kernel
224+
end
225+
# (1 << 6) exclude hypervisor
226+
# (1 << 7) exclude idle
227+
214228
attr.read_format =
215229
PERF_FORMAT_GROUP |
216230
PERF_FORMAT_TOTAL_TIME_ENABLED |

0 commit comments

Comments
 (0)