Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 12efefb

Browse files
author
Jason Evans
committed
Fix dss/mmap allocation precedence code.
Fix dss/mmap allocation precedence code to use recyclable mmap memory only after primary dss allocation fails.
1 parent 2b592b0 commit 12efefb

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ found in the git revision history:
66
http://www.canonware.com/cgi-bin/gitweb.cgi?p=jemalloc.git
77
git://canonware.com/jemalloc.git
88

9+
* 3.x.x (XXX Not released)
10+
11+
Bug fixes:
12+
- Fix dss/mmap allocation precedence code to use recyclable mmap memory only
13+
after primary dss allocation fails.
14+
915
* 3.1.0 (October 16, 2012)
1016

1117
New features:

src/chunk.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -146,40 +146,28 @@ chunk_alloc(size_t size, size_t alignment, bool base, bool *zero,
146146
assert(alignment != 0);
147147
assert((alignment & chunksize_mask) == 0);
148148

149-
/*
150-
* Try to recycle an existing mapping.
151-
*/
152-
153149
/* "primary" dss. */
154-
if (config_dss && dss_prec == dss_prec_primary && (ret =
155-
chunk_recycle(&chunks_szad_dss, &chunks_ad_dss, size, alignment,
156-
base, zero)) != NULL)
157-
goto label_return;
150+
if (config_dss && dss_prec == dss_prec_primary) {
151+
if ((ret = chunk_recycle(&chunks_szad_dss, &chunks_ad_dss, size,
152+
alignment, base, zero)) != NULL)
153+
goto label_return;
154+
if ((ret = chunk_alloc_dss(size, alignment, zero)) != NULL)
155+
goto label_return;
156+
}
158157
/* mmap. */
159158
if ((ret = chunk_recycle(&chunks_szad_mmap, &chunks_ad_mmap, size,
160159
alignment, base, zero)) != NULL)
161160
goto label_return;
162-
/* "secondary" dss. */
163-
if (config_dss && dss_prec == dss_prec_secondary && (ret =
164-
chunk_recycle(&chunks_szad_dss, &chunks_ad_dss, size, alignment,
165-
base, zero)) != NULL)
166-
goto label_return;
167-
168-
/*
169-
* Try to allocate a new mapping.
170-
*/
171-
172-
/* "primary" dss. */
173-
if (config_dss && dss_prec == dss_prec_primary && (ret =
174-
chunk_alloc_dss(size, alignment, zero)) != NULL)
175-
goto label_return;
176-
/* mmap. */
177161
if ((ret = chunk_alloc_mmap(size, alignment, zero)) != NULL)
178162
goto label_return;
179163
/* "secondary" dss. */
180-
if (config_dss && dss_prec == dss_prec_secondary && (ret =
181-
chunk_alloc_dss(size, alignment, zero)) != NULL)
182-
goto label_return;
164+
if (config_dss && dss_prec == dss_prec_secondary) {
165+
if ((ret = chunk_recycle(&chunks_szad_dss, &chunks_ad_dss, size,
166+
alignment, base, zero)) != NULL)
167+
goto label_return;
168+
if ((ret = chunk_alloc_dss(size, alignment, zero)) != NULL)
169+
goto label_return;
170+
}
183171

184172
/* All strategies for allocation failed. */
185173
ret = NULL;

0 commit comments

Comments
 (0)