diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs index b6f612532f4fe1..5ba348edd7fe20 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs @@ -217,7 +217,7 @@ public unsafe void ThreadPoolWorkerThreadAdjustmentStats( [Event(63, Level = EventLevel.Verbose, Message = Messages.IOEnqueue, Task = Tasks.ThreadPool, Opcode = Opcodes.IOEnqueue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)] private unsafe void ThreadPoolIOEnqueue( IntPtr NativeOverlapped, - IntPtr Overlapped, + IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary bool MultiDequeues, ushort ClrInstanceID = DefaultClrInstanceId) { @@ -230,9 +230,14 @@ public unsafe void ThreadPoolIOEnqueue(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)) { +#if TARGET_WINDOWS + IntPtr overlapped = ThreadPool.UseWindowsThreadPool ? 0 : (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#else + IntPtr overlapped = (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#endif ThreadPoolIOEnqueue( (IntPtr)nativeOverlapped, - (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(), + overlapped, false); } } @@ -254,7 +259,7 @@ public void ThreadPoolIOEnqueue(RegisteredWaitHandle registeredWaitHandle) [Event(64, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IODequeue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)] private unsafe void ThreadPoolIODequeue( IntPtr NativeOverlapped, - IntPtr Overlapped, + IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary ushort ClrInstanceID = DefaultClrInstanceId) { LogThreadPoolIODequeue(NativeOverlapped, Overlapped, ClrInstanceID); @@ -266,9 +271,14 @@ public unsafe void ThreadPoolIODequeue(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)) { +#if TARGET_WINDOWS + IntPtr overlapped = ThreadPool.UseWindowsThreadPool ? 0 : (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#else + IntPtr overlapped = (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#endif ThreadPoolIODequeue( (IntPtr)nativeOverlapped, - (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode()); + overlapped); } } @@ -300,16 +310,21 @@ public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) { +#if TARGET_WINDOWS + IntPtr overlapped = ThreadPool.UseWindowsThreadPool ? 0 : (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#else + IntPtr overlapped = (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#endif ThreadPoolIOPack( (IntPtr)nativeOverlapped, - (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode()); + overlapped); } } [Event(65, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IOPack, Version = 0, Keywords = Keywords.ThreadingKeyword)] private unsafe void ThreadPoolIOPack( IntPtr NativeOverlapped, - IntPtr Overlapped, + IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary ushort ClrInstanceID = DefaultClrInstanceId) { LogThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs index 2dff7526e35d86..11c4dfcfe6c539 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs @@ -340,7 +340,7 @@ public unsafe void ThreadPoolWorkerThreadAdjustmentStats( [Event(63, Level = EventLevel.Verbose, Message = Messages.IOEnqueue, Task = Tasks.ThreadPool, Opcode = Opcodes.IOEnqueue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)] private unsafe void ThreadPoolIOEnqueue( IntPtr NativeOverlapped, - IntPtr Overlapped, + IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary bool MultiDequeues, ushort ClrInstanceID = DefaultClrInstanceId) { @@ -367,9 +367,14 @@ public unsafe void ThreadPoolIOEnqueue(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)) { +#if TARGET_WINDOWS + IntPtr overlapped = ThreadPool.UseWindowsThreadPool ? 0 : (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#else + IntPtr overlapped = (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#endif ThreadPoolIOEnqueue( (IntPtr)nativeOverlapped, - (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(), + overlapped, false); } } @@ -392,7 +397,7 @@ public void ThreadPoolIOEnqueue(RegisteredWaitHandle registeredWaitHandle) [Event(64, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IODequeue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)] private unsafe void ThreadPoolIODequeue( IntPtr NativeOverlapped, - IntPtr Overlapped, + IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary ushort ClrInstanceID = DefaultClrInstanceId) { EventData* data = stackalloc EventData[3]; @@ -414,9 +419,14 @@ public unsafe void ThreadPoolIODequeue(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)) { +#if TARGET_WINDOWS + IntPtr overlapped = ThreadPool.UseWindowsThreadPool ? 0 : (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#else + IntPtr overlapped = (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#endif ThreadPoolIODequeue( (IntPtr)nativeOverlapped, - (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode()); + overlapped); } } @@ -456,9 +466,14 @@ public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) { +#if TARGET_WINDOWS + IntPtr overlapped = ThreadPool.UseWindowsThreadPool ? 0 : (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#else + IntPtr overlapped = (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode(); +#endif ThreadPoolIOPack( (IntPtr)nativeOverlapped, - (IntPtr)Overlapped.GetOverlappedFromNative(nativeOverlapped).GetHashCode()); + overlapped); } } @@ -466,7 +481,7 @@ public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped) [Event(65, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IOPack, Version = 0, Keywords = Keywords.ThreadingKeyword)] private unsafe void ThreadPoolIOPack( IntPtr NativeOverlapped, - IntPtr Overlapped, + IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary ushort ClrInstanceID = DefaultClrInstanceId) { EventData* data = stackalloc EventData[3];