aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erts/emulator/beam/erl_alloc.c4
-rw-r--r--erts/emulator/beam/export.c19
-rw-r--r--erts/emulator/beam/export.h1
3 files changed, 20 insertions, 4 deletions
diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c
index bf7c53bf1a..ac92822aca 100644
--- a/erts/emulator/beam/erl_alloc.c
+++ b/erts/emulator/beam/erl_alloc.c
@@ -2185,7 +2185,7 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
if (want.code) {
size.code = module_table_sz();
size.code += export_table_sz();
- size.code += export_list_size(erts_active_code_ix()) * sizeof(Export);
+ size.code += export_entries_sz();
size.code += erts_fun_table_sz();
size.code += erts_ranges_sz();
size.code += erts_total_code_size;
@@ -2335,7 +2335,7 @@ erts_allocated_areas(int *print_to_p, void *print_to_arg, void *proc)
values[i].arity = 2;
values[i].name = "export_list";
- values[i].ui[0] = export_list_size(erts_active_code_ix ()) * sizeof(Export);
+ values[i].ui[0] = export_entries_sz();
i++;
values[i].arity = 2;
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;
diff --git a/erts/emulator/beam/export.h b/erts/emulator/beam/export.h
index 21cfafc77d..f59c5e5c89 100644
--- a/erts/emulator/beam/export.h
+++ b/erts/emulator/beam/export.h
@@ -71,6 +71,7 @@ Export* erts_export_get_or_make_stub(Eterm, Eterm, unsigned);
Export *export_list(int,ErtsCodeIndex);
int export_list_size(ErtsCodeIndex);
int export_table_sz(void);
+int export_entries_sz(void);
Export *export_get(Export*);
void export_start_staging(void);
void export_end_staging(int commit);