per4m
per4m copied to clipboard
sys_perf_event_open() syscall returned with 4 (Interrupted system call) for event (python:take_gil__return)
I followed the article closely twice on two Ubuntu 22.04 LTS machines (one virtual, the other virtual) but the result were the same. The only places where I deviated were as follows:
- Because of missing symbols in
python3
, e.g.
sudo perf probe -f -x `which python3` python:drop_gil=drop_gil%return
Failed to find symbol drop_gil in /usr/bin/python3.10
Error: Failed to add events.
I installed python3-dbg
with the result
sudo perf probe -f -x `which python3-dbg` python:drop_gil=drop_gil%return
Added new event:
python:drop_gil__return (on drop_gil%return in /usr/bin/python3.10d)
perf is not linked with libtraceevent, to use the new probe you can use tracefs:
cd /sys/kernel/tracing/
echo 1 > events/python/drop_gil__return/enable
echo 1 > tracing_on
cat trace_pipe
Before removing the probe, echo 0 > events/python/drop_gil__return/enable
- Because of an "unsupported tracepoint" error with perf e.g
sudo perf record -e python:take_gil__return -- python3-dbg -c "import time; time.sleep(1)"
event syntax error: 'python:take_gil__return'
\___ unsupported tracepoint
libtraceevent is necessary for tracepoint support
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
Following this forum post, I downloaded the linux source and built perf which is how I ended up with the error in subject, i.e.
~/Downloads/linux-master/tools/perf/perf record -e python:take_gil__return -- python3-dbg -c "import time; time.sleep(1)"
Error:
The sys_perf_event_open() syscall returned with 4 (Interrupted system call) for event (python:take_gil__return).
/bin/dmesg | grep -i perf may provide additional information.
Diagnostic
sudo /bin/dmesg | grep -i perf
[ 0.320065] Performance Events: PEBS fmt2+, Haswell events, 16-deep LBR, full-width counters, Intel PMU driver.
[ 0.336481] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[ 14.393007] audit: type=1400 audit(1718007188.312:46): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" pid=915 comm="snap-confine" capability=38 capname="perfmon"
[ 201.386307] audit: type=1400 audit(1718007375.304:48): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" pid=1122 comm="snap-confine" capability=38 capname="perfmon"
[ 5305.685013] audit: type=1400 audit(1718012479.604:50): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" pid=2973 comm="snap-confine" capability=38 capname="perfmon"
[19500.286784] audit: type=1400 audit(1718026674.208:52): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" pid=4242 comm="snap-confine" capability=38 capname="perfmon"
[20648.350935] audit: type=1400 audit(1718027822.272:54): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" pid=5424 comm="snap-confine" capability=38 capname="perfmon"
[176131.022755] audit: type=1400 audit(1718183304.926:58): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" pid=10214 comm="snap-confine" capability=38 capname="perfmon"