summaryrefslogtreecommitdiff
path: root/chromium/base/allocator
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-03-08 13:07:32 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-03-08 13:40:10 +0000
commit818d9aed569afd192f6d4f6d9b28b72912df8b93 (patch)
treefa30cbdffa3e8fdc09dbbe37ffc0a721b40fced1 /chromium/base/allocator
parent66a2147d838e293f4a5db7711c8eba4e6faaaf0f (diff)
downloadqtwebengine-chromium-818d9aed569afd192f6d4f6d9b28b72912df8b93.tar.gz
BASELINE: Update Chromium to 65.0.3325.151
Change-Id: I3c71dd500483eb29491ac3eee4123714dda52da9 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base/allocator')
-rw-r--r--chromium/base/allocator/partition_allocator/spin_lock.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/chromium/base/allocator/partition_allocator/spin_lock.cc b/chromium/base/allocator/partition_allocator/spin_lock.cc
index c30d6cd43ad..fd062c33b4a 100644
--- a/chromium/base/allocator/partition_allocator/spin_lock.cc
+++ b/chromium/base/allocator/partition_allocator/spin_lock.cc
@@ -10,6 +10,8 @@
#include <sched.h>
#endif
+#include "base/threading/platform_thread.h"
+
// The YIELD_PROCESSOR macro wraps an architecture specific-instruction that
// informs the processor we're in a busy wait, so it can handle the branch more
// intelligently and e.g. reduce power to our core or give more resources to the
@@ -67,6 +69,9 @@ void SpinLock::LockSlow() {
// critical section defaults, and various other recommendations.
// TODO(jschuh): Further tuning may be warranted.
static const int kYieldProcessorTries = 1000;
+ // The value of |kYieldThreadTries| is completely made up.
+ static const int kYieldThreadTries = 10;
+ int yield_thread_count = 0;
do {
do {
for (int count = 0; count < kYieldProcessorTries; ++count) {
@@ -77,8 +82,17 @@ void SpinLock::LockSlow() {
return;
}
- // Give the OS a chance to schedule something on this core.
- YIELD_THREAD;
+ if (yield_thread_count < kYieldThreadTries) {
+ ++yield_thread_count;
+ // Give the OS a chance to schedule something on this core.
+ YIELD_THREAD;
+ } else {
+ // At this point, it's likely that the lock is held by a lower priority
+ // thread that is unavailable to finish its work because of higher
+ // priority threads spinning here. Sleeping should ensure that they make
+ // progress.
+ PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
+ }
} while (lock_.load(std::memory_order_relaxed));
} while (UNLIKELY(lock_.exchange(true, std::memory_order_acquire)));
}