From: Vladimir Sadov Date: Mon, 1 Jun 2020 03:57:00 +0000 (-0700) Subject: Revert "Enable test for MemoryBarrierProcessWide on arm64. Update comments." (#35974) X-Git-Tag: submit/tizen/20210909.063632~7671 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdf6a5a0e86101d438316c83d420eb03624b5fc4;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Revert "Enable test for MemoryBarrierProcessWide on arm64. Update comments." (#35974) * Revert "Enable test for MemoryBarrierProcessWide on arm64. Update comments. (#35817)" This reverts commit b6341c6e1ada32117639cc409d445fd6b9b9e9f0. * Update InterlockedTests.cs rerun CI --- diff --git a/src/libraries/System.Threading/tests/InterlockedTests.cs b/src/libraries/System.Threading/tests/InterlockedTests.cs index 1b66dff..cc3b2c3 100644 --- a/src/libraries/System.Threading/tests/InterlockedTests.cs +++ b/src/libraries/System.Threading/tests/InterlockedTests.cs @@ -302,7 +302,7 @@ namespace System.Threading.Tests Assert.Equal(0x17755771u, value); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/11177")] public void MemoryBarrierProcessWide() { // Stress MemoryBarrierProcessWide correctness using a simple AsymmetricLock @@ -358,6 +358,8 @@ namespace System.Threading.Tests // Returning LockCookie to call Exit on is the fastest implementation because of it works naturally with the RCU pattern. // The traditional Enter/Exit lock interface would require thread local storage or some other scheme to reclaim the cookie. + // Returning LockCookie to call Exit on is the fastest implementation because of it works naturally with the RCU pattern. + // The traditional Enter/Exit lock interface would require thread local storage or some other scheme to reclaim the cookie public LockCookie Enter() { int currentThreadId = Environment.CurrentManagedThreadId; @@ -378,7 +380,6 @@ namespace System.Threading.Tests // if (VolatileReadWithoutBarrier(ref _current) == entry) { - // at this point we know for sure that we own the lock. return entry; } @@ -397,13 +398,8 @@ namespace System.Threading.Tests var oldEntry = _current; _current = new LockCookie(Environment.CurrentManagedThreadId); - // MemoryBarrierProcessWide ensures, process-wide, that our write to _current becomes visible - // to every thread, and all writes by other threads become visible to us before we can continue. - // As a result any other thread that sets Taken to true either: - // a) made it past the read of _current and owns the lock OR - // b) will see that _current has changed and will revert Taken without taking the lock - // Thus we only need to wait for 'Taken' to become false and claim the lock for ourselves. - // 'Taken' may yet switch to true after that, but that cannot result in other thread owning the lock. + // After MemoryBarrierProcessWide, we can be sure that the Volatile.Read done by the fast thread will see that it is not a fast + // thread anymore, and thus it will not attempt to enter the lock. Interlocked.MemoryBarrierProcessWide(); // Keep looping as long as the lock is taken by other thread