[llvm] [llvm-exegesis] Add thread IDs to subprocess memory names (PR #84451)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 00:14:01 PDT 2024
================
@@ -22,12 +23,21 @@ namespace exegesis {
#if defined(__linux__) && !defined(__ANDROID__)
+long getCurrentTID() {
+ // We're using the raw syscall here rather than the gettid() function provided
+ // by most libcs for compatibility as gettid() was only added to glibc in
+ // version 2.30.
+ return syscall(SYS_gettid);
+}
+
Error SubprocessMemory::initializeSubprocessMemory(pid_t ProcessID) {
// Add the PID to the shared memory name so that if we're running multiple
// processes at the same time, they won't interfere with each other.
// This comes up particularly often when running the exegesis tests with
- // llvm-lit
- std::string AuxiliaryMemoryName = "/auxmem" + std::to_string(ProcessID);
+ // llvm-lit. Additionally add the TID so that downstream consumers
+ // using multiple threads don't run into conflicts.
+ std::string AuxiliaryMemoryName = "/" + std::to_string(getCurrentTID()) +
+ "auxmem" + std::to_string(ProcessID);
----------------
boomanaiden154 wrote:
Can't believe I didn't find that. Guess I should've looked harder. Thanks for pointing it out! The three instances mentioned here have been updated to use `llvm::formatv`.
(Also didn't realize that you could import llvm headers on compiler explorer. Nifty!)
https://github.com/llvm/llvm-project/pull/84451
More information about the llvm-commits
mailing list