Skip to content

Commit a6e85ec

Browse files
authored
Backport changes affecting EventPipe from PR 38225 into C library. (#46219)
* Backport changes affecting EventPipe from PR 38225 into C library. * Mono only supports portable thread pool.
1 parent 6b606df commit a6e85ec

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ep-session-provider.h"
1212
#include "fstream.h"
1313
#include "typestring.h"
14+
#include "win32threadpool.h"
1415

1516
#undef EP_ARRAY_SIZE
1617
#define EP_ARRAY_SIZE(expr) (sizeof(expr) / sizeof ((expr) [0]))
@@ -1524,6 +1525,15 @@ ep_rt_config_value_get_circular_mb (void)
15241525
return CLRConfig::GetConfigValue (CLRConfig::INTERNAL_EventPipeCircularMB);
15251526
}
15261527

1528+
static
1529+
inline
1530+
bool
1531+
ep_rt_config_value_get_use_portable_thread_pool (void)
1532+
{
1533+
STATIC_CONTRACT_NOTHROW;
1534+
return ThreadpoolMgr::UsePortableThreadPool ();
1535+
}
1536+
15271537
/*
15281538
* EventPipeSampleProfiler.
15291539
*/

src/mono/mono/eventpipe/ep-rt-mono.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,15 @@ ep_rt_config_value_get_circular_mb (void)
980980
return circular_mb;
981981
}
982982

983+
static
984+
inline
985+
bool
986+
ep_rt_config_value_get_use_portable_thread_pool (void)
987+
{
988+
// Only supports portable thread pool.
989+
return true;
990+
}
991+
983992
/*
984993
* EventPipeSampleProfiler.
985994
*/

src/native/eventpipe/ep-config.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,16 @@ config_register_provider (
9595

9696
ep_requires_lock_held ();
9797

98-
// See if we've already registered this provider.
99-
EventPipeProvider *existing_provider = config_get_provider (config, ep_provider_get_provider_name (provider));
98+
// See if we've already registered this provider. When the portable thread pool is being used, allow there to be multiple
99+
// DotNETRuntime providers, as the portable thread pool temporarily uses an event source on the managed side with the same
100+
// provider name.
101+
// TODO: This change to allow multiple DotNETRuntime providers is temporary to get EventPipe working for
102+
// PortableThreadPoolEventSource. Once a long-term solution is figured out, this change should be reverted. See
103+
// https://github.com/dotnet/runtime/issues/38763 for more information.
104+
EventPipeProvider *existing_provider = NULL;
105+
if (!ep_rt_config_value_get_use_portable_thread_pool () || ep_rt_utf8_string_compare (ep_config_get_public_provider_name_utf8 (), ep_provider_get_provider_name (provider)) != 0)
106+
existing_provider = config_get_provider (config, ep_provider_get_provider_name (provider));
107+
100108
if (existing_provider)
101109
return false;
102110

src/native/eventpipe/ep-rt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ static
294294
uint32_t
295295
ep_rt_config_value_get_circular_mb (void);
296296

297+
static
298+
bool
299+
ep_rt_config_value_get_use_portable_thread_pool (void);
300+
297301
/*
298302
* EventPipeSampleProfiler.
299303
*/

0 commit comments

Comments
 (0)