LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0120-erts-Remove-hipe-amd64-code-super-carrier-exec_mmap.patch of Package erlang (Project home:Ledest:erlang:20)

From 8fd6e3353b094aa94e37e257ee20cd5e0e5dddcb Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Tue, 30 Jan 2018 22:19:00 +0100
Subject: [PATCH 2/3] erts: Remove hipe amd64 code super carrier (exec_mmap)

---
 erts/doc/src/erts_alloc.xml         | 16 +---------------
 erts/emulator/beam/erl_alloc.c      | 34 ++--------------------------------
 erts/emulator/beam/erl_alloc_util.c |  8 ++++----
 erts/emulator/beam/erl_alloc_util.h |  2 +-
 erts/emulator/sys/common/erl_mmap.c |  4 ----
 erts/emulator/sys/common/erl_mmap.h | 14 --------------
 erts/emulator/sys/common/erl_mseg.c |  6 ------
 erts/emulator/sys/common/erl_mseg.h |  2 --
 8 files changed, 8 insertions(+), 78 deletions(-)

diff --git a/erts/doc/src/erts_alloc.xml b/erts/doc/src/erts_alloc.xml
index 580780e73b..67c9f017ea 100644
--- a/erts/doc/src/erts_alloc.xml
+++ b/erts/doc/src/erts_alloc.xml
@@ -68,8 +68,7 @@
        fixed size data types.</item>
       <tag><c>exec_alloc</c></tag>
       <item>Allocator used by the <seealso marker="hipe:HiPE_app"><c>HiPE</c></seealso>
-        application for native executable code on specific architectures
-        (x86_64).</item>
+        application for native executable code.</item>
       <tag><c>std_alloc</c></tag>
       <item>Allocator used for most memory blocks not allocated through any of
         the other allocators described above.</item>
@@ -667,19 +666,6 @@
       </taglist>
     </section>
 
-    <section>
-      <title>Special Flag for exec_alloc</title>
-      <taglist>
-        <tag><marker id="MXscs"/><c><![CDATA[+MXscs <size in MB>]]></c></tag>
-        <item>
-          <p><c>exec_alloc</c> super carrier size (in MB). The amount of
-            <em>virtual</em> address space reserved for native executable code
-            used by the <seealso marker="hipe:HiPE_app"><c>HiPE</c></seealso> application
-            on specific architectures (x86_64). Defaults to <c>512</c>.</p>
-        </item>
-      </taglist>
-    </section>
-
     <section>
       <title>Instrumentation Flags</title>
       <taglist>
diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c
index 88285d8be6..f519dd49ef 100644
--- a/erts/emulator/beam/erl_alloc.c
+++ b/erts/emulator/beam/erl_alloc.c
@@ -366,16 +366,9 @@ set_default_exec_alloc_opts(struct au_init *ip)
     ip->init.util.rmbcmt	= 0;
     ip->init.util.acul		= 0;
 
-# ifdef ERTS_HAVE_EXEC_MMAPPER
-    ip->init.util.mseg_alloc    = &erts_alcu_mmapper_mseg_alloc;
-    ip->init.util.mseg_realloc  = &erts_alcu_mmapper_mseg_realloc;
-    ip->init.util.mseg_dealloc  = &erts_alcu_mmapper_mseg_dealloc;
-    ip->init.util.mseg_mmapper  = &erts_exec_mmapper;
-# else
     ip->init.util.mseg_alloc    = &erts_alcu_exec_mseg_alloc;
     ip->init.util.mseg_realloc  = &erts_alcu_exec_mseg_realloc;
     ip->init.util.mseg_dealloc  = &erts_alcu_exec_mseg_dealloc;
-# endif
 }
 #endif /* ERTS_ALC_A_EXEC */
 
@@ -1526,10 +1519,8 @@ handle_args(int *argc, char **argv, erts_alc_hndl_args_init_t *init)
 		    break;
                 case 'X':
                     if (has_prefix("scs", argv[i]+3)) {
-#ifdef ERTS_HAVE_EXEC_MMAPPER
-                        init->mseg.exec_mmap.scs =
-#endif
-                            get_mb_value(argv[i]+6, argv, &i);
+                        /* Ignore obsolete */
+                        (void) get_mb_value(argv[i]+6, argv, &i);
                     }
                     else
                         handle_au_arg(&init->exec_alloc, &argv[i][3], argv, &i, 0);
@@ -2790,10 +2781,6 @@ erts_allocator_info(fmtfn_t to, void *arg)
 #if defined(ARCH_64) && defined(ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION)
         erts_print(to, arg, "=allocator:erts_mmap.literal_mmap\n");
         erts_mmap_info(&erts_literal_mmapper, &to, arg, NULL, NULL, &emis);
-#endif
-#ifdef ERTS_HAVE_EXEC_MMAPPER
-        erts_print(to, arg, "=allocator:erts_mmap.exec_mmap\n");
-        erts_mmap_info(&erts_exec_mmapper, &to, arg, NULL, NULL, &emis);
 #endif
     }
 #endif
@@ -2948,9 +2935,6 @@ erts_allocator_options(void *proc)
 #endif
 #if defined(ARCH_64) && defined(ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION)
     terms[length++] = ERTS_MAKE_AM("literal_mmap");
-#endif
-#ifdef ERTS_HAVE_EXEC_MMAPPER
-    terms[length++] = ERTS_MAKE_AM("exec_mmap");
 #endif
     features = length ? erts_bld_list(hpp, szp, length, terms) : NIL;
 
@@ -3041,9 +3025,6 @@ reply_alloc_info(void *vair)
 # if defined(ARCH_64) && defined(ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION)
     struct erts_mmap_info_struct mmap_info_literal;
 # endif
-# ifdef ERTS_HAVE_EXEC_MMAPPER
-    struct erts_mmap_info_struct mmap_info_exec;
-# endif
 #endif
     int i;
     Eterm (*info_func)(Allctr_t *,
@@ -3172,17 +3153,6 @@ reply_alloc_info(void *vair)
                                             erts_bld_atom(hpp,szp,"literal_mmap"),
                                             ainfo);
 #  endif
-#  ifdef ERTS_HAVE_EXEC_MMAPPER
-                    ai_list = erts_bld_cons(hpp, szp,
-                                            ainfo, ai_list);
-                    ainfo = (air->only_sz ? NIL :
-                             erts_mmap_info(&erts_exec_mmapper, NULL, NULL,
-                                            hpp, szp, &mmap_info_exec));
-                    ainfo = erts_bld_tuple3(hpp, szp,
-                                            alloc_atom,
-                                            erts_bld_atom(hpp,szp,"exec_mmap"),
-                                            ainfo);
-#  endif
 #else  /* !HAVE_ERTS_MMAP */
                     ainfo = erts_bld_tuple2(hpp, szp, alloc_atom,
                                             am_false);
diff --git a/erts/emulator/beam/erl_alloc_util.c b/erts/emulator/beam/erl_alloc_util.c
index 4d4bddb93f..4acb07e19d 100644
--- a/erts/emulator/beam/erl_alloc_util.c
+++ b/erts/emulator/beam/erl_alloc_util.c
@@ -872,7 +872,7 @@ erts_alcu_literal_32_mseg_dealloc(Allctr_t *allctr, void *seg, Uint size,
 #elif defined(ARCH_64) && defined(ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION)
 
 /* For allocators that have their own mmapper (super carrier),
- * like literal_alloc and exec_alloc on amd64
+ * like literal_alloc.
  */
 void*
 erts_alcu_mmapper_mseg_alloc(Allctr_t *allctr, Uint *size_p, Uint flags)
@@ -914,10 +914,10 @@ erts_alcu_mmapper_mseg_dealloc(Allctr_t *allctr, void *seg, Uint size,
 }
 #endif /* ARCH_64 && ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION */
 
-#if defined(ERTS_ALC_A_EXEC) && !defined(ERTS_HAVE_EXEC_MMAPPER)
+#if defined(ERTS_ALC_A_EXEC)
 
 /*
- * For exec_alloc on non-amd64 that just need memory with PROT_EXEC
+ * For exec_alloc that need memory with PROT_EXEC
  */
 void*
 erts_alcu_exec_mseg_alloc(Allctr_t *allctr, Uint *size_p, Uint flags)
@@ -956,7 +956,7 @@ erts_alcu_exec_mseg_dealloc(Allctr_t *allctr, void *seg, Uint size, Uint flags)
     ASSERT(r == 0); (void)r;
     erts_alcu_mseg_dealloc(allctr, seg, size, flags);
 }
-#endif /* ERTS_ALC_A_EXEC && !ERTS_HAVE_EXEC_MMAPPER */
+#endif /* ERTS_ALC_A_EXEC */
 
 #endif /* HAVE_ERTS_MSEG */
 
diff --git a/erts/emulator/beam/erl_alloc_util.h b/erts/emulator/beam/erl_alloc_util.h
index faeb5ef368..31fc755803 100644
--- a/erts/emulator/beam/erl_alloc_util.h
+++ b/erts/emulator/beam/erl_alloc_util.h
@@ -199,7 +199,7 @@ void* erts_alcu_mmapper_mseg_realloc(Allctr_t*, void *seg, Uint old_size, Uint *
 void  erts_alcu_mmapper_mseg_dealloc(Allctr_t*, void *seg, Uint size, Uint flags);
 # endif
 
-# if defined(ERTS_ALC_A_EXEC) && !defined(ERTS_HAVE_EXEC_MMAPPER)
+# if defined(ERTS_ALC_A_EXEC)
 void* erts_alcu_exec_mseg_alloc(Allctr_t*, Uint *size_p, Uint flags);
 void* erts_alcu_exec_mseg_realloc(Allctr_t*, void *seg, Uint old_size, Uint *new_size_p);
 void  erts_alcu_exec_mseg_dealloc(Allctr_t*, void *seg, Uint size, Uint flags);
diff --git a/erts/emulator/sys/common/erl_mmap.c b/erts/emulator/sys/common/erl_mmap.c
index 95e6c6fbd0..90ade5265f 100644
--- a/erts/emulator/sys/common/erl_mmap.c
+++ b/erts/emulator/sys/common/erl_mmap.c
@@ -358,10 +358,6 @@ char* erts_literals_start;
 UWord erts_literals_size;
 #endif
 
-#ifdef ERTS_HAVE_EXEC_MMAPPER
-ErtsMemMapper erts_exec_mmapper;
-#endif
-
 
 #define ERTS_MMAP_SIZE_SC_SA_INC(SZ) 						\
     do {									\
diff --git a/erts/emulator/sys/common/erl_mmap.h b/erts/emulator/sys/common/erl_mmap.h
index 2a07d93c8c..efb12e7737 100644
--- a/erts/emulator/sys/common/erl_mmap.h
+++ b/erts/emulator/sys/common/erl_mmap.h
@@ -93,11 +93,6 @@ typedef struct {
 #define ERTS_MMAP_INIT_LITERAL_INITER \
     {{NULL, NULL}, {NULL, NULL}, ERTS_LITERAL_VIRTUAL_AREA_SIZE, 1, (1 << 10), 0}
 
-#define ERTS_HIPE_EXEC_VIRTUAL_AREA_SIZE (UWORD_CONSTANT(512)*1024*1024)
-
-#define ERTS_MMAP_INIT_HIPE_EXEC_INITER \
-    {{NULL, NULL}, {NULL, NULL}, ERTS_HIPE_EXEC_VIRTUAL_AREA_SIZE, 1, (1 << 10), 0}
-
 
 #define ERTS_SUPERALIGNED_SIZE \
     (1 << ERTS_MMAP_SUPERALIGNED_BITS)
@@ -165,15 +160,6 @@ extern ErtsMemMapper erts_dflt_mmapper;
 extern ErtsMemMapper erts_literal_mmapper;
 #  endif
 
-#  if defined(ERTS_ALC_A_EXEC) && defined(__x86_64__)
-   /*
-    * On x86_64, exec_alloc employs its own super carrier 'erts_exec_mmaper'
-    * to ensure low memory for HiPE AMD64 small code model.
-    */
-#   define ERTS_HAVE_EXEC_MMAPPER
-extern ErtsMemMapper erts_exec_mmapper;
-#  endif
-
 # endif /* ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION */
 #endif /* ERTS_WANT_MEM_MAPPERS */
 
diff --git a/erts/emulator/sys/common/erl_mseg.c b/erts/emulator/sys/common/erl_mseg.c
index bf6de9b13a..a782161a7c 100644
--- a/erts/emulator/sys/common/erl_mseg.c
+++ b/erts/emulator/sys/common/erl_mseg.c
@@ -1406,12 +1406,6 @@ erts_mseg_init(ErtsMsegInit_t *init)
     erts_mtx_init(&init_atoms_mutex, "mseg_init_atoms", NIL,
         ERTS_LOCK_FLAGS_PROPERTY_STATIC | ERTS_LOCK_FLAGS_CATEGORY_GENERIC);
 
-#ifdef ERTS_HAVE_EXEC_MMAPPER
-    /* Initialize erts_exec_mapper *FIRST*, to increase probability
-     * of getting low memory for HiPE AMD64's small code model.
-     */
-    erts_mmap_init(&erts_exec_mmapper, &init->exec_mmap, 1);
-#endif
     erts_mmap_init(&erts_dflt_mmapper, &init->dflt_mmap, 0);
 #if defined(ARCH_64) && defined(ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION)
     erts_mmap_init(&erts_literal_mmapper, &init->literal_mmap, 0);
diff --git a/erts/emulator/sys/common/erl_mseg.h b/erts/emulator/sys/common/erl_mseg.h
index bba0dec499..af275c18be 100644
--- a/erts/emulator/sys/common/erl_mseg.h
+++ b/erts/emulator/sys/common/erl_mseg.h
@@ -61,7 +61,6 @@ typedef struct {
     Uint nos;
     ErtsMMapInit dflt_mmap;
     ErtsMMapInit literal_mmap;
-    ErtsMMapInit exec_mmap;
 } ErtsMsegInit_t;
 
 #define ERTS_MSEG_INIT_DEFAULT_INITIALIZER				\
@@ -72,7 +71,6 @@ typedef struct {
     1000,		/* cci:   Cache check interval		*/	\
     ERTS_MMAP_INIT_DEFAULT_INITER,					\
     ERTS_MMAP_INIT_LITERAL_INITER,                                      \
-    ERTS_MMAP_INIT_HIPE_EXEC_INITER                                     \
 }
 
 typedef struct {
-- 
2.16.2