GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Workaround for PERF_EVENT_IOC_REFRESH bug by apangin · Pull Request #1599 · async-profiler/async-profiler

Conversation

@apangin

@apangin apangin commented Nov 18, 2025

Copy link
Copy Markdown
Collaborator

Description

Implement workaround for the Linux kernel bug that causes the entire system to hang when running CPU profiler with perf_events engine.

Related issues

#1578

Motivation and context

PERF_EVENT_IOC_REFRESH control allows to disable perf_event automatically on counter overflow. Async-profiler uses this control to temporarily disable perf_event while it is processed inside the signal handler. Without this, event could be recursively triggered again and again during processing. Event is then re-enabled just before return from the signal handler.

In Linux 6.16.x and 6.17.x, there is a kernel bug that causes a deadlock when perf_event is automatically disabled inside hrtimer interrupt handler. To workaround this bug, we do not use PERF_EVENT_IOC_REFRESH feature, but instead disable and re-enable the event manually inside a signal handler. To avoid an extra syscall, the workaround is applied only when running CPU profiling on the affected kernel versions.

How has this been tested?

Ran cpu-clock and cycles profiling on Linux versions 6.14, 6.16 and 6.17.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SerCeMan reacted with rocket emoji
All reactions
  • 🚀 1 reaction
apangin added 5 commits November 8, 2025 17:56
@apangin
#1578: Workaround for the Linux PERF_EVENT_IOC_REFRESH bug
b9574ac
@apangin
Check kernel version
8101fcd
@apangin
Merge remote-tracking branch 'origin/master' into cpuclock-bug
0ef8c67
@apangin
Merge remote-tracking branch 'origin/master' into cpuclock-bug
829ecfd
@apangin
Missing include
2c22234
@franz1981

franz1981 commented Nov 18, 2025

Copy link
Copy Markdown

Many thanks again @apangin ❤️

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apangin apangin changed the title Cpuclock bug Workaround for PERF_EVENT_IOC_REFRESH bug Nov 18, 2025
@apangin
apangin merged commit 763616a into master Nov 18, 2025
apangin added a commit that referenced this pull request Nov 18, 2025
@apangin
Workaround for PERF_EVENT_IOC_REFRESH bug (#1599)
a1b2261
(cherry picked from commit 763616a)
apangin added a commit that referenced this pull request Nov 18, 2025
@apangin
Workaround for PERF_EVENT_IOC_REFRESH bug (#1599)
08866f6
(cherry picked from commit 763616a)
apangin added a commit that referenced this pull request Nov 18, 2025
@apangin
Workaround for PERF_EVENT_IOC_REFRESH bug (#1599)
9784592
Signed-off-by: Andrei Pangin <[email protected]>
apangin added a commit that referenced this pull request Nov 18, 2025
@apangin
Follow up: Workaround for the PERF_EVENT_IOC_REFRESH bug (#1599)
b855e0c
Signed-off-by: Andrei Pangin <[email protected]>
apangin added a commit that referenced this pull request Nov 18, 2025
@apangin
Follow up: Workaround for the PERF_EVENT_IOC_REFRESH bug (#1599)
e5582ad
Signed-off-by: Andrei Pangin <[email protected]>
(cherry picked from commit b855e0c)
@apangin apangin mentioned this pull request Nov 22, 2025
[Linux] Entire system freezes whilst attempting world generation with Forge 47.4.0 lucko/spark#530
Closed
jerrinot added a commit to questdb/questdb that referenced this pull request Nov 28, 2025
@jerrinot
chore(utils): update async-profiler to 4.2.1
98a5bd2
this version has a workaround for a bug in kernel 6.17 - async-profiler/async-profiler#1599
@jerrinot jerrinot mentioned this pull request Nov 28, 2025
chore(utils): update async-profiler to 4.2.1 questdb/questdb#6473
Merged
jbachorik pushed a commit to DataDog/async-profiler that referenced this pull request Jan 2, 2026
@apangin @jbachorik
Workaround for PERF_EVENT_IOC_REFRESH bug (async-profiler#1599)
241b04b
(cherry picked from commit 763616a)
jbachorik pushed a commit to DataDog/async-profiler that referenced this pull request Jan 2, 2026
@apangin @jbachorik
Follow up: Workaround for the PERF_EVENT_IOC_REFRESH bug (async-profi…
6d24ce2
…ler#1599)

Signed-off-by: Andrei Pangin <[email protected]>
(cherry picked from commit b855e0c)
jbachorik pushed a commit to DataDog/async-profiler that referenced this pull request Jan 6, 2026
@apangin @jbachorik
Workaround for PERF_EVENT_IOC_REFRESH bug (async-profiler#1599)
d4ad86a
(cherry picked from commit 763616a)
jbachorik pushed a commit to DataDog/async-profiler that referenced this pull request Jan 6, 2026
@apangin @jbachorik
Follow up: Workaround for the PERF_EVENT_IOC_REFRESH bug (async-profi…
f889a62
…ler#1599)

Signed-off-by: Andrei Pangin <[email protected]>
(cherry picked from commit b855e0c)
@apangin
apangin deleted the cpuclock-bug branch January 13, 2026 01:18
This was referenced Sep 30, 2026
Tracepoint, kprobe and uprobe events record at most one sample per thread on Linux 6.17+ #1813
Open
Do not use PERF_EVENT_IOC_REFRESH for tracepoint, kprobe and uprobe events #1814
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@apangin @franz1981
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.