Skip to content

Commit

Permalink
bcc/python: fix ctype warning when creating perf events
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzocarrozzo authored and yonghong-song committed Jan 4, 2024
1 parent 9a458c0 commit 7cdddcb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/python/bcc/perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def __setattr__(self, key, value):
ioctl = libc.ioctl # not declaring vararg types

@staticmethod
def _open_for_cpu(cpu, attr):
def _open_for_cpu(cpu, attr, pid=-1):
pfd = Perf.syscall(Perf.NR_PERF_EVENT_OPEN, ct.byref(attr),
attr.pid, cpu, -1,
pid, cpu, -1,
Perf.PERF_FLAG_FD_CLOEXEC)
if pfd < 0:
errno_ = ct.get_errno()
Expand All @@ -177,7 +177,6 @@ def perf_event_open(tpoint_id, pid=-1, ptype=PERF_TYPE_TRACEPOINT,
freq=0):
attr = Perf.perf_event_attr()
attr.config = tpoint_id
attr.pid = pid
attr.type = ptype
attr.sample_type = Perf.PERF_SAMPLE_RAW
if freq > 0:
Expand All @@ -189,10 +188,9 @@ def perf_event_open(tpoint_id, pid=-1, ptype=PERF_TYPE_TRACEPOINT,
attr.wakeup_events = 9999999 # don't wake up

for cpu in get_online_cpus():
Perf._open_for_cpu(cpu, attr)
Perf._open_for_cpu(cpu, attr, pid)

@staticmethod
def perf_custom_event_open(attr, pid=-1):
attr.pid = pid
for cpu in get_online_cpus():
Perf._open_for_cpu(cpu, attr)
Perf._open_for_cpu(cpu, attr, pid)

0 comments on commit 7cdddcb

Please sign in to comment.