diff options
author | John Högberg <[email protected]> | 2017-07-06 12:30:45 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2017-07-06 12:30:45 +0200 |
commit | 5a537ae41c2295f7f19e4e01fe90acc7585f5b30 (patch) | |
tree | 7a27a822fa0e7a09e2259a77683ca4f2632df0b3 /erts/emulator/beam/safe_hash.c | |
parent | 5e0019ebb29a9fd88e0b04f0bd0b0d722e3f189e (diff) | |
parent | 876ecc058d0d7dd48f8c5f7ddaf189d278e69925 (diff) | |
download | otp-5a537ae41c2295f7f19e4e01fe90acc7585f5b30.tar.gz otp-5a537ae41c2295f7f19e4e01fe90acc7585f5b30.tar.bz2 otp-5a537ae41c2295f7f19e4e01fe90acc7585f5b30.zip |
Merge branch 'john/erts/runtime-lcnt' into maint
* john/erts/runtime-lcnt:
Document rt_mask and add warnings about copy_save
Add an emulator test suite for lock counting
Break erts_debug:lock_counters/1 into separate BIFs
Allow toggling lock counting at runtime
Move lock flags to a common header
Enable register_SUITE for lcnt builds
Enable lcnt smoke test on all builds that have lcnt enabled
Make lock counter info independent of the locks being counted
OTP-14412
OTP-13170
OTP-14413
Diffstat (limited to 'erts/emulator/beam/safe_hash.c')
-rw-r--r-- | erts/emulator/beam/safe_hash.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/erts/emulator/beam/safe_hash.c b/erts/emulator/beam/safe_hash.c index 30b26a7296..527c9efeca 100644 --- a/erts/emulator/beam/safe_hash.c +++ b/erts/emulator/beam/safe_hash.c @@ -155,7 +155,8 @@ int safe_hash_table_sz(SafeHash *h) ** Init a pre allocated or static hash structure ** and allocate buckets. NOT SAFE */ -SafeHash* safe_hash_init(ErtsAlcType_t type, SafeHash* h, char* name, int size, SafeHashFunctions fun) +SafeHash* safe_hash_init(ErtsAlcType_t type, SafeHash* h, char* name, erts_lock_flags_t flags, + int size, SafeHashFunctions fun) { int i, bytes; @@ -170,7 +171,8 @@ SafeHash* safe_hash_init(ErtsAlcType_t type, SafeHash* h, char* name, int size, erts_smp_atomic_init_nob(&h->is_rehashing, 0); erts_smp_atomic_init_nob(&h->nitems, 0); for (i=0; i<SAFE_HASH_LOCK_CNT; i++) { - erts_smp_mtx_init(&h->lock_vec[i].mtx,"safe_hash"); + erts_smp_mtx_init(&h->lock_vec[i].mtx, "safe_hash", NIL, + flags); } return h; } @@ -273,5 +275,22 @@ void safe_hash_for_each(SafeHash* h, void (*func)(void *, void *), void *func_ar } } +#ifdef ERTS_ENABLE_LOCK_COUNT +void erts_lcnt_enable_hash_lock_count(SafeHash *h, erts_lock_flags_t flags, int enable) { + int i; + + for(i = 0; i < SAFE_HASH_LOCK_CNT; i++) { + erts_smp_mtx_t *lock = &h->lock_vec[i].mtx; + + if(enable) { + erts_lcnt_install_new_lock_info(&lock->lcnt, "safe_hash", NIL, + ERTS_LOCK_TYPE_MUTEX | flags); + } else { + erts_lcnt_uninstall(&lock->lcnt); + } + } +} +#endif /* ERTS_ENABLE_LOCK_COUNT */ + #endif /* !ERTS_SYS_CONTINOUS_FD_NUMBERS */ |