From 466e0ecb88a5cbdd0528ff22e81fa7c028ee9799 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Tue, 8 Jan 2019 11:01:18 -0800 Subject: [PATCH] Remove some PR_SET_VMAs during pthread_create PR_SET_VMA takes mmap_sem, which can cause contention and reduce performance any time many threads are created at the same time, like app startup. Test: camera launch performance Bug: 122471935 Change-Id: If7fa7ad99654c01d503f694976fd92bfd30d2afd --- libc/bionic/pthread_create.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index 8e8d180d3..06d2ecbbf 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -76,8 +76,6 @@ bionic_tls* __allocate_bionic_tls() { return nullptr; } - prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, allocation, allocation_size, "bionic TLS guard"); - // Carve out the writable TLS section. bionic_tls* result = reinterpret_cast(static_cast(allocation) + PTHREAD_GUARD_SIZE); @@ -88,7 +86,6 @@ bionic_tls* __allocate_bionic_tls() { return nullptr; } - prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, result, BIONIC_TLS_SIZE, "bionic TLS"); return result; } @@ -111,7 +108,6 @@ static void __init_alternate_signal_stack(pthread_internal_t* thread) { // We can only use const static allocated string for mapped region name, as Android kernel // uses the string pointer directly when dumping /proc/pid/maps. prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ss.ss_sp, ss.ss_size, "thread signal stack"); - prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, stack_base, PTHREAD_GUARD_SIZE, "thread signal stack guard"); } } @@ -214,8 +210,6 @@ static void* __create_thread_mapped_space(size_t mmap_size, size_t stack_guard_s munmap(space, mmap_size); return nullptr; } - prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, space, stack_guard_size, "thread stack guard"); - return space; }