< prev index next >

src/os/aix/vm/os_aix.cpp

Print this page
rev 10257 : 8149036: Add tracing for thread related events at os level
Reviewed-by: coleenp

*** 34,43 **** --- 34,44 ---- #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" #include "compiler/compileBroker.hpp" #include "interpreter/interpreter.hpp" #include "jvm_aix.h" + #include "logging/log.hpp" #include "libo4.hpp" #include "libperfstat_aix.hpp" #include "libodm_aix.hpp" #include "loadlib_aix.hpp" #include "memory/allocation.inline.hpp"
*** 789,813 **** } const pthread_t pthread_id = ::pthread_self(); const tid_t kernel_thread_id = ::thread_self(); ! trcVerbose("newborn Thread : pthread-id %u, ktid " UINT64_FORMAT ! ", stack %p ... %p, stacksize 0x%IX (%IB)", ! pthread_id, kernel_thread_id, ! thread->stack_end(), ! thread->stack_base(), ! thread->stack_size(), ! thread->stack_size()); // Normally, pthread stacks on AIX live in the data segment (are allocated with malloc() // by the pthread library). In rare cases, this may not be the case, e.g. when third-party // tools hook pthread_create(). In this case, we may run into problems establishing // guard pages on those stacks, because the stacks may reside in memory which is not // protectable (shmated). if (thread->stack_base() > ::sbrk(0)) { ! trcVerbose("Thread " UINT64_FORMAT ": stack not in data segment.", (uint64_t) pthread_id); } // Try to randomize the cache line index of hot stack frames. // This helps when threads of the same stack traces evict each other's // cache lines. The threads can be either from the same JVM instance, or --- 790,809 ---- } const pthread_t pthread_id = ::pthread_self(); const tid_t kernel_thread_id = ::thread_self(); ! log_debug(os)("Thread is alive (pthread id " UINTX_FORMAT ", tid " UINTX_FORMAT ")", ! (uintx) pthread_id, (uintx) kernel_thread_id); // Normally, pthread stacks on AIX live in the data segment (are allocated with malloc() // by the pthread library). In rare cases, this may not be the case, e.g. when third-party // tools hook pthread_create(). In this case, we may run into problems establishing // guard pages on those stacks, because the stacks may reside in memory which is not // protectable (shmated). if (thread->stack_base() > ::sbrk(0)) { ! log_warning(os)("Thread " UINTX_FORMAT ": stack not in data segment.", (uintx)pthread_id); } // Try to randomize the cache line index of hot stack frames. // This helps when threads of the same stack traces evict each other's // cache lines. The threads can be either from the same JVM instance, or
*** 837,848 **** assert(osthread->get_state() == RUNNABLE, "invalid os thread state"); // Call one more level start routine. thread->run(); ! trcVerbose("Thread finished : pthread-id %u, ktid " UINT64_FORMAT ".", ! pthread_id, kernel_thread_id); return 0; } bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { --- 833,844 ---- assert(osthread->get_state() == RUNNABLE, "invalid os thread state"); // Call one more level start routine. thread->run(); ! log_debug(os)("Thread finished (pthread id " UINTX_FORMAT ", tid " UINTX_FORMAT ").", ! (uintx) pthread_id, (uintx) kernel_thread_id); return 0; } bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) {
*** 906,929 **** pthread_attr_setstacksize(&attr, stack_size); pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); ! pthread_attr_destroy(&attr); ! if (ret == 0) { ! trcVerbose("Created New Thread : pthread-id %u", tid); } else { ! if (os::Aix::on_pase()) { ! // QIBM_MULTI_THREADED=Y is needed when the launcher is started on iSeries ! // using QSH. Otherwise pthread_create fails with errno=11. ! trcVerbose("(Please make sure you set the environment variable " ! "QIBM_MULTI_THREADED=Y before running this program.)"); } - if (PrintMiscellaneous && (Verbose || WizardMode)) { - perror("pthread_create()"); } // Need to clean up stuff we've allocated so far thread->set_osthread(NULL); delete osthread; return false; } --- 902,926 ---- pthread_attr_setstacksize(&attr, stack_size); pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); ! LogHandle(os) log; ! if (log.is_debug()) { ! char buf[64]; if (ret == 0) { ! log.debug("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ", ! (uintx) tid, os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); } else { ! log.warning("Failed to start thread - pthread_create failed (%s) for attributes: %s.", ! strerror(errno), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); } } + + pthread_attr_destroy(&attr); + + if (ret != 0) { // Need to clean up stuff we've allocated so far thread->set_osthread(NULL); delete osthread; return false; }
*** 956,972 **** } const pthread_t pthread_id = ::pthread_self(); const tid_t kernel_thread_id = ::thread_self(); - trcVerbose("attaching Thread : pthread-id %u, ktid " UINT64_FORMAT ", stack %p ... %p, stacksize 0x%IX (%IB)", - pthread_id, kernel_thread_id, - thread->stack_end(), - thread->stack_base(), - thread->stack_size(), - thread->stack_size()); - // OSThread::thread_id is the pthread id. osthread->set_thread_id(pthread_id); // .. but keep kernel thread id too for diagnostics osthread->set_kernel_thread_id(kernel_thread_id); --- 953,962 ----
*** 988,997 **** --- 978,990 ---- // initialize signal mask for this thread // and save the caller's signal mask os::Aix::hotspot_sigmask(thread); + log_debug(os)("Thread attached (pthread id " UINTX_FORMAT ", tid " UINTX_FORMAT ")", + (uintx) pthread_id, (uintx) kernel_thread_id); + return true; } void os::pd_start_thread(Thread* thread) { int status = pthread_continue_np(thread->osthread()->pthread_id());
< prev index next >