release/19.x: [llvm-exegesis] Use correct rseq struct size (#100804)#100896
Merged
tru merged 1 commit intollvm:release/19.xfrom Jul 29, 2024
Merged
release/19.x: [llvm-exegesis] Use correct rseq struct size (#100804)#100896tru merged 1 commit intollvm:release/19.xfrom
tru merged 1 commit intollvm:release/19.xfrom
Conversation
Member
Author
|
@mgorny What do you think about merging this PR to the release branch? |
Member
Author
|
@llvm/pr-subscribers-tools-llvm-exegesis Author: None (llvmbot) ChangesBackport 1e8df9e Requested by: @boomanaiden154 Full diff: https://github.com/llvm/llvm-project/pull/100896.diff 1 Files Affected:
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index ed53f8fabb175..adee869967d98 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -466,9 +466,20 @@ class SubProcessFunctionExecutorImpl
// segfaults in the program. Unregister the rseq region so that we can safely
// unmap it later
#ifdef GLIBC_INITS_RSEQ
+ unsigned int RseqStructSize = __rseq_size;
+
+ // Glibc v2.40 (the change is also expected to be backported to v2.35)
+ // changes the definition of __rseq_size to be the usable area of the struct
+ // rather than the actual size of the struct. v2.35 uses only 20 bytes of
+ // the 32 byte struct. For now, it should be safe to assume that if the
+ // usable size is less than 32, the actual size of the struct will be 32
+ // bytes given alignment requirements.
+ if (__rseq_size < 32)
+ RseqStructSize = 32;
+
long RseqDisableOutput =
syscall(SYS_rseq, (intptr_t)__builtin_thread_pointer() + __rseq_offset,
- __rseq_size, RSEQ_FLAG_UNREGISTER, RSEQ_SIG);
+ RseqStructSize, RSEQ_FLAG_UNREGISTER, RSEQ_SIG);
if (RseqDisableOutput != 0)
exit(ChildProcessExitCodeE::RSeqDisableFailed);
#endif // GLIBC_INITS_RSEQ
|
mgorny
approved these changes
Jul 28, 2024
Glibc v2.40 changes the definition of __rseq_size to the usable area of the struct rather than the actual size of the struct to accommodate users trying to figure out what features can be used. This change breaks llvm-exegesis trying to disable rseq as the size registered in the kernel is no longer equal to __rseq_size. This patch adds a check to see if __rseq_size is less than 32 bytes and uses 32 as a value if it is given alignment requirements. Fixes llvm#100791. (cherry picked from commit 1e8df9e)
|
@boomanaiden154 (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. |
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.
Backport 1e8df9e
Requested by: @boomanaiden154