GeezerVison is showing github.com — User-space part of a trace is not reported if Kernel symbols are unavailable · Issue #1044 · async-profiler/async-profiler
User-space part of a trace is not reported if Kernel symbols are unavailable #1044DescriptionDescribe the bug
Say there is a trace that leads into the kernel:
...
[13] do_syscall_64_[k]
[14] entry_SYSCALL_64_after_hwframe_[k]
[15] send
[16] io.netty.channel.unix.Socket.sendAddress
and consumes much CPU cycles.
If Kernel symbols are not available:
[WARN] Kernel symbols are unavailable due to restrictions. Try
sysctl kernel.perf_event_paranoid=1
sysctl kernel.kptr_restrict=0
such traces are not reported at all.
This creates an illusion that CPU is spend elsewhere.
Expected vs. actual behavior
Actual behaviour: such traces are ignored.
Expected behaviour: at least user-space part of such traces should be reported, e.g.:
[0] send
[1] io.netty.channel.unix.Socket.sendAddress
Or even:
[0] Kernel symbols are unavailable
[1] send
[2] io.netty.channel.unix.Socket.sendAddress
Reproduction Steps
No response
Additional Information/Context
No response
Async-profiler version
3.0
Environment details
OS: CentOS 9, Linux 5.15.160
JDK: 11
CPU: x86_64 Activityadded a commit that references this issue on Nov 4, 2024#1044: Fall back to ctimer for CPU profiling when perf_events are una… apangin commented on Nov 4, 2024 Previously, when /proc/sys/kernel/perf_event_paranoid settings allowed only user-space measurements (default since Linux 4.6), async-profiler automatically enabled alluser option, corresponding to perf_event_attr.exclude_kernel bit. It was a big oversight, because exclude_kernel option silently discarded all execution samples occurred in the kernel-space, leading to the issue you've described.
If kernel-space measurements are not allowed by system configuration, it's better to switch to ctimer mode based on timer_create API. I've modified the logic of CPU profiling as follows:
- perf_events availability is now automatically checked by trying to create a dummy perf_event.
- If kernel-space profiling using perf_events is not available (including when restricted by
perf_event_paranoid setting or by seccomp), async-profiler transparently falls back to ctimer mode.
- If perf_events are available, but kernel symbols are hidden (e.g., by
kptr_resitrct setting), async-profiler continues to use perf_events, emits a warning and does not show kernel stack traces.
- To force using perf_events for user-space only profiling, specify
-e cpu-clock --all-user instead of -e cpu.
allkernel option has been removed.
- JFR recording now contains
engine setting with the current profiling engine: perf_events, ctimer, wall, etc.
apangin commented on Nov 4, 2024 Reacted by Anton Ivanov Reacted by Anton Ivanov Reacted by Anton Ivanov AntonIvanov87 commented on Nov 5, 2024 Thank you so much, @apangin, I've just verified it and it works great. added a commit that references this issue on Nov 7, 2024#1044: Automatically switch on --all-user for non-CPU events if kerne… apangin commented on Jul 8, 2025 @lisong2010 The issue your are commenting has been already closed, and your questions seems to be different. Could you please open a separate issue or start a new discussion, so it can be tracked separately? Thanks.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|