Fix to avoid stalling the process when ETW is doing a rundown (dotnet/coreclr#8357)
authorVance Morrison <vancem@microsoft.com>
Wed, 30 Nov 2016 19:45:17 +0000 (11:45 -0800)
committerJan Kotas <jkotas@microsoft.com>
Wed, 30 Nov 2016 19:45:17 +0000 (11:45 -0800)
commit25976c57b0eeafa2dd8a16945a298e29dc1695d4
tree4c2b3cee31283ae7470892cc06a82b380e9feb87
parent02ba5821ba712de0f838648a92e7df4a7c992f9a
Fix to avoid stalling the process when ETW is doing a rundown (dotnet/coreclr#8357)

This only matters when there are MANY JIT compiled methods, but Bing operates
in exactly this mode, and thus it stalls for several seconds while rundown completes.

This fix does not fix the problem completely, but it makes it MUCH less likely, and is
a trivial, safe fix. The problem is that as part of a GC, we do cleanup of any removed
JIT code. To do this we take a JIT code manager lock, but this is also a lock that the
JIT code iterator takes and is used during ETW rundown. Thus rundown blocks GCs.

Almost all the time, we DON'T have JIT code manager cleanup to do, so we just avoid
taking the lock in that case, and this makes the stall MUCH less likely.

Commit migrated from https://github.com/dotnet/coreclr/commit/e26e3551994fd89f9360da7a463628cb7dbe67c5
src/coreclr/src/vm/codeman.cpp