Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8191784

[JVMCI] JavaThread::collect_counters() should stop using Threads_lock

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 10
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      src/hotspot/share/runtime/thread.cpp:

      void JavaThread::collect_counters(typeArrayOop array) {
        if (JVMCICounterSize > 0) {
          // dcubed - Looks like the Threads_lock is for stable access
          // to _jvmci_old_thread_counters and _jvmci_counters.
          MutexLocker tl(Threads_lock);
          JavaThreadIteratorWithHandle jtiwh;
          for (int i = 0; i < array->length(); i++) {
            array->long_at_put(i, _jvmci_old_thread_counters[i]);
          }
          for (; JavaThread *tp = jtiwh.next(); ) {
            if (jvmci_counters_include(tp)) {
              for (int i = 0; i < array->length(); i++) {
                array->long_at_put(i, array->long_at(i) + tp->_jvmci_counters[i]);
              }
            }
          }
        }
      }

      With the advent of ThreadsListHandles (and JavaThreadIteratorWithHandle),
      JavaThread::collect_counters() no longer needs to use Threads_lock to
      safely access JavaThreads. However, it looks like Threads_lock is also
      being used for stable access to _jvmci_old_thread_counters and
      _jvmci_counters.

      It would be better if another mechanism or lock were used for that
      access in order to reduce use of the Threads_lock.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlong Dean Long
                Reporter:
                dcubed Daniel Daugherty
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: