From 360a4c66b0fae2b38a97d69d39032e28521786de Mon Sep 17 00:00:00 2001 From: John Salem Date: Wed, 30 Mar 2022 10:15:21 -0700 Subject: [PATCH 01/11] Add method stubs for eventid 65 --- ...meEventSource.PortableThreadPool.NativeSinks.cs | 10 ++++++++++ .../NativeRuntimeEventSource.PortableThreadPool.cs | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs index 011f3dc45a4dd6..af5c370d16ceab 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs @@ -46,6 +46,7 @@ private static class Messages { public const EventOpcode IOEnqueue = (EventOpcode)13; public const EventOpcode IODequeue = (EventOpcode)14; + public const EventOpcode IOPack = (EventOpcode)15; public const EventOpcode Wait = (EventOpcode)90; public const EventOpcode Sample = (EventOpcode)100; public const EventOpcode Adjustment = (EventOpcode)101; @@ -225,5 +226,14 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID } LogThreadPoolWorkingThreadCount(Count, ClrInstanceID); } + + [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, + ushort ClrInstanceID = DefaultClrInstanceId) + { + throw new NotImplementedException(); + } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index 08bc3de170d4ef..253ba2282f3821 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -50,6 +50,7 @@ private static class Messages { public const EventOpcode IOEnqueue = (EventOpcode)13; public const EventOpcode IODequeue = (EventOpcode)14; + public const EventOpcode IOPack = (EventOpcode)15; public const EventOpcode Wait = (EventOpcode)90; public const EventOpcode Sample = (EventOpcode)100; public const EventOpcode Adjustment = (EventOpcode)101; @@ -362,5 +363,18 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID data[1].Reserved = 0; WriteEventCore(60, 2, data); } + +#if !ES_BUILD_STANDALONE + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", + Justification = EventSourceSuppressMessage)] +#endif + [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, + ushort ClrInstanceID = DefaultClrInstanceId) + { + throw new NotImplementedException(); + } } } From 18e7adca76cffd8e5e4fa77541c63205e87456e2 Mon Sep 17 00:00:00 2001 From: John Salem Date: Wed, 30 Mar 2022 10:16:01 -0700 Subject: [PATCH 02/11] Turn on and update test --- .../NativeRuntimeEventSourceTest.cs | 16 +++++++++++++++- .../nativeruntimeeventsource.csproj | 8 +------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs b/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs index 43306a803ffbfc..29e74af014b808 100644 --- a/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs +++ b/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs @@ -5,7 +5,9 @@ using System.IO; using System.Diagnostics.Tracing; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Threading; +using System.Threading.Tasks; using Tracing.Tests.Common; namespace Tracing.Tests @@ -22,7 +24,11 @@ static int Main(string[] args) using (SimpleEventListener listener = new SimpleEventListener("Simple")) { // Trigger the allocator task. - System.Threading.Tasks.Task.Run(new Action(Allocator)); + Task.Run(new Action(Allocator)); + + // If on Windows, attempt some Overlapped IO (triggers ThreadPool events) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + DoOverlappedIO(); // Wait for events. Thread.Sleep(1000); @@ -57,6 +63,14 @@ private static void Allocator() Thread.Sleep(10); } } + + private static unsafe void DoOverlappedIO() + { + Console.WriteLine("DOOVERLAPPEDIO"); + Overlapped overlapped = new(); + NativeOverlapped* pOverlap = overlapped.Pack(null, null); + Overlapped.Free(pOverlap); + } } internal sealed class SimpleEventListener : EventListener diff --git a/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj b/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj index e6fab390492fd7..11c39d9a439b55 100644 --- a/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj +++ b/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj @@ -5,15 +5,9 @@ true true - - true - + From 6f146635a3056a3155a74dbb5db2de86320ada07 Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 14 Apr 2022 17:18:53 +0000 Subject: [PATCH 03/11] Disable test for Mono --- src/tests/issues.targets | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 820103fd248d0f..dea706ce9daf4a 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -1426,8 +1426,9 @@ https://github.com/dotnet/runtime/issues/54185 - - + + https://github.com/dotnet/runtime/issues/68032 + Mono does not define out of range fp to int conversions From 7122aecf7b111d78392324e3db12384cd9a11f47 Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 14 Apr 2022 21:17:28 +0000 Subject: [PATCH 04/11] fix test exclusion --- src/tests/issues.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index dea706ce9daf4a..6f1e717a113921 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -1426,7 +1426,7 @@ https://github.com/dotnet/runtime/issues/54185 - + https://github.com/dotnet/runtime/issues/68032 From 2f09eea6087063a7babc160b1388728238041612 Mon Sep 17 00:00:00 2001 From: John Salem Date: Wed, 20 Apr 2022 03:26:38 +0000 Subject: [PATCH 05/11] Add implementation of event for mono and use it --- ...eEventSource.PortableThreadPool.NativeSinks.cs | 15 ++++++++++++++- ...NativeRuntimeEventSource.PortableThreadPool.cs | 15 ++++++++++++++- .../src/System/Threading/Overlapped.cs | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs index af5c370d16ceab..af929b9a5edb05 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs @@ -233,7 +233,20 @@ private unsafe void ThreadPoolIOPack( IntPtr Overlapped, ushort ClrInstanceID = DefaultClrInstanceId) { - throw new NotImplementedException(); + if (!IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) + return; + + EventData* data = stackalloc EventData[3] + data[0].DataPointer = (IntPtr)(&NativeOverlapped); + data[0].Size = sizeof(IntPtr); + data[0].Reserved = 0; + data[1].DataPointer = (IntPtr)(&Overlapped); + data[1].Size = sizeof(IntPtr); + data[1].Reserved = 0; + data[2].DataPointer = (IntPtr)(&ClrInstanceId); + data[2].Size = sizeof(ushort); + data[2].Reserved = 0; + WriteEventCore(65, 3, data); } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index 253ba2282f3821..a146abcfb20e09 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -374,7 +374,20 @@ private unsafe void ThreadPoolIOPack( IntPtr Overlapped, ushort ClrInstanceID = DefaultClrInstanceId) { - throw new NotImplementedException(); + if (!IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) + return; + + EventData* data = stackalloc EventData[3] + data[0].DataPointer = (IntPtr)(&NativeOverlapped); + data[0].Size = sizeof(IntPtr); + data[0].Reserved = 0; + data[1].DataPointer = (IntPtr)(&Overlapped); + data[1].Size = sizeof(IntPtr); + data[1].Reserved = 0; + data[2].DataPointer = (IntPtr)(&ClrInstanceId); + data[2].Size = sizeof(ushort); + data[2].Reserved = 0; + WriteEventCore(65, 3, data); } } } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 6838de54ba5904..910f620af20374 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -98,6 +98,8 @@ internal sealed unsafe class OverlappedData *(GCHandle*)(_pNativeOverlapped + 1) = GCHandle.Alloc(this); success = true; + if (NativeRuntimeEventSource.Log.IsEnabled()) + NativeRuntimeEventSource.Log.ThreadPoolIOPack((IntPtr)(&pNativeOverlapped), (IntPtr)(&pNativeOverlapped)); return _pNativeOverlapped; } finally From fcf6d79be8aa0eebe60b0c1264a3a62220dbbe04 Mon Sep 17 00:00:00 2001 From: John Salem Date: Tue, 19 Apr 2022 23:03:36 -0700 Subject: [PATCH 06/11] Fix typo --- .../Threading/NativeRuntimeEventSource.PortableThreadPool.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index a146abcfb20e09..ac6020e49e519c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -377,7 +377,7 @@ private unsafe void ThreadPoolIOPack( if (!IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) return; - EventData* data = stackalloc EventData[3] + EventData* data = stackalloc EventData[3]; data[0].DataPointer = (IntPtr)(&NativeOverlapped); data[0].Size = sizeof(IntPtr); data[0].Reserved = 0; From 4acfe2e4e6f89c69d0bef06f9791a510a34e92bd Mon Sep 17 00:00:00 2001 From: John Salem Date: Wed, 20 Apr 2022 21:04:53 +0000 Subject: [PATCH 07/11] refactor to match pattern and feedback --- ....PortableThreadPool.NativeSinks.CoreCLR.cs | 11 ++++++++ ...ntSource.PortableThreadPool.NativeSinks.cs | 27 +++++++++---------- ...veRuntimeEventSource.PortableThreadPool.cs | 18 ++++++++++--- ...rce.PortableThreadPool.NativeSinks.Mono.cs | 19 +++++++++++++ .../src/System/Threading/Overlapped.cs | 2 +- .../NativeRuntimeEventSourceTest.cs | 11 +++++++- 6 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs index a06aa7950521a9..6602439e5f17c4 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs @@ -68,5 +68,16 @@ internal static partial void LogThreadPoolWorkingThreadCount( uint Count, ushort ClrInstanceID ); + + [NonEvent] + internal void LogThreadPoolIOPack( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID) + { + // This event is _only_ sent in a QCall in CoreCLR, so it shouldn't be called from managed code. + // This event is described in managed code so that EventListener is able to build metadata about the event. + throw new NotImplementedException(); + } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs index af929b9a5edb05..057b82f876d11d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs @@ -227,26 +227,25 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID LogThreadPoolWorkingThreadCount(Count, ClrInstanceID); } + [NonEvent] + [MethodImpl(MethodImplOptions.NoInlining)] + public unsafe void ThreadPoolIOPack(NativeOverlapped *nativeOverlapped) + { + if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) + { + ThreadPoolIOPack( + (IntPtr)nativeOverlapped, + (IntPtr)OverlappedData.GetOverlappedFromNative(nativeOverlapped).GetHashCode()); + } + } + [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, ushort ClrInstanceID = DefaultClrInstanceId) { - if (!IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) - return; - - EventData* data = stackalloc EventData[3] - data[0].DataPointer = (IntPtr)(&NativeOverlapped); - data[0].Size = sizeof(IntPtr); - data[0].Reserved = 0; - data[1].DataPointer = (IntPtr)(&Overlapped); - data[1].Size = sizeof(IntPtr); - data[1].Reserved = 0; - data[2].DataPointer = (IntPtr)(&ClrInstanceId); - data[2].Size = sizeof(ushort); - data[2].Reserved = 0; - WriteEventCore(65, 3, data); + LogThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID); } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index ac6020e49e519c..38511e8c527024 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -364,6 +364,18 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID WriteEventCore(60, 2, data); } + [NonEvent] + [MethodImpl(MethodImplOptions.NoInlining)] + public unsafe void ThreadPoolIOPack(NativeOverlapped *nativeOverlapped) + { + if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) + { + ThreadPoolIOPack( + (IntPtr)nativeOverlapped, + (IntPtr)OverlappedData.GetOverlappedFromNative(nativeOverlapped).GetHashCode()); + } + } + #if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] @@ -378,13 +390,13 @@ private unsafe void ThreadPoolIOPack( return; EventData* data = stackalloc EventData[3]; - data[0].DataPointer = (IntPtr)(&NativeOverlapped); + data[0].DataPointer = NativeOverlapped; data[0].Size = sizeof(IntPtr); data[0].Reserved = 0; - data[1].DataPointer = (IntPtr)(&Overlapped); + data[1].DataPointer = Overlapped; data[1].Size = sizeof(IntPtr); data[1].Reserved = 0; - data[2].DataPointer = (IntPtr)(&ClrInstanceId); + data[2].DataPointer = (IntPtr)(&ClrInstanceID); data[2].Size = sizeof(ushort); data[2].Reserved = 0; WriteEventCore(65, 3, data); diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs index bf9564fc11a7d9..dafd28827c0c2d 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs @@ -68,5 +68,24 @@ internal static extern void LogThreadPoolWorkingThreadCount( uint Count, ushort ClrInstanceID ); + + [NonEvent] + internal void LogThreadPoolIOPack( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID) + { + EventData* data = stackalloc EventData[3]; + data[0].DataPointer = NativeOverlapped; + data[0].Size = sizeof(IntPtr); + data[0].Reserved = 0; + data[1].DataPointer = Overlapped; + data[1].Size = sizeof(IntPtr); + data[1].Reserved = 0; + data[2].DataPointer = (IntPtr)(&ClrInstanceID); + data[2].Size = sizeof(ushort); + data[2].Reserved = 0; + WriteEventCore(65, 3, data); + } } } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 910f620af20374..131563779938c6 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -99,7 +99,7 @@ internal sealed unsafe class OverlappedData success = true; if (NativeRuntimeEventSource.Log.IsEnabled()) - NativeRuntimeEventSource.Log.ThreadPoolIOPack((IntPtr)(&pNativeOverlapped), (IntPtr)(&pNativeOverlapped)); + NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped); return _pNativeOverlapped; } finally diff --git a/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs b/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs index 29e74af014b808..c05747fca34382 100644 --- a/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs +++ b/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Tracing.Tests.Common; +using System.Collections.Generic; namespace Tracing.Tests { @@ -27,7 +28,7 @@ static int Main(string[] args) Task.Run(new Action(Allocator)); // If on Windows, attempt some Overlapped IO (triggers ThreadPool events) - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (OperatingSystem.IsWindows()) DoOverlappedIO(); // Wait for events. @@ -40,7 +41,11 @@ static int Main(string[] args) Thread.Sleep(1000); // Ensure that we've seen some events. + foreach (string s in listener.SeenProvidersAndEvents) + Console.WriteLine(s); Assert.True("listener.EventCount > 0", listener.EventCount > 0); + if (OperatingSystem.IsWindows()) + Assert.True("Saw the ThreadPoolIOPack event", listener.SeenProvidersAndEvents.Contains("Microsoft-Windows-DotNETRuntime/EVENTID(65)")); } // Generate some more GC events. @@ -75,6 +80,7 @@ private static unsafe void DoOverlappedIO() internal sealed class SimpleEventListener : EventListener { + public HashSet SeenProvidersAndEvents { get; private set; } = new(); private string m_name; // Keep track of the set of keywords to be enabled. @@ -122,6 +128,9 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData) } Console.WriteLine("\n"); + SeenProvidersAndEvents.Add($"{eventData.EventSource.Name}"); + SeenProvidersAndEvents.Add($"{eventData.EventSource.Name}/EVENTID({eventData.EventId})"); + EventCount++; } } From b087cc397104f0462b8e067f027e6907f9185195 Mon Sep 17 00:00:00 2001 From: John Salem Date: Wed, 20 Apr 2022 23:32:05 +0000 Subject: [PATCH 08/11] Feedback and fix Mono corelib build --- ...untimeEventSource.PortableThreadPool.NativeSinks.cs | 2 +- .../NativeRuntimeEventSource.PortableThreadPool.cs | 3 --- ...eEventSource.PortableThreadPool.NativeSinks.Mono.cs | 10 +++++++++- .../src/System/Threading/Overlapped.cs | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs index 057b82f876d11d..5eaaee080c5e11 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs @@ -229,7 +229,7 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID [NonEvent] [MethodImpl(MethodImplOptions.NoInlining)] - public unsafe void ThreadPoolIOPack(NativeOverlapped *nativeOverlapped) + public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index 38511e8c527024..5a3a248e056c79 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -386,9 +386,6 @@ private unsafe void ThreadPoolIOPack( IntPtr Overlapped, ushort ClrInstanceID = DefaultClrInstanceId) { - if (!IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) - return; - EventData* data = stackalloc EventData[3]; data[0].DataPointer = NativeOverlapped; data[0].Size = sizeof(IntPtr); diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs index dafd28827c0c2d..3ebc0b498d1c1c 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs @@ -12,6 +12,10 @@ namespace System.Diagnostics.Tracing // It contains the runtime specific interop to native event sinks. internal sealed partial class NativeRuntimeEventSource : EventSource { +#if !ES_BUILD_STANDALONE + private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; +#endif + [NonEvent] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void LogThreadPoolWorkerThreadStart(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); @@ -69,8 +73,12 @@ internal static extern void LogThreadPoolWorkingThreadCount( ushort ClrInstanceID ); +#if !ES_BUILD_STANDALONE + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", + Justification = EventSourceSuppressMessage)] +#endif [NonEvent] - internal void LogThreadPoolIOPack( + internal unsafe void LogThreadPoolIOPack( IntPtr NativeOverlapped, IntPtr Overlapped, ushort ClrInstanceID) diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 131563779938c6..543aa4061bc836 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.Tracing; using System.Runtime.InteropServices; namespace System.Threading From 8cb8c4afd4f208435cfe4f642a01ece7e205792e Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 21 Apr 2022 19:22:40 +0000 Subject: [PATCH 09/11] Move event firing to {Q|I}Call and ifdef for wasm --- ....PortableThreadPool.NativeSinks.CoreCLR.cs | 10 +++---- src/coreclr/vm/nativeeventsource.cpp | 10 +++++++ src/coreclr/vm/nativeeventsource.h | 1 + src/coreclr/vm/qcallentrypoints.cpp | 1 + ...rce.PortableThreadPool.NativeSinks.Mono.cs | 26 +++---------------- .../src/System/Threading/Overlapped.cs | 2 ++ src/mono/mono/component/event_pipe-stub.c | 18 ++++++++++++- src/mono/mono/component/event_pipe.c | 3 ++- src/mono/mono/component/event_pipe.h | 7 +++++ src/mono/mono/eventpipe/ep-rt-mono.c | 14 ++++++++++ src/mono/mono/eventpipe/ep-rt-mono.h | 6 +++++ .../mono/eventpipe/gen-eventing-event-inc.lst | 1 + src/mono/mono/metadata/icall-decl.h | 1 + src/mono/mono/metadata/icall-def.h | 1 + src/mono/mono/metadata/icall-eventpipe.c | 23 ++++++++++++++++ 15 files changed, 92 insertions(+), 32 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs index 6602439e5f17c4..f833134f370be8 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs @@ -70,14 +70,10 @@ ushort ClrInstanceID ); [NonEvent] - internal void LogThreadPoolIOPack( + [LibraryImport(RuntimeHelpers.QCall)] + internal static partial void LogThreadPoolIOPack( IntPtr NativeOverlapped, IntPtr Overlapped, - ushort ClrInstanceID) - { - // This event is _only_ sent in a QCall in CoreCLR, so it shouldn't be called from managed code. - // This event is described in managed code so that EventListener is able to build metadata about the event. - throw new NotImplementedException(); - } + ushort ClrInstanceID); } } diff --git a/src/coreclr/vm/nativeeventsource.cpp b/src/coreclr/vm/nativeeventsource.cpp index 751e8e625aad78..f2a8d7f7c5344d 100644 --- a/src/coreclr/vm/nativeeventsource.cpp +++ b/src/coreclr/vm/nativeeventsource.cpp @@ -133,4 +133,14 @@ extern "C" void QCALLTYPE LogThreadPoolWorkingThreadCount(_In_z_ uint count, _In END_QCALL; } + +extern "C" void QCALLTYPE LogThreadPoolIOPack(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ short ClrInstanceID) +{ + QCALL_CONTRACT; + BEGIN_QCALL; + + FireEtwThreadPoolIOPack(nativeOverlapped, overlapped, ClrInstanceID); + + END_QCALL; +} #endif // FEATURE_PERFTRACING diff --git a/src/coreclr/vm/nativeeventsource.h b/src/coreclr/vm/nativeeventsource.h index 9dbb751261de68..6f89d55c01e48c 100644 --- a/src/coreclr/vm/nativeeventsource.h +++ b/src/coreclr/vm/nativeeventsource.h @@ -26,6 +26,7 @@ extern "C" void QCALLTYPE LogThreadPoolWorkerThreadAdjustmentStats(_In_z_ double extern "C" void QCALLTYPE LogThreadPoolIOEnqueue(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ bool multiDequeues, _In_z_ short ClrInstanceID); extern "C" void QCALLTYPE LogThreadPoolIODequeue(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ short ClrInstanceID); extern "C" void QCALLTYPE LogThreadPoolWorkingThreadCount(_In_z_ uint count, _In_z_ short ClrInstanceID); +extern "C" void QCALLTYPE LogThreadPoolIOPack(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ short ClrInstanceID); #endif // defined(FEATURE_PERFTRACING) #endif //_NATIVEEVENTSOURCE_H_ diff --git a/src/coreclr/vm/qcallentrypoints.cpp b/src/coreclr/vm/qcallentrypoints.cpp index 2d5d1cfc92b37c..d47454bade8390 100644 --- a/src/coreclr/vm/qcallentrypoints.cpp +++ b/src/coreclr/vm/qcallentrypoints.cpp @@ -278,6 +278,7 @@ static const Entry s_QCall[] = DllImportEntry(LogThreadPoolWorkerThreadAdjustmentStats) DllImportEntry(LogThreadPoolIOEnqueue) DllImportEntry(LogThreadPoolIODequeue) + DllImportEntry(LogThreadPoolIOPack) DllImportEntry(LogThreadPoolWorkingThreadCount) DllImportEntry(EventPipeInternal_Enable) DllImportEntry(EventPipeInternal_Disable) diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs index 3ebc0b498d1c1c..ed34ddf60e0708 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs @@ -12,10 +12,6 @@ namespace System.Diagnostics.Tracing // It contains the runtime specific interop to native event sinks. internal sealed partial class NativeRuntimeEventSource : EventSource { -#if !ES_BUILD_STANDALONE - private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif - [NonEvent] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void LogThreadPoolWorkerThreadStart(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); @@ -73,27 +69,11 @@ internal static extern void LogThreadPoolWorkingThreadCount( ushort ClrInstanceID ); -#if !ES_BUILD_STANDALONE - [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", - Justification = EventSourceSuppressMessage)] -#endif [NonEvent] - internal unsafe void LogThreadPoolIOPack( + [MethodImplAttribute(MethodImplOptions.InternalCall)] + internal static extern void LogThreadPoolIOPack( IntPtr NativeOverlapped, IntPtr Overlapped, - ushort ClrInstanceID) - { - EventData* data = stackalloc EventData[3]; - data[0].DataPointer = NativeOverlapped; - data[0].Size = sizeof(IntPtr); - data[0].Reserved = 0; - data[1].DataPointer = Overlapped; - data[1].Size = sizeof(IntPtr); - data[1].Reserved = 0; - data[2].DataPointer = (IntPtr)(&ClrInstanceID); - data[2].Size = sizeof(ushort); - data[2].Reserved = 0; - WriteEventCore(65, 3, data); - } + ushort ClrInstanceID); } } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 543aa4061bc836..f6a5f5c0f74585 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -99,8 +99,10 @@ internal sealed unsafe class OverlappedData *(GCHandle*)(_pNativeOverlapped + 1) = GCHandle.Alloc(this); success = true; +#if FEATURE_PERFTRACING if (NativeRuntimeEventSource.Log.IsEnabled()) NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped); +#endif return _pNativeOverlapped; } finally diff --git a/src/mono/mono/component/event_pipe-stub.c b/src/mono/mono/component/event_pipe-stub.c index 273d04f62da9fd..e925629ae90acf 100644 --- a/src/mono/mono/component/event_pipe-stub.c +++ b/src/mono/mono/component/event_pipe-stub.c @@ -171,6 +171,12 @@ event_pipe_stub_write_event_threadpool_working_thread_count ( uint16_t count, uint16_t clr_instance_id); +static bool +event_pipe_stub_write_event_threadpool_io_pack ( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id); + MonoComponentEventPipe * component_event_pipe_stub_init (void); @@ -203,7 +209,8 @@ static MonoComponentEventPipe fn_table = { &event_pipe_stub_write_event_threadpool_worker_thread_adjustment_stats, &event_pipe_stub_write_event_threadpool_io_enqueue, &event_pipe_stub_write_event_threadpool_io_dequeue, - &event_pipe_stub_write_event_threadpool_working_thread_count + &event_pipe_stub_write_event_threadpool_working_thread_count, + &event_pipe_stub_write_event_threadpool_io_pack }; static bool @@ -443,6 +450,15 @@ event_pipe_stub_write_event_threadpool_working_thread_count ( return true; } +static bool +event_pipe_stub_write_event_threadpool_io_pack ( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id) +{ + return true; +} + MonoComponentEventPipe * component_event_pipe_stub_init (void) { diff --git a/src/mono/mono/component/event_pipe.c b/src/mono/mono/component/event_pipe.c index 0ca3a18a357728..c23a694714de6e 100644 --- a/src/mono/mono/component/event_pipe.c +++ b/src/mono/mono/component/event_pipe.c @@ -113,7 +113,8 @@ static MonoComponentEventPipe fn_table = { &ep_rt_write_event_threadpool_worker_thread_adjustment_stats, &ep_rt_write_event_threadpool_io_enqueue, &ep_rt_write_event_threadpool_io_dequeue, - &ep_rt_write_event_threadpool_working_thread_count + &ep_rt_write_event_threadpool_working_thread_count, + &ep_rt_write_event_threadpool_io_pack }; static bool diff --git a/src/mono/mono/component/event_pipe.h b/src/mono/mono/component/event_pipe.h index 940522321d7f96..c67e3b82867cfe 100644 --- a/src/mono/mono/component/event_pipe.h +++ b/src/mono/mono/component/event_pipe.h @@ -201,6 +201,12 @@ typedef bool uint16_t count, uint16_t clr_instance_id); +typedef bool +(*event_pipe_component_write_event_threadpool_io_pack_func)( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id); + /* * MonoComponentEventPipe function table. */ @@ -235,6 +241,7 @@ typedef struct _MonoComponentEventPipe { event_pipe_component_write_event_threadpool_io_enqueue_func write_event_threadpool_io_enqueue; event_pipe_component_write_event_threadpool_io_dequeue_func write_event_threadpool_io_dequeue; event_pipe_component_write_event_threadpool_working_thread_count_func write_event_threadpool_working_thread_count; + event_pipe_component_write_event_threadpool_io_pack_func write_event_threadpool_io_pack; } MonoComponentEventPipe; MONO_COMPONENT_EXPORT_ENTRYPOINT diff --git a/src/mono/mono/eventpipe/ep-rt-mono.c b/src/mono/mono/eventpipe/ep-rt-mono.c index c29345098d8bfc..189a2dcf003ec0 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.c +++ b/src/mono/mono/eventpipe/ep-rt-mono.c @@ -3802,6 +3802,20 @@ ep_rt_write_event_threadpool_working_thread_count ( NULL) == 0 ? true : false; } +bool +ep_rt_write_event_threadpool_io_pack ( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id) +{ + return FireEtwThreadPoolIOPack ( + (const void *)native_overlapped, + (const void *)overlapped, + clr_instance_id, + NULL, + NULL) == 0 ? true : false; +} + static void runtime_profiler_jit_begin ( diff --git a/src/mono/mono/eventpipe/ep-rt-mono.h b/src/mono/mono/eventpipe/ep-rt-mono.h index ac7e41dc8aee14..f1edf6cd8dbc41 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.h +++ b/src/mono/mono/eventpipe/ep-rt-mono.h @@ -2296,6 +2296,12 @@ ep_rt_write_event_threadpool_working_thread_count ( uint16_t count, uint16_t clr_instance_id); +bool +ep_rt_write_event_threadpool_io_pack ( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id); + /* * EventPipe provider callbacks. */ diff --git a/src/mono/mono/eventpipe/gen-eventing-event-inc.lst b/src/mono/mono/eventpipe/gen-eventing-event-inc.lst index ad52dd9f8c8ebb..42086b3d81e3d0 100644 --- a/src/mono/mono/eventpipe/gen-eventing-event-inc.lst +++ b/src/mono/mono/eventpipe/gen-eventing-event-inc.lst @@ -42,6 +42,7 @@ ThreadPoolWorkerThreadStart ThreadPoolWorkerThreadStop ThreadPoolWorkerThreadWait ThreadPoolWorkingThreadCount +ThreadPoolIOPack ThreadTerminated TypeLoadStart TypeLoadStop diff --git a/src/mono/mono/metadata/icall-decl.h b/src/mono/mono/metadata/icall-decl.h index 0c7334de6d4451..23647ef78a7aff 100644 --- a/src/mono/mono/metadata/icall-decl.h +++ b/src/mono/mono/metadata/icall-decl.h @@ -166,6 +166,7 @@ ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_ ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop (uint32_t active_thread_count, uint32_t retired_worker_thread_count, uint16_t clr_instance_id); ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait (uint32_t active_thread_count, uint32_t retired_worker_thread_count, uint16_t clr_instance_id); ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount (uint16_t count, uint16_t clr_instance_id); +ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack (intptr_t native_overlapped, intptr_t overlapped, uint16_t clr_instance_id); ICALL_EXPORT void ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array); ICALL_EXPORT void ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname, MonoBoolean free_struct); diff --git a/src/mono/mono/metadata/icall-def.h b/src/mono/mono/metadata/icall-def.h index 6845a35a7482f2..25907864b7e4b8 100644 --- a/src/mono/mono/metadata/icall-def.h +++ b/src/mono/mono/metadata/icall-def.h @@ -179,6 +179,7 @@ NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_6, "LogThreadPoolWorkerThreadStart", NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_7, "LogThreadPoolWorkerThreadStop", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_8, "LogThreadPoolWorkerThreadWait", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_9, "LogThreadPoolWorkingThreadCount", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount)) +NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_10, "LogThreadPoolIOPack", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack)) ICALL_TYPE(ENUM, "System.Enum", ENUM_1) HANDLES(ENUM_1, "GetEnumValuesAndNames", ves_icall_System_Enum_GetEnumValuesAndNames, MonoBoolean, 3, (MonoQCallTypeHandle, MonoArrayOut, MonoArrayOut)) diff --git a/src/mono/mono/metadata/icall-eventpipe.c b/src/mono/mono/metadata/icall-eventpipe.c index 7165efd3805890..78dba38de681f9 100644 --- a/src/mono/mono/metadata/icall-eventpipe.c +++ b/src/mono/mono/metadata/icall-eventpipe.c @@ -465,6 +465,18 @@ ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorki clr_instance_id); } +void +ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack ( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id) +{ + mono_component_event_pipe ()->write_event_threadpool_io_pack ( + native_overlapped, + overlapped, + clr_instance_id); +} + #else /* ENABLE_PERFTRACING */ gconstpointer @@ -703,4 +715,15 @@ ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorki mono_error_set_pending_exception (error); } +void +ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack ( + intptr_t native_overlapped, + intptr_t overlapped, + uint16_t clr_instance_id) +{ + ERROR_DECL (error); + mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.NativeRuntimeEventSource.LogThreadPoolIOPack"); + mono_error_set_pending_exception (error); +} + #endif /* ENABLE_PERFTRACING */ From da14ec5a240cec12778e922641e4ca93b3de7ae0 Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 21 Apr 2022 21:05:56 +0000 Subject: [PATCH 10/11] suppress CA1822 --- .../NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs | 1 + .../Threading/NativeRuntimeEventSource.PortableThreadPool.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs index 5eaaee080c5e11..2d4bcbc6a6b5c9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs @@ -15,6 +15,7 @@ namespace System.Diagnostics.Tracing // FireEtw* methods auto-generated from ClrEtwAll.man. This ensures that corresponding event sinks are being used // for the native platform. // For implementation of these events not supporting native sinks, refer to NativeRuntimeEventSource.PortableThreadPool.cs. + [CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "NativeRuntimeEventSource is a special case where event methods don't use WriteEvent/WriteEventCore but still need to be instance methods.")] internal sealed partial class NativeRuntimeEventSource : EventSource { // This value does not seem to be used, leaving it as zero for now. It may be useful for a scenario that may involve diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index 5a3a248e056c79..6e4b13e1e03433 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -366,7 +366,7 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID [NonEvent] [MethodImpl(MethodImplOptions.NoInlining)] - public unsafe void ThreadPoolIOPack(NativeOverlapped *nativeOverlapped) + public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped) { if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword)) { From c58fa15735403ad9f186e0b3ea554825f89acae8 Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 21 Apr 2022 22:25:24 +0000 Subject: [PATCH 11/11] Fix ordering of ICall defs for Mono --- src/mono/mono/metadata/icall-def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/icall-def.h b/src/mono/mono/metadata/icall-def.h index 25907864b7e4b8..d9ce17336ab907 100644 --- a/src/mono/mono/metadata/icall-def.h +++ b/src/mono/mono/metadata/icall-def.h @@ -172,6 +172,7 @@ NOHANDLES(ICALL(EVENTPIPE_12, "WriteEventData", ves_icall_System_Diagnostics_Tra ICALL_TYPE(NATIVE_RUNTIME_EVENT_SOURCE, "System.Diagnostics.Tracing.NativeRuntimeEventSource", NATIVE_RUNTIME_EVENT_SOURCE_1) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_1, "LogThreadPoolIODequeue", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIODequeue)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_2, "LogThreadPoolIOEnqueue", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOEnqueue)) +NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_10, "LogThreadPoolIOPack", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_3, "LogThreadPoolWorkerThreadAdjustmentAdjustment", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_4, "LogThreadPoolWorkerThreadAdjustmentSample", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_5, "LogThreadPoolWorkerThreadAdjustmentStats", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats)) @@ -179,7 +180,6 @@ NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_6, "LogThreadPoolWorkerThreadStart", NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_7, "LogThreadPoolWorkerThreadStop", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_8, "LogThreadPoolWorkerThreadWait", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_9, "LogThreadPoolWorkingThreadCount", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount)) -NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_10, "LogThreadPoolIOPack", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack)) ICALL_TYPE(ENUM, "System.Enum", ENUM_1) HANDLES(ENUM_1, "GetEnumValuesAndNames", ves_icall_System_Enum_GetEnumValuesAndNames, MonoBoolean, 3, (MonoQCallTypeHandle, MonoArrayOut, MonoArrayOut))