diff --git a/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h b/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h --- a/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h +++ b/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h @@ -39,7 +39,11 @@ # define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) #endif #ifdef __amd64__ +#ifdef _USE_LG_VADDR_WIDE +# define LG_VADDR 64 +#else # define LG_VADDR 48 +#endif # define LG_SIZEOF_PTR 3 # define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) #endif diff --git a/lib/libc/stdlib/malloc/jemalloc/Makefile.inc b/lib/libc/stdlib/malloc/jemalloc/Makefile.inc --- a/lib/libc/stdlib/malloc/jemalloc/Makefile.inc +++ b/lib/libc/stdlib/malloc/jemalloc/Makefile.inc @@ -5,6 +5,11 @@ test_hooks.c ticker.c tsd.c witness.c CFLAGS+=-I${SRCTOP}/contrib/jemalloc/include +.if ${LIBC_ARCH} == "amd64" +.if ${MK_LG_VADDR_WIDE} != no +CFLAGS+=-D_USE_LG_VADDR_WIDE +.endif +.endif .for src in ${JEMALLOCSRCS} MISRCS+=jemalloc_${src} diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -362,6 +362,10 @@ __DEFAULT_NO_OPTIONS+=OPENMP .endif +.if ${__T} == "amd64" +__DEFAULT_YES_OPTIONS+=LG_VADDR_WIDE +.endif + # Broken on 32-bit arm, kernel module compile errors .if ${__T:Marm*} != "" BROKEN_OPTIONS+= OFED diff --git a/tools/build/options/WITH_LG_VADDR_WIDE b/tools/build/options/WITH_LG_VADDR_WIDE new file mode 100644 --- /dev/null +++ b/tools/build/options/WITH_LG_VADDR_WIDE @@ -0,0 +1,4 @@ +Allow programs to use more than 48 address bits on amd64. +Required for LA57 mode. +Disabling this option might result in a slight reduction in memory +consumption for jemalloc metadata.