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.
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.
- relates to
-
JDK-8254877 GCLogPrecious::_lock rank constrains what locks you are allowed to have when crashing
- Closed
-
JDK-8273730 WorkGangBarrierSync constructor unused
- Resolved
-
JDK-8176363 Incorrect lock rank for G1 PtrQueue related locks
- Resolved
-
JDK-8198760 Move global lock SpaceManager::_expand_lock to MutexLocker.cpp
- Resolved
-
JDK-8184732 Deadlock detection improvements for 'special' locks
- Resolved
1.
|
Remove 'native' ranked Mutex | Resolved | Coleen Phillimore | ||
2.
|
Nonleaf ranked locks should not be safepoint_check_never | Resolved | Coleen Phillimore | ||
3.
|
Mutex with rank safepoint_check_never imply allow_vm_block | Resolved | Coleen Phillimore | ||
4.
|
Check Mutex ranking during a safepoint | Resolved | Coleen Phillimore | ||
5.
|
Do not hold ttyLock around stack walking | Resolved | Coleen Phillimore | ||
6.
|
Remove unused ProfilePrint_lock | Resolved | Coleen Phillimore | ||
7.
|
Create 'nosafepoint' rank | Resolved | Coleen Phillimore | ||
8.
|
Remove 'special' ranking | Resolved | Coleen Phillimore | ||
9.
|
Remove 'leaf' ranking for Mutex | Resolved | Coleen Phillimore | ||
10.
|
Add checking for rank values | Resolved | Coleen Phillimore | ||
11.
|
Change 'nonleaf' rank name | Resolved | Coleen Phillimore | ||
12.
|
Clarify special wait assert | Resolved | Coleen Phillimore |