aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/export.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-02-03 18:12:17 +0100
committerSverker Eriksson <[email protected]>2012-02-21 12:23:06 +0100
commit63265772e86ca2e0f14a236c8aa964697a7cda70 (patch)
treec9a9df9fa79c79c5007d303d74c3eebdb0c87e67 /erts/emulator/beam/export.c
parente148e9fc3e11eb6e08e2dc94a468dc433864b11b (diff)
downloadotp-63265772e86ca2e0f14a236c8aa964697a7cda70.tar.gz
otp-63265772e86ca2e0f14a236c8aa964697a7cda70.tar.bz2
otp-63265772e86ca2e0f14a236c8aa964697a7cda70.zip
erts: Fix memory reports from export table
Report sum from all code index.
Diffstat (limited to 'erts/emulator/beam/export.c')
-rw-r--r--erts/emulator/beam/export.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/erts/emulator/beam/export.c b/erts/emulator/beam/export.c
index 4a2a77a527..31de141497 100644
--- a/erts/emulator/beam/export.c
+++ b/erts/emulator/beam/export.c
@@ -40,6 +40,8 @@
static IndexTable export_tables[ERTS_NUM_CODE_IX]; /* Active not locked */
+static erts_smp_atomic_t total_entries_bytes;
+
#include "erl_smp.h"
erts_smp_rwmtx_t export_table_lock; /* Locks the secondary export table. */
@@ -126,6 +128,7 @@ export_alloc(struct export_entry* tmpl_e)
Export* obj;
blob = (struct export_blob*) erts_alloc(ERTS_ALC_T_EXPORT, sizeof(*blob));
+ erts_smp_atomic_add_nob(&total_entries_bytes, sizeof(*blob));
obj = &blob->exp;
obj->fake_op_func_info_for_hipe[0] = 0;
obj->fake_op_func_info_for_hipe[1] = 0;
@@ -165,6 +168,7 @@ export_free(struct export_entry* obj)
}
}
erts_free(ERTS_ALC_T_EXPORT, blob);
+ erts_smp_atomic_add_nob(&total_entries_bytes, -sizeof(*blob));
}
void
@@ -177,6 +181,7 @@ init_export_table(void)
rwmtx_opt.lived = ERTS_SMP_RWMTX_LONG_LIVED;
erts_smp_rwmtx_init_opt(&export_table_lock, &rwmtx_opt, "export_tab");
+ erts_smp_atomic_init_nob(&total_entries_bytes, 0);
f.hash = (H_FUN) export_hash;
f.cmp = (HCMP_FUN) export_cmp;
@@ -353,9 +358,19 @@ int export_list_size(ErtsCodeIndex code_ix)
int export_table_sz(void)
{
- return index_table_sz(&export_tables[erts_active_code_ix()]);
-}
+ int i, bytes = 0;
+ export_read_lock();
+ for (i=0; i<ERTS_NUM_CODE_IX; i++) {
+ bytes += index_table_sz(&export_tables[i]);
+ }
+ export_read_unlock();
+ return bytes;
+}
+int export_entries_sz(void)
+{
+ return erts_smp_atomic_read_nob(&total_entries_bytes);
+}
Export *export_get(Export *e)
{
struct export_entry ee;