diff options
author | Yabin Cui <yabinc@google.com> | 2018-01-23 12:56:18 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2018-01-24 16:11:07 -0800 |
commit | 6b9c85b36d2e69b45d780e6a0b27d64909311a7e (patch) | |
tree | eff21cc7000bc125f5c91f0d90819fd778be371f /benchmarks | |
parent | 73871ad09be8a8259171d606c4e3e3cf08d4733c (diff) | |
download | android_bionic-6b9c85b36d2e69b45d780e6a0b27d64909311a7e.tar.gz android_bionic-6b9c85b36d2e69b45d780e6a0b27d64909311a7e.tar.bz2 android_bionic-6b9c85b36d2e69b45d780e6a0b27d64909311a7e.zip |
Support priority inheritance mutex in 64bit programs.
Bug: http://b/29177606
Test: run bionic-unit-tests on walleye.
Test: run bionic-unit-tests-glibc on host.
Change-Id: Iac349284aa73515f384e7509445f87434757f59e
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/pthread_benchmark.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp index 1ad634576..46d6e6430 100644 --- a/benchmarks/pthread_benchmark.cpp +++ b/benchmarks/pthread_benchmark.cpp @@ -96,6 +96,57 @@ static void BM_pthread_mutex_lock_RECURSIVE(benchmark::State& state) { } BIONIC_BENCHMARK(BM_pthread_mutex_lock_RECURSIVE); +#if defined(__LP64__) +namespace { +struct PIMutex { + pthread_mutex_t mutex; + + PIMutex(int type) { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, type); + pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT); + pthread_mutex_init(&mutex, &attr); + pthread_mutexattr_destroy(&attr); + } + + ~PIMutex() { + pthread_mutex_destroy(&mutex); + } +}; +} + +static void BM_pthread_mutex_lock_PI(benchmark::State& state) { + PIMutex m(PTHREAD_MUTEX_NORMAL); + + while (state.KeepRunning()) { + pthread_mutex_lock(&m.mutex); + pthread_mutex_unlock(&m.mutex); + } +} +BIONIC_BENCHMARK(BM_pthread_mutex_lock_PI); + +static void BM_pthread_mutex_lock_ERRORCHECK_PI(benchmark::State& state) { + PIMutex m(PTHREAD_MUTEX_ERRORCHECK); + + while (state.KeepRunning()) { + pthread_mutex_lock(&m.mutex); + pthread_mutex_unlock(&m.mutex); + } +} +BIONIC_BENCHMARK(BM_pthread_mutex_lock_ERRORCHECK_PI); + +static void BM_pthread_mutex_lock_RECURSIVE_PI(benchmark::State& state) { + PIMutex m(PTHREAD_MUTEX_RECURSIVE); + + while (state.KeepRunning()) { + pthread_mutex_lock(&m.mutex); + pthread_mutex_unlock(&m.mutex); + } +} +BIONIC_BENCHMARK(BM_pthread_mutex_lock_RECURSIVE_PI); +#endif // defined(__LP64__) + static void BM_pthread_rwlock_read(benchmark::State& state) { pthread_rwlock_t lock; pthread_rwlock_init(&lock, NULL); |