diff options
author | John Högberg <[email protected]> | 2017-05-18 23:05:02 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2017-05-18 23:05:02 +0200 |
commit | 9f0e2acbdc7105f02a8cac2aa11cf9259dca34ae (patch) | |
tree | 492c84a8c7d3633de1cd6982d634fb880a9b78d4 /erts/emulator/beam/erl_drv_thread.c | |
parent | 05dce0f330c83278cb134c7235a5353ce4116307 (diff) | |
download | otp-9f0e2acbdc7105f02a8cac2aa11cf9259dca34ae.tar.gz otp-9f0e2acbdc7105f02a8cac2aa11cf9259dca34ae.tar.bz2 otp-9f0e2acbdc7105f02a8cac2aa11cf9259dca34ae.zip |
Make lock counter info independent of the locks being counted
This allows us to enable/disable lock counting at will, and greatly improves
the performance of erts_debug:lock_counters/1 since we no longer have to
worry about the lock counters "dying" while we're enumerating them.
OTP-14412
Diffstat (limited to 'erts/emulator/beam/erl_drv_thread.c')
-rw-r--r-- | erts/emulator/beam/erl_drv_thread.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/erts/emulator/beam/erl_drv_thread.c b/erts/emulator/beam/erl_drv_thread.c index 0e6aadf568..3b68abe5d7 100644 --- a/erts/emulator/beam/erl_drv_thread.c +++ b/erts/emulator/beam/erl_drv_thread.c @@ -55,7 +55,7 @@ fatal_error(int err, char *func) struct ErlDrvMutex_ { ethr_mutex mtx; #ifdef ERTS_ENABLE_LOCK_COUNT - erts_lcnt_lock_t lcnt; + erts_lcnt_ref_t lcnt; #endif char *name; }; @@ -68,7 +68,7 @@ struct ErlDrvCond_ { struct ErlDrvRWLock_ { ethr_rwmutex rwmtx; #ifdef ERTS_ENABLE_LOCK_COUNT - erts_lcnt_lock_t lcnt; + erts_lcnt_ref_t lcnt; #endif char *name; }; @@ -176,7 +176,8 @@ erl_drv_mutex_create(char *name) dmtx->name = no_name; } #ifdef ERTS_ENABLE_LOCK_COUNT - erts_lcnt_init_lock(&dmtx->lcnt, dmtx->name, ERTS_LCNT_LT_MUTEX); + erts_lcnt_init_ref(&dmtx->lcnt); + erts_lcnt_install_new_lock_info(&dmtx->lcnt, dmtx->name, ERTS_LCNT_LT_MUTEX); #endif } return dmtx; @@ -191,7 +192,7 @@ erl_drv_mutex_destroy(ErlDrvMutex *dmtx) #ifdef USE_THREADS int res; #ifdef ERTS_ENABLE_LOCK_COUNT - erts_lcnt_destroy_lock(&dmtx->lcnt); + erts_lcnt_uninstall(&dmtx->lcnt); #endif res = dmtx ? ethr_mutex_destroy(&dmtx->mtx) : EINVAL; if (res != 0) @@ -368,7 +369,8 @@ erl_drv_rwlock_create(char *name) drwlck->name = no_name; } #ifdef ERTS_ENABLE_LOCK_COUNT - erts_lcnt_init_lock(&drwlck->lcnt, drwlck->name, ERTS_LCNT_LT_RWMUTEX); + erts_lcnt_init_ref(&drwlck->lcnt); + erts_lcnt_install_new_lock_info(&drwlck->lcnt, drwlck->name, ERTS_LCNT_LT_RWMUTEX); #endif } return drwlck; @@ -383,7 +385,7 @@ erl_drv_rwlock_destroy(ErlDrvRWLock *drwlck) #ifdef USE_THREADS int res; #ifdef ERTS_ENABLE_LOCK_COUNT - erts_lcnt_destroy_lock(&drwlck->lcnt); + erts_lcnt_uninstall(&drwlck->lcnt); #endif res = drwlck ? ethr_rwmutex_destroy(&drwlck->rwmtx) : EINVAL; if (res != 0) |