< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page

        

@@ -824,13 +824,17 @@
         (GetMinStack)dlsym(RTLD_DEFAULT, "__pthread_get_minstack");
   log_info(os, thread)("Lookup of __pthread_get_minstack %s",
                        _get_minstack_func == NULL ? "failed" : "succeeded");
 }
 
+static bool tls_size_inited = false;
+static size_t tls_size = 0;
 // Returns the size of the static TLS area glibc puts on thread stacks.
 static size_t get_static_tls_area_size(const pthread_attr_t *attr) {
-  size_t tls_size = 0;
+  if (!tls_size_inited) {
+    tls_size_inited = true;
+
   if (_get_minstack_func != NULL) {
     // Obtain the pthread minstack size by calling __pthread_get_minstack.
     size_t minstack_size = _get_minstack_func(attr);
 
     // Remove non-TLS area size included in minstack size returned

@@ -857,10 +861,11 @@
     // if check is done for precaution.
     if (minstack_size > (size_t)os::vm_page_size() + PTHREAD_STACK_MIN) {
       tls_size = minstack_size - os::vm_page_size() - PTHREAD_STACK_MIN;
     }
   }
+  }
 
   log_info(os, thread)("Stack size adjustment for TLS is " SIZE_FORMAT,
                        tls_size);
   return tls_size;
 }
< prev index next >