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

Fix Mutex ranking system

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Delivered
    • P3
    • 18
    • 9
    • hotspot

    Description

      If a mutex has "leaf" ranking, it should be a leaf mutex, but alas, there are leaf-1 mutexes that are taken out when leaf mutexes are held. The ranking system is a bit fragile.

      I've been thinking about how to make this better, discussing with people like ErikO, Patricio and Kim, and suggest these improvements that can be made in stages:

      1. Remove 'native' rank. It's not used anymore for raw monitors and shouldn't have been used for others.
      2. Remove 'safepoint' and 'barrier' ranks that don't make sense.
         Their rank is odd because they're higher than 'leaf' but some have 'safepoint_check_never'
         The goal is to partition the safepoint checking locks vs. nonsafepoint checking locks by rank.
         If we want to have names for specific ranks, especially for locks in other files, that's ok to add later.

      3. Disallow _allow_vm_block=false, _safepoint_check_never configuration. If it's _safepoint_check_never, assume that the VM can take this lock. The other configurations make sense.

              _allow_vm_block=true, _safepoint_check_always - after safepoint check and lock acquired NSV
              _allow_vm_block=true, _safepoint_check_never - after lock acquired NSV
              _allow_vm_block=false, _safepoint_check_always - after safepoint check and lock acquired, other safepoints ok
              _allow_vm_block=false, _safepoint_check_never - after lock acquired, safepoints allowed (don't allow this!)

      4. Make a 'max_safepoint_never' rank > oopstorage, so max_safepoint_never is the highest ranked lock that doesn't check for safepoints. (Now we have that check as 'special')

      5. nonleaf ranked lock that don't safepoint don't make sense! Change to leaf, to set up for step 6.

      6. Divide leaf locks that check for safepoints, and leaf locks that don't check for safepoints into two.
      Non safepoint become 'max_safepoint_never', safepoint become 'safepoint' or some better name

      7. Log all lock hierarchies in /tmp while running the tests.

      8. Reverse order in the mutexLocker.cpp list so highest ranked locks go first.
      9. Make all safepoint checking locks = max_safepoint_always = 900 and put them first in the list, put the ones
         afterwards as some lock you own.rank() -1, ie:

        def(ClassLoaderDataGraph_lock , PaddedMutex , nonleaf, false, _safepoint_check_always);
        def(SystemDictionary_lock , PaddedMonitor, ClassLoaderDataGraph_lock.rank() -1, true, _safepoint_check_always);

      10. Add rank range checking so that there's no values that overlap the enum. Also add an operator so that you can't add to a rank. You can only subtract from max_safepoint_always or max_safepoint_never, but other ranks can be added in the middle if it makes things more clear, especially for locks defined in other files.

      11. If all 'max_safepoint_never' and below cannot safepoint and above that can, remove the _no_safepoint_check field and its initialization. It's implied by the rank now.

      Attachments

        Issue Links

          Activity

            People

              coleenp Coleen Phillimore
              coleenp Coleen Phillimore
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: