aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-10-01 18:12:43 +0200
committerSverker Eriksson <[email protected]>2013-10-02 17:00:23 +0200
commitff95e85937007a7952477c7acc7619791405ab1c (patch)
tree302db9f3c82085289c1c50b72b2a165175ff7482 /erts
parente9f670e542dd2ea2dc29dff66d3516a3fd0d2d21 (diff)
downloadotp-ff95e85937007a7952477c7acc7619791405ab1c.tar.gz
otp-ff95e85937007a7952477c7acc7619791405ab1c.tar.bz2
otp-ff95e85937007a7952477c7acc7619791405ab1c.zip
erts: Add mutex to init_atoms in erts_mmap.c
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_lock_check.c1
-rw-r--r--erts/emulator/sys/common/erl_mmap.c109
2 files changed, 60 insertions, 50 deletions
diff --git a/erts/emulator/beam/erl_lock_check.c b/erts/emulator/beam/erl_lock_check.c
index 87efbdbc3e..0dd83fa6ed 100644
--- a/erts/emulator/beam/erl_lock_check.c
+++ b/erts/emulator/beam/erl_lock_check.c
@@ -132,6 +132,7 @@ static erts_lc_lock_order_t erts_lock_order[] = {
#endif /* __WIN32__ */
{ "alcu_init_atoms", NULL },
{ "mseg_init_atoms", NULL },
+ { "mmap_init_atoms", NULL },
{ "drv_tsd", NULL },
{ "async_enq_mtx", NULL },
#ifdef ERTS_SMP
diff --git a/erts/emulator/sys/common/erl_mmap.c b/erts/emulator/sys/common/erl_mmap.c
index 52041fd03e..a9da7430fb 100644
--- a/erts/emulator/sys/common/erl_mmap.c
+++ b/erts/emulator/sys/common/erl_mmap.c
@@ -2039,6 +2039,64 @@ int erts_mmap_in_supercarrier(void *ptr)
return ERTS_MMAP_IN_SUPERCARRIER(ptr);
}
+
+static struct {
+ Eterm total;
+ Eterm total_sa;
+ Eterm total_sua;
+ Eterm used;
+ Eterm used_sa;
+ Eterm used_sua;
+ Eterm max;
+ Eterm allocated;
+ Eterm reserved;
+ Eterm sizes;
+ Eterm free_segs;
+ Eterm supercarrier;
+ Eterm os;
+ Eterm scs;
+ Eterm sco;
+ Eterm scrpm;
+ Eterm scmgc;
+
+ int is_initialized;
+ erts_mtx_t init_mutex;
+}am;
+
+static void ERTS_INLINE atom_init(Eterm *atom, char *name)
+{
+ *atom = am_atom_put(name, strlen(name));
+}
+#define AM_INIT(AM) atom_init(&am.AM, #AM)
+
+static void init_atoms(void)
+{
+ erts_mtx_lock(&am.init_mutex);
+
+ if (!am.is_initialized) {
+ AM_INIT(total);
+ AM_INIT(total_sa);
+ AM_INIT(total_sua);
+ AM_INIT(used);
+ AM_INIT(used_sa);
+ AM_INIT(used_sua);
+ AM_INIT(max);
+ AM_INIT(allocated);
+ AM_INIT(reserved);
+ AM_INIT(sizes);
+ AM_INIT(free_segs);
+ AM_INIT(supercarrier);
+ AM_INIT(os);
+ AM_INIT(scs);
+ AM_INIT(sco);
+ AM_INIT(scrpm);
+ AM_INIT(scmgc);
+ am.is_initialized = 1;
+ }
+ erts_mtx_unlock(&am.init_mutex);
+};
+
+
#ifdef HARD_DEBUG_MSEG
static void hard_dbg_mseg_init(void);
#endif
@@ -2085,6 +2143,7 @@ erts_mmap_init(ErtsMMapInit *init)
#endif
erts_smp_mtx_init(&mmap_state.mtx, "erts_mmap");
+ erts_mtx_init(&am.init_mutex, "mmap_init_atoms");
#ifdef ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION
if (init->virtual_range.start) {
@@ -2246,56 +2305,6 @@ erts_mmap_init(ErtsMMapInit *init)
#endif
}
-static struct {
- Eterm total;
- Eterm total_sa;
- Eterm total_sua;
- Eterm used;
- Eterm used_sa;
- Eterm used_sua;
- Eterm max;
- Eterm allocated;
- Eterm reserved;
- Eterm sizes;
- Eterm free_segs;
- Eterm supercarrier;
- Eterm os;
- Eterm scs;
- Eterm sco;
- Eterm scrpm;
- Eterm scmgc;
-
- int is_initialized;
-}am;
-
-static void ERTS_INLINE atom_init(Eterm *atom, char *name)
-{
- *atom = am_atom_put(name, strlen(name));
-}
-#define AM_INIT(AM) atom_init(&am.AM, #AM)
-
-static void init_atoms(void)
-{
- AM_INIT(total);
- AM_INIT(total_sa);
- AM_INIT(total_sua);
- AM_INIT(used);
- AM_INIT(used_sa);
- AM_INIT(used_sua);
- AM_INIT(max);
- AM_INIT(allocated);
- AM_INIT(reserved);
- AM_INIT(sizes);
- AM_INIT(free_segs);
- AM_INIT(supercarrier);
- AM_INIT(os);
- AM_INIT(scs);
- AM_INIT(sco);
- AM_INIT(scrpm);
- AM_INIT(scmgc);
- am.is_initialized = 1;
-};
-
static ERTS_INLINE void
add_2tup(Uint **hpp, Uint *szp, Eterm *lp, Eterm el1, Eterm el2)