Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/jemalloc/files/, dev-libs/jemalloc/
Date: Tue, 30 Aug 2022 06:23:35
Message-Id: 1661840608.1a4fb1bc6d85251e6c99eb8b36e7709805b7720c.juippis@gentoo
1 commit: 1a4fb1bc6d85251e6c99eb8b36e7709805b7720c
2 Author: matoro <matoro <AT> users <DOT> noreply <DOT> github <DOT> com>
3 AuthorDate: Mon Aug 29 22:44:26 2022 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 30 06:23:28 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1a4fb1bc
7
8 dev-libs/jemalloc: revbump 5.3.0-r1, disable HPA feature on non-x86
9
10 Upstream explicitly clarified during discussion that the feature is not
11 supported, and not intended to run, on non-x86 platforms.
12
13 See: https://github.com/jemalloc/jemalloc/issues/2305
14 See: https://github.com/jemalloc/jemalloc/pull/2312
15 Closes: https://bugs.gentoo.org/856061
16 Closes: https://github.com/gentoo/gentoo/pull/27063
17 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
18
19 .../files/jemalloc-5.3.0-backport-pr-2312.patch | 160 +++++++++++++++++++++
20 dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild | 56 ++++++++
21 2 files changed, 216 insertions(+)
22
23 diff --git a/dev-libs/jemalloc/files/jemalloc-5.3.0-backport-pr-2312.patch b/dev-libs/jemalloc/files/jemalloc-5.3.0-backport-pr-2312.patch
24 new file mode 100644
25 index 000000000000..8867eeb3b2c1
26 --- /dev/null
27 +++ b/dev-libs/jemalloc/files/jemalloc-5.3.0-backport-pr-2312.patch
28 @@ -0,0 +1,160 @@
29 +This backports https://github.com/jemalloc/jemalloc/pull/2312, which
30 +I opened after discussion with upstream in
31 +https://github.com/jemalloc/jemalloc/issues/2305, where they explicitly
32 +clarify that the HPA feature is not tested, not supported, and not
33 +intended for use on non-x86 platforms.
34 +
35 +From: matoro <matoro@××××××××××××××××××××.com>
36 +Date: Wed, 27 Jul 2022 11:13:35 -0400
37 +Subject: [PATCH] Support HPA only on x86
38 +
39 +This can be overridden with -DHPA_SUPPORTED.
40 +
41 +Unfortunately has to be implemented using preprocessor macros, can't use
42 +test_skip_if because the test name string is already corrupted by that
43 +time. See https://github.com/jemalloc/jemalloc/issues/2305
44 +---
45 + include/jemalloc/internal/hpa.h | 27 +++++++++++++++++++++++++++
46 + src/hpa.c | 7 +------
47 + test/include/test/test.h | 9 +++++++++
48 + test/unit/psset.c | 14 ++++++++++++++
49 + 4 files changed, 51 insertions(+), 6 deletions(-)
50 +
51 +diff --git a/include/jemalloc/internal/hpa.h b/include/jemalloc/internal/hpa.h
52 +index f3562853e..3d389a644 100644
53 +--- a/include/jemalloc/internal/hpa.h
54 ++++ b/include/jemalloc/internal/hpa.h
55 +@@ -7,6 +7,33 @@
56 + #include "jemalloc/internal/pai.h"
57 + #include "jemalloc/internal/psset.h"
58 +
59 ++/*
60 ++ * The HPA_SUPPORTED macro is not a technical indicator of whether HPA
61 ++ * theoretically functions on the platform, but rather whether the platform is
62 ++ * tested/supported for using HPA on by the jemalloc developers.
63 ++ */
64 ++#ifdef HPA_SUPPORTED
65 ++#warning "Force-enabling HPA support. Do NOT report issues to jemalloc developers."
66 ++#else
67 ++#define HPA_SUPPORTED 1
68 ++
69 ++/*
70 ++ * At least until the API and implementation is somewhat settled, we
71 ++ * don't want to try to debug the VM subsystem on the hardest-to-test
72 ++ * platform.
73 ++ */
74 ++#ifdef _WIN32
75 ++#undef HPA_SUPPORTED
76 ++#endif
77 ++
78 ++/*
79 ++ * https://github.com/jemalloc/jemalloc/issues/2305#issuecomment-1195917164
80 ++ */
81 ++#if !defined(__x86_64__) && !defined(__i386__)
82 ++#undef HPA_SUPPORTED
83 ++#endif
84 ++#endif
85 ++
86 + typedef struct hpa_central_s hpa_central_t;
87 + struct hpa_central_s {
88 + /*
89 +diff --git a/src/hpa.c b/src/hpa.c
90 +index 7e2aeba0c..0a9946b9e 100644
91 +--- a/src/hpa.c
92 ++++ b/src/hpa.c
93 +@@ -25,12 +25,7 @@ static uint64_t hpa_time_until_deferred_work(tsdn_t *tsdn, pai_t *self);
94 +
95 + bool
96 + hpa_supported() {
97 +-#ifdef _WIN32
98 +- /*
99 +- * At least until the API and implementation is somewhat settled, we
100 +- * don't want to try to debug the VM subsystem on the hardest-to-test
101 +- * platform.
102 +- */
103 ++#ifndef HPA_SUPPORTED
104 + return false;
105 + #endif
106 + if (!pages_can_hugify) {
107 +diff --git a/test/include/test/test.h b/test/include/test/test.h
108 +index d4b65912d..7fa56f7be 100644
109 +--- a/test/include/test/test.h
110 ++++ b/test/include/test/test.h
111 +@@ -546,6 +546,15 @@ static void \
112 + f(void) { \
113 + p_test_init(#f);
114 +
115 ++#define TEST_SKIP(f) \
116 ++static void \
117 ++f(void) { \
118 ++ p_test_init(#f); \
119 ++ test_skip("%s:%s:%d: Test skipped: ", \
120 ++ __func__, __FILE__, __LINE__); \
121 ++ p_test_fini(); \
122 ++}
123 ++
124 + #define TEST_END \
125 + goto label_test_end; \
126 + label_test_end: \
127 +diff --git a/test/unit/psset.c b/test/unit/psset.c
128 +index 6ff720129..af764d3a3 100644
129 +--- a/test/unit/psset.c
130 ++++ b/test/unit/psset.c
131 +@@ -276,6 +276,7 @@ TEST_BEGIN(test_evict) {
132 + }
133 + TEST_END
134 +
135 ++#ifdef HPA_SUPPORTED
136 + TEST_BEGIN(test_multi_pageslab) {
137 + bool err;
138 + hpdata_t *ps;
139 +@@ -338,6 +339,9 @@ TEST_BEGIN(test_multi_pageslab) {
140 + expect_false(err, "Allocation should have succeeded");
141 + }
142 + TEST_END
143 ++#else
144 ++TEST_SKIP(test_multi_pageslab)
145 ++#endif
146 +
147 + static void
148 + stats_expect_empty(psset_bin_stats_t *stats) {
149 +@@ -427,6 +431,7 @@ TEST_END
150 + * (There's nothing magic about these numbers; it's just useful to share the
151 + * setup between the oldest fit and the insert/remove test).
152 + */
153 ++#ifdef HPA_SUPPORTED
154 + static void
155 + init_test_pageslabs(psset_t *psset, hpdata_t *pageslab,
156 + hpdata_t *worse_pageslab, edata_t *alloc, edata_t *worse_alloc) {
157 +@@ -472,7 +477,9 @@ init_test_pageslabs(psset_t *psset, hpdata_t *pageslab,
158 + &alloc[HUGEPAGE_PAGES - 1]);
159 + expect_ptr_null(evicted, "Unexpected eviction");
160 + }
161 ++#endif
162 +
163 ++#ifdef HPA_SUPPORTED
164 + TEST_BEGIN(test_oldest_fit) {
165 + bool err;
166 + edata_t alloc[HUGEPAGE_PAGES];
167 +@@ -495,7 +502,11 @@ TEST_BEGIN(test_oldest_fit) {
168 + "Allocated from the wrong pageslab");
169 + }
170 + TEST_END
171 ++#else
172 ++TEST_SKIP(test_oldest_fit)
173 ++#endif
174 +
175 ++#ifdef HPA_SUPPORTED
176 + TEST_BEGIN(test_insert_remove) {
177 + bool err;
178 + hpdata_t *ps;
179 +@@ -541,6 +552,9 @@ TEST_BEGIN(test_insert_remove) {
180 + expect_true(err, "psset should be empty, but an alloc succeeded");
181 + }
182 + TEST_END
183 ++#else
184 ++TEST_SKIP(test_insert_remove)
185 ++#endif
186 +
187 + TEST_BEGIN(test_purge_prefers_nonhuge) {
188 + /*
189
190 diff --git a/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild b/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild
191 new file mode 100644
192 index 000000000000..e8e5b62bd8d1
193 --- /dev/null
194 +++ b/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild
195 @@ -0,0 +1,56 @@
196 +# Copyright 1999-2022 Gentoo Authors
197 +# Distributed under the terms of the GNU General Public License v2
198 +
199 +EAPI="8"
200 +
201 +inherit autotools multilib-minimal
202 +
203 +DESCRIPTION="Jemalloc is a general-purpose scalable concurrent allocator"
204 +HOMEPAGE="http://jemalloc.net/ https://github.com/jemalloc/jemalloc"
205 +SRC_URI="https://github.com/jemalloc/jemalloc/releases/download/${PV}/${P}.tar.bz2"
206 +
207 +LICENSE="BSD"
208 +SLOT="0/2"
209 +#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
210 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
211 +IUSE="debug lazy-lock prof stats xmalloc"
212 +HTML_DOCS=( doc/jemalloc.html )
213 +PATCHES=(
214 + "${FILESDIR}/${PN}-5.3.0-gentoo-fixups.patch"
215 + "${FILESDIR}/${PN}-5.3.0-backport-pr-2312.patch"
216 +)
217 +
218 +MULTILIB_WRAPPED_HEADERS=( /usr/include/jemalloc/jemalloc.h )
219 +
220 +src_prepare() {
221 + default
222 + eautoreconf
223 +}
224 +
225 +multilib_src_configure() {
226 + local myconf=(
227 + $(use_enable debug)
228 + $(use_enable lazy-lock)
229 + $(use_enable prof)
230 + $(use_enable stats)
231 + $(use_enable xmalloc)
232 + )
233 +
234 + ECONF_SOURCE="${S}" econf "${myconf[@]}"
235 +}
236 +
237 +multilib_src_install() {
238 + # Copy man file which the Makefile looks for
239 + cp "${S}/doc/jemalloc.3" "${BUILD_DIR}/doc" || die
240 + emake DESTDIR="${D}" install
241 +}
242 +
243 +multilib_src_install_all() {
244 + if [[ ${CHOST} == *-darwin* ]] ; then
245 + # fixup install_name, #437362
246 + install_name_tool \
247 + -id "${EPREFIX}"/usr/$(get_libdir)/libjemalloc.2.dylib \
248 + "${ED}"/usr/$(get_libdir)/libjemalloc.2.dylib || die
249 + fi
250 + find "${ED}" -name '*.a' -delete || die
251 +}