Draft: allow using an external symbol as a semaphore#26
Draft
bonzini wants to merge 6 commits intocuviper:masterfrom
Draft
Draft: allow using an external symbol as a semaphore#26bonzini wants to merge 6 commits intocuviper:masterfrom
bonzini wants to merge 6 commits intocuviper:masterfrom
Conversation
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
As a step towards allowing user-provided semaphores, move from "static mut" to properly annotated interior mutability. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
In preparation for allowing semaphores declared outside the probe_lazy macro, split platform_probe_lazy in two: one macro to place the semaphore in the .probes section, one to create the tracepoint. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Change the macro argument from ident to path. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
For now, this is kept internal and not documented. However, it will be used by QEMU to let C code declare the semaphores. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Ensure that Semaphore is documented properly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
bonzini
commented
Sep 25, 2025
| // put it in the stapsdt note. The program cannot really do | ||
| // anything with it---the only available method is enabled(); therefore, | ||
| // even though not placing it in the .probes section could upset the tracing | ||
| // tool, it cannot be used to trigger undefined behavior. |
Author
There was a problem hiding this comment.
This is worth pointing out—here I assume that the tools are robust enough and will either complain or ignore the probe, but not mess themselves up.
Author
|
CI run at bonzini#3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In QEMU, each probe point has the address of its semaphore stored in a table, so that it's possible to observe which semaphores are enabled and which are not.
While in principle it is possible for a single (provider, name) pair to be associated to multiple semaphores, support for this is sometimes buggy so it's preferable to have a single semaphore shared between C code (which is where the table lies) and Rust invocations of
probe_lazy!.This series modifies
probe_lazy!so that:Semaphoreprobe_lazy!, as long as it has static lifetime.Semaphorereplaces thestatic mutsemaphore with anUnsafeCellwrapper that only allows reading. Alternatively, it could also use anAtomicU16, and the volatile read would be replaced with a relaxed load.