Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: perf_event_open error : unknown architecture on riscv64 #55

Closed
giordano opened this issue Jan 12, 2025 · 3 comments · Fixed by #56
Closed

ERROR: perf_event_open error : unknown architecture on riscv64 #55

giordano opened this issue Jan 12, 2025 · 3 comments · Fixed by #56

Comments

@giordano
Copy link
Contributor

I guess that's because of

const SYS_perf_event_open = if Sys.ARCH === :x86_64
Clong(298)
elseif Sys.ARCH === :i686
Clong(336)
elseif Sys.ARCH === :aarch64
Clong(241)
elseif Sys.ARCH === :arm
Clong(364)
elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
Clong(319)
else
Clong(-1) # sentinel for unknown syscall ID
end

Where are those magic numbers coming from?

@Zentrik
Copy link
Collaborator

Zentrik commented Jan 12, 2025

https://jborza.com/post/2021-05-11-riscv-linux-syscalls/ says SYS_perf_event_open is 241 (search perf_event_open) and for SYS_prctl its 167.

@giordano
Copy link
Contributor Author

Thanks, I got to that table a few minutes after opening the ticket! However with

diff --git a/src/LinuxPerf.jl b/src/LinuxPerf.jl
index 7326cb3..fd6c17c 100644
--- a/src/LinuxPerf.jl
+++ b/src/LinuxPerf.jl
@@ -167,6 +167,9 @@ elseif Sys.ARCH === :arm
     Clong(364)
 elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
     Clong(319)
+elseif Sys.ARCH === :riscv64 || Sys.ARCH === :rv64
+    # See syscalls table at https://jborza.com/post/2021-05-11-riscv-linux-syscalls/
+    Clong(241)
 else
     Clong(-1) # sentinel for unknown syscall ID
 end
@@ -350,6 +353,9 @@ elseif Sys.ARCH === :arm
     Clong(172)
 elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
     Clong(171)
+elseif Sys.ARCH === :riscv64 || Sys.ARCH === :rv64
+    # See syscalls table at https://jborza.com/post/2021-05-11-riscv-linux-syscalls/
+    Clong(167)
 else
     Clong(-1) # sentinel for unknown syscall ID
 end

I get

julia> @pstats 1 + 1
ERROR: perf_event_open error : Function not implemented
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:44
 [2] LinuxPerf.EventGroup(types::Vector{LinuxPerf.EventTypeExt}; warn_unsupported::Bool, userspace_only::Bool, pinned::Bool, exclusive::Bool, pid::Int32)
   @ LinuxPerf ~/.julia/dev/LinuxPerf/src/LinuxPerf.jl:317

This may be due to the kernel I'm using on this machine? It's

$ uname -a
Linux rvc23 5.15.0-starfive #1 SMP Mon Dec 19 07:56:37 EST 2022 riscv64 GNU/Linux

It's a bit old, I have access to another board with a much newer kernel v6.6.36, but I can't use LinuxPerf there because of JuliaLang/julia#57019 (Crayons is an indirect dependency of this package).

@giordano
Copy link
Contributor Author

Yeah, it's probably a kernel issue, on a different machine it works:

julia> @pstats 1 + 1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┌ cpu-cycles               3.23e+05  100.0%  #  1.7 cycles per ns
│ stalled-cycles-frontend  0.00e+00  100.0%  #  0.0% of cycles
└ stalled-cycles-backend   0.00e+00  100.0%  #  0.0% of cycles
┌ instructions             4.54e+04  100.0%  #  0.1 insns per cycle
│ branch-instructions      0.00e+00  100.0%  #  0.0% of insns
└ branch-misses            0.00e+00  100.0%  #  NaN% of branch insns
┌ task-clock               9.39e+04  100.0%  # 93.9 μs
│ context-switches         0.00e+00  100.0%
│ cpu-migrations           0.00e+00  100.0%
└ page-faults              0.00e+00  100.0%
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

shell> uname -a
Linux rvc24 6.1.22 #2 SMP Thu May  4 19:24:40 CST 2023 riscv64 GNU/Linux

🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants