Skip to content

Commit

Permalink
Backport changes affecting EventPipe from PR 38225 into C library. (#…
Browse files Browse the repository at this point in the history
…46219)

* Backport changes affecting EventPipe from PR 38225 into C library.

* Mono only supports portable thread pool.
  • Loading branch information
lateralusX authored Jan 7, 2021
1 parent 6b606df commit a6e85ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ep-session-provider.h"
#include "fstream.h"
#include "typestring.h"
#include "win32threadpool.h"

#undef EP_ARRAY_SIZE
#define EP_ARRAY_SIZE(expr) (sizeof(expr) / sizeof ((expr) [0]))
Expand Down Expand Up @@ -1524,6 +1525,15 @@ ep_rt_config_value_get_circular_mb (void)
return CLRConfig::GetConfigValue (CLRConfig::INTERNAL_EventPipeCircularMB);
}

static
inline
bool
ep_rt_config_value_get_use_portable_thread_pool (void)
{
STATIC_CONTRACT_NOTHROW;
return ThreadpoolMgr::UsePortableThreadPool ();
}

/*
* EventPipeSampleProfiler.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/mono/mono/eventpipe/ep-rt-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,15 @@ ep_rt_config_value_get_circular_mb (void)
return circular_mb;
}

static
inline
bool
ep_rt_config_value_get_use_portable_thread_pool (void)
{
// Only supports portable thread pool.
return true;
}

/*
* EventPipeSampleProfiler.
*/
Expand Down
12 changes: 10 additions & 2 deletions src/native/eventpipe/ep-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ config_register_provider (

ep_requires_lock_held ();

// See if we've already registered this provider.
EventPipeProvider *existing_provider = config_get_provider (config, ep_provider_get_provider_name (provider));
// See if we've already registered this provider. When the portable thread pool is being used, allow there to be multiple
// DotNETRuntime providers, as the portable thread pool temporarily uses an event source on the managed side with the same
// provider name.
// TODO: This change to allow multiple DotNETRuntime providers is temporary to get EventPipe working for
// PortableThreadPoolEventSource. Once a long-term solution is figured out, this change should be reverted. See
// https://github.com/dotnet/runtime/issues/38763 for more information.
EventPipeProvider *existing_provider = NULL;
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)
existing_provider = config_get_provider (config, ep_provider_get_provider_name (provider));

if (existing_provider)
return false;

Expand Down
4 changes: 4 additions & 0 deletions src/native/eventpipe/ep-rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ static
uint32_t
ep_rt_config_value_get_circular_mb (void);

static
bool
ep_rt_config_value_get_use_portable_thread_pool (void);

/*
* EventPipeSampleProfiler.
*/
Expand Down

0 comments on commit a6e85ec

Please sign in to comment.