aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/io.c
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2017-05-18 23:05:02 +0200
committerJohn Högberg <[email protected]>2017-05-18 23:05:02 +0200
commit9f0e2acbdc7105f02a8cac2aa11cf9259dca34ae (patch)
tree492c84a8c7d3633de1cd6982d634fb880a9b78d4 /erts/emulator/beam/io.c
parent05dce0f330c83278cb134c7235a5353ce4116307 (diff)
downloadotp-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/io.c')
-rw-r--r--erts/emulator/beam/io.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index d25e53ada0..11cb2dfddf 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -3461,39 +3461,34 @@ void erts_init_io(int port_tab_size,
static ERTS_INLINE void lcnt_enable_drv_lock_count(erts_driver_t *dp, int enable)
{
if (dp->lock) {
- if (enable)
- erts_lcnt_init_lock_x(&dp->lock->lcnt,
- "driver_lock",
- ERTS_LCNT_LT_MUTEX,
- erts_atom_put((byte*)dp->name,
- sys_strlen(dp->name),
- ERTS_ATOM_ENC_LATIN1,
- 1));
-
- else
- erts_lcnt_destroy_lock(&dp->lock->lcnt);
-
- }
+ if (enable) {
+ Eterm name_as_atom = erts_atom_put((byte*)dp->name, sys_strlen(dp->name),
+ ERTS_ATOM_ENC_LATIN1, 1);
+ erts_lcnt_install_new_lock_info_x(&dp->lock->lcnt,
+ "driver_lock", ERTS_LCNT_LT_MUTEX, name_as_atom);
+ } else {
+ erts_lcnt_uninstall(&dp->lock->lcnt);
+ }
+ }
}
static ERTS_INLINE void lcnt_enable_port_lock_count(Port *prt, int enable)
{
erts_aint32_t state = erts_atomic32_read_nob(&prt->state);
- if (!enable) {
- erts_lcnt_destroy_lock(&prt->sched.mtx.lcnt);
- if (state & ERTS_PORT_SFLG_PORT_SPECIFIC_LOCK)
- erts_lcnt_destroy_lock(&prt->lock->lcnt);
- }
- else {
- erts_lcnt_init_lock_x(&prt->sched.mtx.lcnt,
- "port_sched_lock",
- ERTS_LCNT_LT_MUTEX,
- prt->common.id);
- if (state & ERTS_PORT_SFLG_PORT_SPECIFIC_LOCK)
- erts_lcnt_init_lock_x(&prt->lock->lcnt,
- "port_lock",
- ERTS_LCNT_LT_MUTEX,
- prt->common.id);
+
+ if(enable) {
+ erts_lcnt_install_new_lock_info_x(&prt->sched.mtx.lcnt,
+ "port_sched_lock", ERTS_LCNT_LT_MUTEX,prt->common.id);
+
+ if (state & ERTS_PORT_SFLG_PORT_SPECIFIC_LOCK) {
+ erts_lcnt_install_new_lock_info_x(&prt->lock->lcnt,
+ "port_lock", ERTS_LCNT_LT_MUTEX, prt->common.id);
+ }
+ } else {
+ erts_lcnt_uninstall(&prt->sched.mtx.lcnt);
+ if (state & ERTS_PORT_SFLG_PORT_SPECIFIC_LOCK) {
+ erts_lcnt_uninstall(&prt->lock->lcnt);
+ }
}
}
@@ -3701,7 +3696,7 @@ deliver_result(Port *prt, Eterm sender, Eterm pid, Eterm res)
ERTS_SMP_CHK_NO_PROC_LOCKS;
ASSERT(!prt || prt->common.id == sender);
-#ifdef ERTS_SMP
+#if defined(ERTS_SMP) && defined(ERTS_ENABLE_LOCK_CHECK)
ASSERT(!prt || erts_lc_is_port_locked(prt));
#endif