The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c43cad87172039ccf38172129c79755ea79e6102

commit c43cad87172039ccf38172129c79755ea79e6102
Merge: da260ab23f26 48ec896efb0b
Author:     Warner Losh <i...@freebsd.org>
AuthorDate: 2025-08-11 23:38:36 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2025-08-15 21:48:34 +0000

    jemalloc: Merge from jemalloc 5.3.0 vendor branch
    
    This brings in a merge from jemalloc 5.3.0. It's almost fully scripted, 
except:
            Three conflicts resolved by hand:
            include/jemalloc/internal/test_hooks.h  Use the new name
            src/extent.c                            Use the new code
            src/jemalloc.c                          Use the new code since 
je_realloc has moved
    
    The script is recorded in FREEBSD-upgrade. The old script did svn
    commands that were basically a rebase of our changes. This update has a
    series of diff reduction changes before this.
    
    Note: I'd planned on fixing the above three conflicts with commits, but
    ran out of time when I did this work in January. I got discouraged when
    jemalloc was EOL'd and didn't pick this back up. I did the above by hand
    to get this into FreeBSD 15.0
    
    This work is a repeat of the work by Minsoo Choo who did all these
    changes and created a pull request. Given the importance of jemalloc, I
    audited these changes by redoing them in this series of commits (and
    with the script that was checked in). I did this to confince myself and
    anybody else in doubt that there was no supply chain attack. The diffs
    between this series of commits and Minsoo's work are minor (though the
    version skew makes adds some noise). Interested parties can independent
    audit each step, I hope. I've listed Minsoo as a co-author since without
    his pull request to test again, this wouldn't have been possible.
    
    Thanks to brooks@ for help with getting the jemalloc 3 ABI compat
    symbols right.
    
    Co-authored-by: Minsoo Choo <minsoochoo0...@proton.me>
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1337
    Sponsored by: Netflix

 contrib/jemalloc/ChangeLog                         |  100 +
 contrib/jemalloc/FREEBSD-upgrade                   |  254 +-
 contrib/jemalloc/INSTALL.md                        |  428 ++
 contrib/jemalloc/Makefile.in                       |  766 +++
 contrib/jemalloc/TUNING.md                         |  133 +
 contrib/jemalloc/VERSION                           |    2 +-
 contrib/jemalloc/bin/jeprof.in                     | 5727 ++++++++++++++++++++
 contrib/jemalloc/build-aux/config.guess            | 1705 ++++++
 contrib/jemalloc/build-aux/config.sub              | 1859 +++++++
 contrib/jemalloc/configure.ac                      | 2673 +++++++++
 contrib/jemalloc/doc/jemalloc.xml.in               | 3792 +++++++++++++
 .../jemalloc/doc_internal/PROFILING_INTERNALS.md   |  127 +
 contrib/jemalloc/doc_internal/jemalloc.svg         |    1 +
 .../include/jemalloc/internal/activity_callback.h  |   23 +
 .../include/jemalloc/internal/arena_externs.h      |   77 +-
 .../include/jemalloc/internal/arena_inlines_a.h    |   35 +-
 .../include/jemalloc/internal/arena_inlines_b.h    |  489 +-
 .../include/jemalloc/internal/arena_stats.h        |  227 +-
 .../include/jemalloc/internal/arena_structs.h      |  101 +
 .../include/jemalloc/internal/arena_structs_a.h    |   11 -
 .../include/jemalloc/internal/arena_structs_b.h    |  232 -
 .../include/jemalloc/internal/arena_types.h        |   23 +-
 .../jemalloc/include/jemalloc/internal/atomic.h    |   33 +-
 .../jemalloc/internal/background_thread_externs.h  |    7 +-
 .../jemalloc/internal/background_thread_inlines.h  |   14 -
 .../jemalloc/internal/background_thread_structs.h  |   12 +
 contrib/jemalloc/include/jemalloc/internal/base.h  |  110 +
 .../include/jemalloc/internal/base_externs.h       |   22 -
 .../include/jemalloc/internal/base_inlines.h       |   13 -
 .../include/jemalloc/internal/base_structs.h       |   59 -
 .../include/jemalloc/internal/base_types.h         |   33 -
 contrib/jemalloc/include/jemalloc/internal/bin.h   |   85 +-
 .../jemalloc/include/jemalloc/internal/bin_info.h  |   50 +
 .../jemalloc/include/jemalloc/internal/bin_stats.h |    5 +-
 .../jemalloc/include/jemalloc/internal/bin_types.h |    2 +-
 .../jemalloc/include/jemalloc/internal/bit_util.h  |  457 +-
 .../jemalloc/include/jemalloc/internal/bitmap.h    |   21 +-
 .../include/jemalloc/internal/buf_writer.h         |   32 +
 .../jemalloc/include/jemalloc/internal/cache_bin.h |  625 ++-
 .../jemalloc/include/jemalloc/internal/counter.h   |   34 +
 contrib/jemalloc/include/jemalloc/internal/ctl.h   |   31 +-
 contrib/jemalloc/include/jemalloc/internal/decay.h |  186 +
 .../jemalloc/include/jemalloc/internal/ecache.h    |   55 +
 contrib/jemalloc/include/jemalloc/internal/edata.h |  698 +++
 .../include/jemalloc/internal/edata_cache.h        |   49 +
 .../jemalloc/include/jemalloc/internal/ehooks.h    |  412 ++
 contrib/jemalloc/include/jemalloc/internal/emap.h  |  357 ++
 .../jemalloc/include/jemalloc/internal/emitter.h   |   74 +-
 contrib/jemalloc/include/jemalloc/internal/eset.h  |   77 +
 .../jemalloc/include/jemalloc/internal/exp_grow.h  |   50 +
 .../jemalloc/include/jemalloc/internal/extent.h    |  137 +
 .../include/jemalloc/internal/extent_externs.h     |   83 -
 .../include/jemalloc/internal/extent_inlines.h     |  501 --
 .../include/jemalloc/internal/extent_structs.h     |  256 -
 .../include/jemalloc/internal/extent_types.h       |   23 -
 contrib/jemalloc/include/jemalloc/internal/fb.h    |  373 ++
 contrib/jemalloc/include/jemalloc/internal/fxp.h   |  126 +
 contrib/jemalloc/include/jemalloc/internal/hash.h  |   63 +-
 contrib/jemalloc/include/jemalloc/internal/hpa.h   |  182 +
 .../jemalloc/include/jemalloc/internal/hpa_hooks.h |   17 +
 .../jemalloc/include/jemalloc/internal/hpa_opts.h  |   74 +
 .../jemalloc/include/jemalloc/internal/hpdata.h    |  413 ++
 .../jemalloc/include/jemalloc/internal/inspect.h   |   40 +
 .../jemalloc/internal/jemalloc_internal_decls.h    |   16 +-
 .../jemalloc/internal/jemalloc_internal_defs.h.in  |  431 ++
 .../jemalloc/internal/jemalloc_internal_externs.h  |   28 +-
 .../jemalloc/internal/jemalloc_internal_includes.h |   16 +-
 .../internal/jemalloc_internal_inlines_a.h         |   82 +-
 .../internal/jemalloc_internal_inlines_b.h         |   52 +-
 .../internal/jemalloc_internal_inlines_c.h         |  124 +-
 .../jemalloc/internal/jemalloc_internal_macros.h   |   13 +-
 .../jemalloc/internal/jemalloc_internal_types.h    |   28 +-
 .../jemalloc/internal/jemalloc_preamble.h.in       |  266 +
 .../include/jemalloc/internal/large_externs.h      |   26 +-
 .../jemalloc/include/jemalloc/internal/lockedint.h |  204 +
 .../jemalloc/include/jemalloc/internal/malloc_io.h |   11 +-
 .../include/jemalloc/internal/mpsc_queue.h         |  134 +
 contrib/jemalloc/include/jemalloc/internal/mutex.h |   63 +-
 .../include/jemalloc/internal/mutex_pool.h         |   94 -
 .../include/jemalloc/internal/mutex_prof.h         |   13 +-
 .../jemalloc/include/jemalloc/internal/nstime.h    |   43 +-
 contrib/jemalloc/include/jemalloc/internal/pa.h    |  243 +
 contrib/jemalloc/include/jemalloc/internal/pac.h   |  179 +
 contrib/jemalloc/include/jemalloc/internal/pages.h |   31 +
 contrib/jemalloc/include/jemalloc/internal/pai.h   |   95 +
 contrib/jemalloc/include/jemalloc/internal/peak.h  |   37 +
 .../include/jemalloc/internal/peak_event.h         |   24 +
 contrib/jemalloc/include/jemalloc/internal/ph.h    |  817 +--
 contrib/jemalloc/include/jemalloc/internal/prng.h  |   93 +-
 .../jemalloc/include/jemalloc/internal/prof_data.h |   37 +
 .../include/jemalloc/internal/prof_externs.h       |  116 +-
 .../jemalloc/include/jemalloc/internal/prof_hook.h |   21 +
 .../include/jemalloc/internal/prof_inlines.h       |  261 +
 .../include/jemalloc/internal/prof_inlines_a.h     |   85 -
 .../include/jemalloc/internal/prof_inlines_b.h     |  250 -
 .../jemalloc/include/jemalloc/internal/prof_log.h  |   22 +
 .../include/jemalloc/internal/prof_recent.h        |   23 +
 .../include/jemalloc/internal/prof_stats.h         |   17 +
 .../include/jemalloc/internal/prof_structs.h       |   47 +-
 .../jemalloc/include/jemalloc/internal/prof_sys.h  |   30 +
 .../include/jemalloc/internal/prof_types.h         |   37 +-
 contrib/jemalloc/include/jemalloc/internal/psset.h |  131 +
 contrib/jemalloc/include/jemalloc/internal/ql.h    |  129 +-
 contrib/jemalloc/include/jemalloc/internal/qr.h    |  130 +-
 .../jemalloc/include/jemalloc/internal/quantum.h   |   12 +-
 contrib/jemalloc/include/jemalloc/internal/rb.h    |  920 +++-
 contrib/jemalloc/include/jemalloc/internal/rtree.h |  520 +-
 .../jemalloc/include/jemalloc/internal/rtree_tsd.h |   24 +-
 .../include/jemalloc/internal/safety_check.h       |    7 +-
 contrib/jemalloc/include/jemalloc/internal/san.h   |  191 +
 .../jemalloc/include/jemalloc/internal/san_bump.h  |   52 +
 contrib/jemalloc/include/jemalloc/internal/sc.h    |   78 +-
 contrib/jemalloc/include/jemalloc/internal/sec.h   |  120 +
 .../jemalloc/include/jemalloc/internal/sec_opts.h  |   59 +
 .../jemalloc/include/jemalloc/internal/slab_data.h |   12 +
 contrib/jemalloc/include/jemalloc/internal/stats.h |   29 +-
 contrib/jemalloc/include/jemalloc/internal/sz.h    |   97 +-
 .../include/jemalloc/internal/tcache_externs.h     |   60 +-
 .../include/jemalloc/internal/tcache_inlines.h     |  156 +-
 .../include/jemalloc/internal/tcache_structs.h     |   62 +-
 .../include/jemalloc/internal/tcache_types.h       |   40 +-
 .../include/jemalloc/internal/test_hooks.h         |   16 +-
 .../include/jemalloc/internal/thread_event.h       |  301 +
 .../jemalloc/include/jemalloc/internal/ticker.h    |   92 +-
 contrib/jemalloc/include/jemalloc/internal/tsd.h   |  243 +-
 .../include/jemalloc/internal/tsd_generic.h        |   23 +-
 .../jemalloc/internal/tsd_malloc_thread_cleanup.h  |    2 +-
 .../jemalloc/include/jemalloc/internal/tsd_types.h |    2 +-
 .../jemalloc/include/jemalloc/internal/tsd_win.h   |  143 +
 .../include/jemalloc/internal/typed_list.h         |   55 +
 contrib/jemalloc/include/jemalloc/internal/util.h  |   56 +
 .../jemalloc/include/jemalloc/internal/witness.h   |  183 +-
 .../jemalloc/include/jemalloc/jemalloc_defs.h.in   |   58 +
 .../jemalloc/include/jemalloc/jemalloc_macros.h.in |  153 +
 .../jemalloc/include/jemalloc/jemalloc_protos.h.in |   75 +
 contrib/jemalloc/m4/ax_cxx_compile_stdcxx.m4       |  955 ++++
 contrib/jemalloc/scripts/check-formatting.sh       |   28 +
 contrib/jemalloc/scripts/freebsd/before_install.sh |    3 +
 contrib/jemalloc/scripts/freebsd/before_script.sh  |   10 +
 contrib/jemalloc/scripts/freebsd/script.sh         |    3 +
 contrib/jemalloc/scripts/gen_run_tests.py          |  134 +
 contrib/jemalloc/scripts/gen_travis.py             |  331 ++
 contrib/jemalloc/scripts/linux/before_install.sh   |   13 +
 contrib/jemalloc/scripts/windows/before_install.sh |   83 +
 contrib/jemalloc/scripts/windows/before_script.sh  |   20 +
 contrib/jemalloc/scripts/windows/script.sh         |   10 +
 contrib/jemalloc/src/arena.c                       | 2063 +++----
 contrib/jemalloc/src/background_thread.c           |  335 +-
 contrib/jemalloc/src/base.c                        |  193 +-
 contrib/jemalloc/src/bin.c                         |   30 +-
 contrib/jemalloc/src/bin_info.c                    |   30 +
 contrib/jemalloc/src/bitmap.c                      |    1 -
 contrib/jemalloc/src/buf_writer.c                  |  144 +
 contrib/jemalloc/src/cache_bin.c                   |   99 +
 contrib/jemalloc/src/ckh.c                         |    7 +-
 contrib/jemalloc/src/counter.c                     |   30 +
 contrib/jemalloc/src/ctl.c                         | 1691 ++++--
 contrib/jemalloc/src/decay.c                       |  295 +
 contrib/jemalloc/src/ecache.c                      |   35 +
 contrib/jemalloc/src/edata.c                       |    6 +
 contrib/jemalloc/src/edata_cache.c                 |  154 +
 contrib/jemalloc/src/ehooks.c                      |  275 +
 contrib/jemalloc/src/emap.c                        |  386 ++
 contrib/jemalloc/src/eset.c                        |  282 +
 contrib/jemalloc/src/exp_grow.c                    |    8 +
 contrib/jemalloc/src/extent.c                      | 2488 +++------
 contrib/jemalloc/src/extent_dss.c                  |   42 +-
 contrib/jemalloc/src/extent_mmap.c                 |    1 -
 contrib/jemalloc/src/fxp.c                         |  124 +
 contrib/jemalloc/src/hash.c                        |    3 -
 contrib/jemalloc/src/hook.c                        |    6 +-
 contrib/jemalloc/src/hpa.c                         | 1044 ++++
 contrib/jemalloc/src/hpa_hooks.c                   |   63 +
 contrib/jemalloc/src/hpdata.c                      |  325 ++
 contrib/jemalloc/src/inspect.c                     |   77 +
 contrib/jemalloc/src/jemalloc.c                    | 2155 +++++---
 contrib/jemalloc/src/jemalloc_cpp.cpp              |  258 +
 contrib/jemalloc/src/large.c                       |  299 +-
 contrib/jemalloc/src/malloc_io.c                   |   46 +-
 contrib/jemalloc/src/mutex.c                       |   19 +-
 contrib/jemalloc/src/mutex_pool.c                  |   18 -
 contrib/jemalloc/src/nstime.c                      |  127 +-
 contrib/jemalloc/src/pa.c                          |  277 +
 contrib/jemalloc/src/pa_extra.c                    |  191 +
 contrib/jemalloc/src/pac.c                         |  587 ++
 contrib/jemalloc/src/pages.c                       |  209 +-
 contrib/jemalloc/src/pai.c                         |   31 +
 contrib/jemalloc/src/peak_event.c                  |   82 +
 contrib/jemalloc/src/prng.c                        |    3 -
 contrib/jemalloc/src/prof.c                        | 3189 ++---------
 contrib/jemalloc/src/prof_data.c                   | 1447 +++++
 contrib/jemalloc/src/prof_log.c                    |  717 +++
 contrib/jemalloc/src/prof_recent.c                 |  600 ++
 contrib/jemalloc/src/prof_stats.c                  |   57 +
 contrib/jemalloc/src/prof_sys.c                    |  669 +++
 contrib/jemalloc/src/psset.c                       |  385 ++
 contrib/jemalloc/src/rtree.c                       |   75 +-
 contrib/jemalloc/src/safety_check.c                |   16 +-
 contrib/jemalloc/src/san.c                         |  208 +
 contrib/jemalloc/src/san_bump.c                    |  104 +
 contrib/jemalloc/src/sc.c                          |   17 +-
 contrib/jemalloc/src/sec.c                         |  422 ++
 contrib/jemalloc/src/stats.c                       |  794 ++-
 contrib/jemalloc/src/sz.c                          |   52 +-
 contrib/jemalloc/src/tcache.c                      | 1137 ++--
 contrib/jemalloc/src/thread_event.c                |  343 ++
 contrib/jemalloc/src/ticker.c                      |   31 +-
 contrib/jemalloc/src/ticker.py                     |   15 +
 contrib/jemalloc/src/tsd.c                         |   75 +-
 contrib/jemalloc/src/witness.c                     |   44 +-
 lib/libc/stdlib/malloc/jemalloc/Makefile.inc       |   12 +-
 .../jemalloc/internal/jemalloc_internal_defs.h     |   91 +-
 .../include/jemalloc/internal/jemalloc_preamble.h  |   54 +-
 .../include/jemalloc/internal/private_namespace.h  |  481 +-
 .../include/jemalloc/internal/public_namespace.h   |    4 +-
 .../malloc/jemalloc/include/jemalloc/jemalloc.h    |   69 +-
 .../jemalloc/include/jemalloc/jemalloc_FreeBSD.h   |   10 +-
 .../jemalloc/include/jemalloc/jemalloc_defs.h      |   55 +
 218 files changed, 47956 insertions(+), 12362 deletions(-)

diff --cc contrib/jemalloc/FREEBSD-upgrade
index d3173b9d1f36,000000000000..fcb66ea71786
mode 100755,000000..100755
--- a/contrib/jemalloc/FREEBSD-upgrade
+++ b/contrib/jemalloc/FREEBSD-upgrade
@@@ -1,189 -1,0 +1,91 @@@
 +#!/bin/sh
- #
- # Usage: cd /usr/src/contrib/jemalloc
- #        ./FREEBSD-upgrade <command> [args]
- #
- # At least the following ports are required when importing jemalloc:
- # - devel/autoconf
- # - devel/git
- # - devel/gmake
- # - textproc/docbook-xsl
- # - textproc/libxslt
- #
- # The normal workflow for importing a new release is:
- #
- #   cd /usr/src/contrib/jemalloc
- #
- # Merge local changes that were made since the previous import:
- #
- #   ./FREEBSD-upgrade merge-changes
- #   ./FREEBSD-upgrade rediff
- #
- # Extract latest jemalloc release.
- #
- #   ./FREEBSD-upgrade extract <rev>
- #
- # Fix patch conflicts as necessary, then regenerate diffs to update line
- # offsets:
- #
- #   ./FREEBSD-upgrade rediff
- #   ./FREEBSD-upgrade extract <rev>
- #
- # Do multiple buildworld/installworld rounds.  If problems arise and patches
- # are needed, edit the code in ${work} as necessary, then:
- #
- #   ./FREEBSD-upgrade rediff
- #   ./FREEBSD-upgrade extract <rev>
- #
- # The rediff/extract order is important because rediff saves the local
- # changes, then extract blows away the work tree and re-creates it with the
- # diffs applied.
- #
- # Finally, to clean up:
- #
- #  ./FREEBSD-upgrade clean
 +
- set -e
- set -x
++# Note: you need docbook installed, as well as gmake (we need it to
++# make private_namespace.h)
 +
- if [ ! -x "FREEBSD-upgrade" ] ; then
-   echo "Run from within src/contrib/jemalloc/" >&2
-   exit 1
- fi
++# git subtree merge -- not committed at this time.
++ git subtree merge -P contrib/jemalloc vendor/jemalloc
++cd contrib/jemalloc
 +
- if [ "x${JEMALLOC_REPO}" = "x" ] ; then
-   JEMALLOC_REPO=https://github.com/jemalloc/jemalloc.git
- fi
++# Gut the tests, since they take up too much space.
++# Everything else can stay, but if not, add more to trim (there's
++# always a trade off between time and saved size.
++git rm -rf test msvc
++git commit --amend
 +
- src=`pwd`
++# kill the tests with empty files so we don't have to hack configure.ac
++mkdir -p test/include/test
++touch test/include/test/jemalloc_test_defs.h.in
++touch test/include/test/jemalloc_test.h.in
++echo 'exit 0' > test/test.sh.in
 +
- jemalloc_tmp="jemalloc.tmp"
- tmpdir="${src}/../${jemalloc_tmp}"
- bare_repo="${tmpdir}/jemalloc_bare.git"
- work="jemalloc_work.git"
- work_repo="${tmpdir}/${work}"
- namespace_repo="${tmpdir}/jemalloc_namespace.git"
- changes="${src}/FREEBSD-changes"
- 
- do_fetch() {
-   local rev=$1
-   if [ ! -d "${bare_repo}" ] ; then
-     mkdir -p "${bare_repo}"
-     git clone --bare ${JEMALLOC_REPO} ${bare_repo}
-   fi
-   (
-     cd ${bare_repo}
-     git fetch origin ${rev}
-   )
- }
++# Reconfigure -- needed only to regenerate the .h files... We don't
++# use all the files generated.
++#
++# Also note: 5.2 lacks --with-lg-page-sizes, but 5.3 has it.
++# Also, there's got to be a way to not hard-wire version / hash.
++./autogen.sh --enable-xmalloc --enable-fill --enable-lazy-lock --enable-stats 
\
++           --enable-utrace --with-malloc-conf=abort_conf:false \
++           --with-xslroot=/usr/local/share/xsl/docbook 
--with-private-namespace=__ \
++           --with-lg-page-sizes=12,13,14,15,16 \
++           --with-version=5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c
 +
- do_extract_helper() {
-   local rev=$1
-   local repo=$2
-   do_fetch ${rev}
-   rm -rf ${repo}
-   git clone ${bare_repo} ${repo}
-   (
-     cd ${repo}
-     if [ "x${rev}" != "x" ] ; then
-       # Use optional rev argument to check out a revision other than HEAD on
-       # master.
-       git checkout ${rev}
-     fi
-   )
- }
++# Copy over the important generated .h files in configure
++cp ./include/jemalloc/jemalloc.h 
../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc
++git add ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h
++cp ./include/jemalloc/jemalloc_defs.h 
../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc
++git add ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_defs.h
 +
- do_autogen() {
-   ./autogen.sh --enable-xmalloc --enable-utrace \
-     --with-malloc-conf=abort_conf:false \
-     --with-xslroot=/usr/local/share/xsl/docbook --with-private-namespace=__ \
-     --with-lg-page-sizes=12,13,14,16
- }
++# need to make the namespace .h files, and copy a small subset into the tree
++# These are super-awkward to generate at buildworld time. Also, we assume we
++# only have to make one of these (currently true due to current unlikely to
++# change dependencies.
++gmake include/jemalloc/internal/private_namespace.h
++for i in private_namespace.h jemalloc_internal_defs.h public_namespace.h 
jemalloc_preamble.h; do
++    cp include/jemalloc/internal/$i 
../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/
++    git add ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/$i
++    rm include/jemalloc/internal/$i
++done
++# OK, commit all the generated files
++git add VERSION
++git commit --amend
 +
- do_extract_diff() {
-   local rev=$1
-   local repo=$2
-   do_extract_helper ${rev} ${repo}
-   (
-     cd ${repo}
-     # Apply diffs before generating files.
-     patch -p1 < "${src}/FREEBSD-diffs"
-     find . -name '*.orig' -delete
-     # Generate files.
-     do_autogen
-     gmake dist
-   )
- }
++# Clean up the mess
++git clean -f .
 +
- do_extract_namespace() {
-   local rev=$1
-   local repo=$2
-   do_extract_helper ${rev} ${repo}
-   (
-     cd ${repo}
-     # Generate files.
-     do_autogen
-     gmake include/jemalloc/internal/private_namespace.h
-   )
- }
++# Save the cheat sheet
++cp ~/jemalloc-upd FREEBSD-upgrade
++git add FREEBSD-upgrade
++git commit --amend
 +
- do_extract() {
-   local rev=$1
-   do_fetch ${rev}
-   do_extract_diff ${rev} ${work_repo}
-   do_extract_namespace ${rev} ${namespace_repo}
- }
++# Remove hash.c from lib/libc/stdlib/malloc/jemalloc/Makefile.inc
++# mutex_pool.c prng.c
++# Add
++# bin_info.c san.c san_bump.c counter.c prof_data.c prof_log.c prof_recent.c 
prof_stats.c prof_sys.c
++# emap.c edata.c edata_cache.c pa.c pa_extra.c pac.c decay.c hpa.c 
hpa_hooks.c fxp.c hpdata.c pai.c
++# ecache.c ehooks.c eset.c sec.c cache_bin.c peak_event.c psset.c inspect.c 
exp_grow.c thread_event.c
++#
 +
- do_diff() {
-   (
-     cd ${work_repo}
-     find . -name '*.orig' -delete
-     find . -name '*.rej' -delete
-     git add -A
-     git diff --cached
-   ) > FREEBSD-diffs
- }
++# Manually comment out the following in 
lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h
++# /* #define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */
++# Add
++# #define JEMALLOC_OVERRIDE_VALLOC
++# and #include "jemalloc_FreeBSD.h"
++# With some adjustments to the old jemalloc_FreeBSD.h, but git can help
 +
- command=$1
- shift
- case "${command}" in
-   merge-changes) # Merge local changes that were made since the previous 
import.
-     rev=`cat VERSION |tr 'g' ' ' |awk '{print $2}'`
-     # Extract code corresponding to most recent import.
-     do_extract ${rev}
-     # Compute local differences to the upstream+patches and apply them.
-     (
-       cd ${tmpdir}
-       diff -ru -X ${src}/FREEBSD-Xlist ${work} ../jemalloc > ${changes} || 
true
-     )
-     (
-       cd ${work_repo}
-       patch -p1 < ${changes} || true
-       find . -name '*.orig' -delete
-     )
-     # Update diff.
-     do_diff
-     ;;
-   extract) # Extract upstream sources, apply patches, copy to 
contrib/jemalloc.
-     rev=$1
-     do_extract ${rev}
-     # Delete existing files so that cruft doesn't silently remain.
-     rm -rf ChangeLog COPYING VERSION doc include src
-     # Copy files over.
-     tar cf - -C ${work_repo} -X FREEBSD-Xlist . |tar xvf -
-     internal_dir="include/jemalloc/internal"
-     grep -v ' isthreaded ' \
-       "${namespace_repo}/${internal_dir}/private_namespace.h" \
-       > "${internal_dir}/private_namespace.h"
-     ;;
-   rediff) # Regenerate diffs based on working tree.
-     do_diff
-     ;;
-   clean) # Remove working tree and temporary files.
-     rm -rf ${tmpdir} ${changes}
-     ;;
-   *)
-     echo "Unsupported command: \"${command}\"" >&2
-     exit 1
-     ;;
- esac
++# Had to manually remove
++# -#define __malloc_options_1_0 JEMALLOC_N(__malloc_options_1_0)
++# -#define _malloc_first_thread JEMALLOC_N(_malloc_first_thread)
++# -#define __malloc_message_1_0 JEMALLOC_N(__malloc_message_1_0)
++# -#define isthreaded JEMALLOC_N(isthreaded)
++#
++# Also had to remove the following to fix jemalloc 3 ABI compat
++# -#define je_allocm JEMALLOC_N(je_allocm)
++# -#define je_dallocm JEMALLOC_N(je_dallocm)
++# -#define je_nallocm JEMALLOC_N(je_nallocm)
++# -#define je_rallocm JEMALLOC_N(je_rallocm)
++# -#define je_sallocm JEMALLOC_N(je_sallocm)
++# Without the diff you end up with non-exported _je_je*allocm symbols. With 
you get symbols of the form:
++#  365: 000000000018e2a0   406 FUNC    WEAK   DEFAULT   14 rallocm@FBSD_1.3 
(5)
++#  657: 000000000018e2a0   406 FUNC    GLOBAL DEFAULT   14 __rallocm@FBSD_1.3 
(5)
++#
diff --cc contrib/jemalloc/INSTALL.md
index b8f729b0d790,000000000000..9701364041c8
mode 100644,000000..100644
--- a/contrib/jemalloc/INSTALL.md
+++ b/contrib/jemalloc/INSTALL.md
@@@ -1,421 -1,0 +1,849 @@@
++<<<<<<< HEAD
++Building and installing a packaged release of jemalloc can be as simple as
++typing the following while in the root directory of the source tree:
++
++    ./configure
++    make
++    make install
++
++If building from unpackaged developer sources, the simplest command sequence
++that might work is:
++
++    ./autogen.sh
++    make
++    make install
++
++You can uninstall the installed build artifacts like this:
++
++    make uninstall
++
++Notes:
++ - "autoconf" needs to be installed
++ - Documentation is built by the default target only when xsltproc is
++available.  Build will warn but not stop if the dependency is missing.
++
++
++## Advanced configuration
++
++The 'configure' script supports numerous options that allow control of which
++functionality is enabled, where jemalloc is installed, etc.  Optionally, pass
++any of the following arguments (not a definitive list) to 'configure':
++
++* `--help`
++
++    Print a definitive list of options.
++
++* `--prefix=<install-root-dir>`
++
++    Set the base directory in which to install.  For example:
++
++        ./configure --prefix=/usr/local
++
++    will cause files to be installed into /usr/local/include, /usr/local/lib,
++    and /usr/local/man.
++
++* `--with-version=(<major>.<minor>.<bugfix>-<nrev>-g<gid>|VERSION)`
++
++    The VERSION file is mandatory for successful configuration, and the
++    following steps are taken to assure its presence:
++    1) If --with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid> is specified,
++       generate VERSION using the specified value.
++    2) If --with-version is not specified in either form and the source
++       directory is inside a git repository, try to generate VERSION via 'git
++       describe' invocations that pattern-match release tags.
++    3) If VERSION is missing, generate it with a bogus version:
++       0.0.0-0-g0000000000000000000000000000000000000000
++
++    Note that --with-version=VERSION bypasses (1) and (2), which simplifies
++    VERSION configuration when embedding a jemalloc release into another
++    project's git repository.
++
++* `--with-rpath=<colon-separated-rpath>`
++
++    Embed one or more library paths, so that libjemalloc can find the 
libraries
++    it is linked to.  This works only on ELF-based systems.
++
++* `--with-mangling=<map>`
++
++    Mangle public symbols specified in <map> which is a comma-separated list 
of
++    name:mangled pairs.
++
++    For example, to use ld's --wrap option as an alternative method for
++    overriding libc's malloc implementation, specify something like:
++
++      --with-mangling=malloc:__wrap_malloc,free:__wrap_free[...]
++
++    Note that mangling happens prior to application of the prefix specified by
++    --with-jemalloc-prefix, and mangled symbols are then ignored when applying
++    the prefix.
++
++* `--with-jemalloc-prefix=<prefix>`
++
++    Prefix all public APIs with <prefix>.  For example, if <prefix> is
++    "prefix_", API changes like the following occur:
++
++      malloc()         --> prefix_malloc()
++      malloc_conf      --> prefix_malloc_conf
++      /etc/malloc.conf --> /etc/prefix_malloc.conf
++      MALLOC_CONF      --> PREFIX_MALLOC_CONF
++
++    This makes it possible to use jemalloc at the same time as the system
++    allocator, or even to use multiple copies of jemalloc simultaneously.
++
++    By default, the prefix is "", except on OS X, where it is "je_".  On OS X,
++    jemalloc overlays the default malloc zone, but makes no attempt to 
actually
++    replace the "malloc", "calloc", etc. symbols.
++
++* `--without-export`
++
++    Don't export public APIs.  This can be useful when building jemalloc as a
++    static library, or to avoid exporting public APIs when using the zone
++    allocator on OSX.
++
++* `--with-private-namespace=<prefix>`
++
++    Prefix all library-private APIs with <prefix>je_.  For shared libraries,
++    symbol visibility mechanisms prevent these symbols from being exported, 
but
++    for static libraries, naming collisions are a real possibility.  By
++    default, <prefix> is empty, which results in a symbol prefix of je_ .
++
++* `--with-install-suffix=<suffix>`
++
++    Append <suffix> to the base name of all installed files, such that 
multiple
++    versions of jemalloc can coexist in the same installation directory.  For
++    example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
++
++* `--with-malloc-conf=<malloc_conf>`
++
++    Embed `<malloc_conf>` as a run-time options string that is processed 
prior to
++    the malloc_conf global variable, the /etc/malloc.conf symlink, and the
++    MALLOC_CONF environment variable.  For example, to change the default 
decay
++    time to 30 seconds:
++
++      --with-malloc-conf=decay_ms:30000
++
++* `--enable-debug`
++
++    Enable assertions and validation code.  This incurs a substantial
++    performance hit, but is very useful during application development.
++
++* `--disable-stats`
++
++    Disable statistics gathering functionality.  See the "opt.stats_print"
++    option documentation for usage details.
++
++* `--enable-prof`
++
++    Enable heap profiling and leak detection functionality.  See the 
"opt.prof"
++    option documentation for usage details.  When enabled, there are several
++    approaches to backtracing, and the configure script chooses the first one
++    in the following list that appears to function correctly:
++
++    + libunwind      (requires --enable-prof-libunwind)
++    + libgcc         (unless --disable-prof-libgcc)
++    + gcc intrinsics (unless --disable-prof-gcc)
++
++* `--enable-prof-libunwind`
++
++    Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
++    backtracing.
++
++* `--disable-prof-libgcc`
++
++    Disable the use of libgcc's backtracing functionality.
++
++* `--disable-prof-gcc`
++
++    Disable the use of gcc intrinsics for backtracing.
++
++* `--with-static-libunwind=<libunwind.a>`
++
++    Statically link against the specified libunwind.a rather than dynamically
++    linking with -lunwind.
++
++* `--disable-fill`
++
++    Disable support for junk/zero filling of memory.  See the "opt.junk" and
++    "opt.zero" option documentation for usage details.
++
++* `--disable-zone-allocator`
++
++    Disable zone allocator for Darwin.  This means jemalloc won't be hooked as
++    the default allocator on OSX/iOS.
++
++* `--enable-utrace`
++
++    Enable utrace(2)-based allocation tracing.  This feature is not broadly
++    portable (FreeBSD has it, but Linux and OS X do not).
++
++* `--enable-xmalloc`
++
++    Enable support for optional immediate termination due to out-of-memory
++    errors, as is commonly implemented by "xmalloc" wrapper function for 
malloc.
++    See the "opt.xmalloc" option documentation for usage details.
++
++* `--enable-lazy-lock`
++
++    Enable code that wraps pthread_create() to detect when an application
++    switches from single-threaded to multi-threaded mode, so that it can avoid
++    mutex locking/unlocking operations while in single-threaded mode.  In
++    practice, this feature usually has little impact on performance unless
++    thread-specific caching is disabled.
++
++* `--disable-cache-oblivious`
++
++    Disable cache-oblivious large allocation alignment by default, for large
++    allocation requests with no alignment constraints.  If this feature is
++    disabled, all large allocations are page-aligned as an implementation
++    artifact, which can severely harm CPU cache utilization.  However, the
++    cache-oblivious layout comes at the cost of one extra page per large
++    allocation, which in the most extreme case increases physical memory usage
++    for the 16 KiB size class to 20 KiB.
++
++* `--disable-syscall`
++
++    Disable use of syscall(2) rather than {open,read,write,close}(2).  This is
++    intended as a workaround for systems that place security limitations on
++    syscall(2).
++
++* `--disable-cxx`
++
++    Disable C++ integration.  This will cause new and delete operator
++    implementations to be omitted.
++
++* `--with-xslroot=<path>`
++
++    Specify where to find DocBook XSL stylesheets when building the
++    documentation.
++
++* `--with-lg-page=<lg-page>`
++
++    Specify the base 2 log of the allocator page size, which must in turn be 
at
++    least as large as the system page size.  By default the configure script
++    determines the host's page size and sets the allocator page size equal to
++    the system page size, so this option need not be specified unless the
++    system page size may change between configuration and execution, e.g. when
++    cross compiling.
++
++* `--with-lg-hugepage=<lg-hugepage>`
++
++    Specify the base 2 log of the system huge page size.  This option is 
useful
++    when cross compiling, or when overriding the default for systems that do
++    not explicitly support huge pages.
++
++* `--with-lg-quantum=<lg-quantum>`
++
++    Specify the base 2 log of the minimum allocation alignment.  jemalloc 
needs
++    to know the minimum alignment that meets the following C standard
++    requirement (quoted from the April 12, 2011 draft of the C11 standard):
++
++    >  The pointer returned if the allocation succeeds is suitably aligned so
++      that it may be assigned to a pointer to any type of object with a
++      fundamental alignment requirement and then used to access such an object
++      or an array of such objects in the space allocated [...]
++
++    This setting is architecture-specific, and although jemalloc includes 
known
++    safe values for the most commonly used modern architectures, there is a
++    wrinkle related to GNU libc (glibc) that may impact your choice of
++    <lg-quantum>.  On most modern architectures, this mandates 16-byte
++    alignment (<lg-quantum>=4), but the glibc developers chose not to meet 
this
++    requirement for performance reasons.  An old discussion can be found at
++    <https://sourceware.org/bugzilla/show_bug.cgi?id=206> .  Unlike glibc,
++    jemalloc does follow the C standard by default (caveat: jemalloc
++    technically cheats for size classes smaller than the quantum), but the 
fact
++    that Linux systems already work around this allocator noncompliance means
++    that it is generally safe in practice to let jemalloc's minimum alignment
++    follow glibc's lead.  If you specify `--with-lg-quantum=3` during
++    configuration, jemalloc will provide additional size classes that are not
++    16-byte-aligned (24, 40, and 56).
++
++* `--with-lg-vaddr=<lg-vaddr>`
++
++    Specify the number of significant virtual address bits.  By default, the
++    configure script attempts to detect virtual address size on those 
platforms
++    where it knows how, and picks a default otherwise.  This option may be
++    useful when cross-compiling.
++
++* `--disable-initial-exec-tls`
++
++    Disable the initial-exec TLS model for jemalloc's internal thread-local
++    storage (on those platforms that support explicit settings).  This can 
allow
++    jemalloc to be dynamically loaded after program startup (e.g. using 
dlopen).
++    Note that in this case, there will be two malloc implementations operating
++    in the same process, which will almost certainly result in confusing 
runtime
++    crashes if pointers leak from one implementation to the other.
++
++* `--disable-libdl`
++
++    Disable the usage of libdl, namely dlsym(3) which is required by the lazy
++    lock option.  This can allow building static binaries.
++
++The following environment variables (not a definitive list) impact configure's
++behavior:
++
++* `CFLAGS="?"`
++* `CXXFLAGS="?"`
++
++    Pass these flags to the C/C++ compiler.  Any flags set by the configure
++    script are prepended, which means explicitly set flags generally take
++    precedence.  Take care when specifying flags such as -Werror, because
++    configure tests may be affected in undesirable ways.
++
++* `EXTRA_CFLAGS="?"`
++* `EXTRA_CXXFLAGS="?"`
++
++    Append these flags to CFLAGS/CXXFLAGS, without passing them to the
++    compiler(s) during configuration.  This makes it possible to add flags 
such
++    as -Werror, while allowing the configure script to determine what other
++    flags are appropriate for the specified configuration.
++
++* `CPPFLAGS="?"`
++
++    Pass these flags to the C preprocessor.  Note that CFLAGS is not passed to
++    'cpp' when 'configure' is looking for include files, so you must use
++    CPPFLAGS instead if you need to help 'configure' find header files.
++
++* `LD_LIBRARY_PATH="?"`
++
++    'ld' uses this colon-separated list to find libraries.
++
++* `LDFLAGS="?"`
++
++    Pass these flags when linking.
++
++* `PATH="?"`
++
++    'configure' uses this to find programs.
++
++In some cases it may be necessary to work around configuration results that do
++not match reality.  For example, Linux 4.5 added support for the MADV_FREE 
flag
++to madvise(2), which can cause problems if building on a host with MADV_FREE
++support and deploying to a target without.  To work around this, use a cache
++file to override the relevant configuration variable defined in configure.ac,
++e.g.:
++
++    echo "je_cv_madv_free=no" > config.cache && ./configure -C
++
++
++## Advanced compilation
++
++To build only parts of jemalloc, use the following targets:
++
++    build_lib_shared
++    build_lib_static
++    build_lib
++    build_doc_html
++    build_doc_man
++    build_doc
++
++To install only parts of jemalloc, use the following targets:
++
++    install_bin
++    install_include
++    install_lib_shared
++    install_lib_static
++    install_lib_pc
++    install_lib
++    install_doc_html
++    install_doc_man
++    install_doc
++
++To clean up build results to varying degrees, use the following make targets:
++
++    clean
++    distclean
++    relclean
++
++
++## Advanced installation
++
++Optionally, define make variables when invoking make, including (not
++exclusively):
++
++* `INCLUDEDIR="?"`
++
++    Use this as the installation prefix for header files.
++
++* `LIBDIR="?"`
++
++    Use this as the installation prefix for libraries.
++
++* `MANDIR="?"`
++
++    Use this as the installation prefix for man pages.
++
++* `DESTDIR="?"`
++
++    Prepend DESTDIR to INCLUDEDIR, LIBDIR, DATADIR, and MANDIR.  This is 
useful
++    when installing to a different path than was specified via --prefix.
++
++* `CC="?"`
++
++    Use this to invoke the C compiler.
++
++* `CFLAGS="?"`
++
++    Pass these flags to the compiler.
++
++* `CPPFLAGS="?"`
++
++    Pass these flags to the C preprocessor.
++
++* `LDFLAGS="?"`
++
++    Pass these flags when linking.
++
++* `PATH="?"`
++
++    Use this to search for programs used during configuration and building.
++
++
++## Development
++
++If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
++script rather than 'configure'.  This re-generates 'configure', enables
++configuration dependency rules, and enables re-generation of automatically
++generated source files.
++
++The build system supports using an object directory separate from the source
++tree.  For example, you can create an 'obj' directory, and from within that
++directory, issue configuration and build commands:
++
++    autoconf
++    mkdir obj
++    cd obj
++    ../configure --enable-autogen
++    make
++
++
++## Documentation
++
++The manual page is generated in both html and roff formats.  Any web browser
++can be used to view the html manual.  The roff manual page can be formatted
++prior to installation via the following command:
++
++    nroff -man -t doc/jemalloc.3
++||||||| dec341af7695
++=======
 +Building and installing a packaged release of jemalloc can be as simple as
 +typing the following while in the root directory of the source tree:
 +
 +    ./configure
 +    make
 +    make install
 +
 +If building from unpackaged developer sources, the simplest command sequence
 +that might work is:
 +
 +    ./autogen.sh
 +    make dist
 +    make
 +    make install
 +
*** 43131 LINES SKIPPED ***

Reply via email to