aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--HOWTO/INSTALL.md5
-rw-r--r--erts/configure.in19
-rw-r--r--erts/emulator/beam/erl_alloc.h4
-rw-r--r--erts/include/internal/ethread.h2
-rw-r--r--erts/include/internal/ethread_header_config.h.in2
5 files changed, 29 insertions, 3 deletions
diff --git a/HOWTO/INSTALL.md b/HOWTO/INSTALL.md
index c9f4062b83..fb18676699 100644
--- a/HOWTO/INSTALL.md
+++ b/HOWTO/INSTALL.md
@@ -274,6 +274,11 @@ Some of the available `configure` options are:
`(g)cc`
* `--enable-m32-build` - Build 32-bit binaries using the `-m32` flag to
`(g)cc`
+* `--with-assumed-cache-line-size=SIZE` - Set assumed cache-line size in
+ bytes. Default is 64. Valid values are powers of two between and
+ including 16 and 8192. The runtime system use this value in order to
+ try to avoid false sharing. A too large value wastes memory. A to
+ small value will increase the amount of false sharing.
* `--{with,without}-termcap` - termcap (without implies that only the old
Erlang shell can be used)
* `--with-javac=JAVAC` - Specify Java compiler to use
diff --git a/erts/configure.in b/erts/configure.in
index 51e2e99c88..46e5a15751 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -347,6 +347,25 @@ AS_HELP_STRING([--enable-clock-gettime],
*) clock_gettime_correction=yes ;;
esac ], clock_gettime_correction=unknown)
+AC_ARG_WITH(assumed-cache-line-size,
+AS_HELP_STRING([--with-assumed-cache-line-size=SIZE],
+ [specify assumed cache line size in bytes (valid values are powers of two between and including 16 and 8192; default is 64)]))
+
+dnl Require the assumed cache-line size to be a power of two between 16 and 8192
+case "$with_assumed_cache_line_size" in
+ ""|no|yes)
+ with_assumed_cache_line_size=64;;
+ 16|32|64|128|256|512|1024|2048|4096|8192)
+ ;;
+ *)
+ AC_MSG_ERROR([Invalid assumed cache-line size of $with_assumed_cache_line_size bytes])
+ ;;
+esac
+
+AC_DEFINE_UNQUOTED(ASSUMED_CACHE_LINE_SIZE,
+ $with_assumed_cache_line_size,
+ [Assumed cache-line size (in bytes)])
+
dnl Magic test for clearcase.
OTP_RELEASE=
if test "${ERLANG_COMMERCIAL_BUILD}" != ""; then
diff --git a/erts/emulator/beam/erl_alloc.h b/erts/emulator/beam/erl_alloc.h
index f83f6b39cf..942eaa47d0 100644
--- a/erts/emulator/beam/erl_alloc.h
+++ b/erts/emulator/beam/erl_alloc.h
@@ -209,8 +209,8 @@ int erts_is_allctr_wrapper_prelocked(void);
void *erts_alloc_permanent_cache_aligned(ErtsAlcType_t type, Uint size);
#ifndef ERTS_CACHE_LINE_SIZE
-/* Assume a cache line size of 64 bytes */
-# define ERTS_CACHE_LINE_SIZE ((UWord) 64)
+/* Assumed cache line size */
+# define ERTS_CACHE_LINE_SIZE ((UWord) ASSUMED_CACHE_LINE_SIZE)
# define ERTS_CACHE_LINE_MASK (ERTS_CACHE_LINE_SIZE - 1)
#endif
diff --git a/erts/include/internal/ethread.h b/erts/include/internal/ethread.h
index 38b8e9e9b6..3a676e2a36 100644
--- a/erts/include/internal/ethread.h
+++ b/erts/include/internal/ethread.h
@@ -60,7 +60,7 @@
#endif
/* Assume 64-byte cache line size */
-#define ETHR_CACHE_LINE_SIZE 64
+#define ETHR_CACHE_LINE_SIZE ASSUMED_CACHE_LINE_SIZE
#define ETHR_CACHE_LINE_MASK (ETHR_CACHE_LINE_SIZE - 1)
#define ETHR_CACHE_LINE_ALIGN_SIZE(SZ) \
diff --git a/erts/include/internal/ethread_header_config.h.in b/erts/include/internal/ethread_header_config.h.in
index dd3599f86d..b36322490a 100644
--- a/erts/include/internal/ethread_header_config.h.in
+++ b/erts/include/internal/ethread_header_config.h.in
@@ -235,3 +235,5 @@
/* Define if you want to turn on extra sanity checking in the ethread library */
#undef ETHR_XCHK
+/* Assumed cache-line size (in bytes) */
+#undef ASSUMED_CACHE_LINE_SIZE