diff options
author | José Rivero <jorive@microsoft.com> | 2019-06-24 20:31:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-24 20:31:14 -0700 |
commit | 46b22d8706a17d48de1259b3cd75a55903bd2dfd (patch) | |
tree | 4825e2591938e85643722f41ab58279acb2e9496 | |
parent | 56bc2579ee99fed75681f80aaae232efe990c94b (diff) | |
download | coreclr-46b22d8706a17d48de1259b3cd75a55903bd2dfd.tar.gz coreclr-46b22d8706a17d48de1259b3cd75a55903bd2dfd.tar.bz2 coreclr-46b22d8706a17d48de1259b3cd75a55903bd2dfd.zip |
Make s_numberOfSessions Volatile as advertisement to other devs that the data is being used across multiple threads and a portion of that usage is lock-free (#25366)
-rw-r--r-- | src/vm/eventpipe.cpp | 4 | ||||
-rw-r--r-- | src/vm/eventpipe.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp index fc29160d3e..eb8734f40c 100644 --- a/src/vm/eventpipe.cpp +++ b/src/vm/eventpipe.cpp @@ -36,7 +36,7 @@ VolatilePtr<EventPipeSession> EventPipe::s_pSessions[MaxNumberOfSessions]; #ifndef FEATURE_PAL unsigned int * EventPipe::s_pProcGroupOffsets = nullptr; #endif -uint32_t EventPipe::s_numberOfSessions = 0; +Volatile<uint32_t> EventPipe::s_numberOfSessions(0); // This function is auto-generated from /src/scripts/genEventPipe.py #ifdef FEATURE_PAL @@ -238,7 +238,7 @@ bool EventPipe::EnableInternal( return false; } - if (s_numberOfSessions > MaxNumberOfSessions) + if (s_numberOfSessions >= MaxNumberOfSessions) { _ASSERTE(!"Max number of sessions reached."); return false; diff --git a/src/vm/eventpipe.h b/src/vm/eventpipe.h index 4089d9003f..9889abcb52 100644 --- a/src/vm/eventpipe.h +++ b/src/vm/eventpipe.h @@ -63,7 +63,7 @@ public: static bool Enabled() { LIMITED_METHOD_CONTRACT; - return s_tracingInitialized && (s_numberOfSessions > 0); + return s_tracingInitialized && (s_numberOfSessions.LoadWithoutBarrier() > 0); } // Create a provider. @@ -206,7 +206,7 @@ private: #ifndef FEATURE_PAL static unsigned int * s_pProcGroupOffsets; #endif - static uint32_t s_numberOfSessions; + static Volatile<uint32_t> s_numberOfSessions; }; static_assert(EventPipe::MaxNumberOfSessions == 64, "Maximum number of EventPipe sessions is not 64."); |