New upstream release

- Removed the no-pprof patch, as jemalloc now comes with its own prof variant
- Removed atomic.h patch for armv5tel. jemalloc now provides a specific
  variant for armv5tel
- Added a patch from upstream for errnous bitshift by negative amounts on pagesize >8KiB
- Added -lrt to LDFLAGS for rhel<7
This commit is contained in:
Ingvar Hagelund 2015-08-28 12:42:08 +02:00
parent fbd0f28893
commit d1ac2aca2f
4 changed files with 223 additions and 9 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@
/jemalloc-3.4.0.tar.bz2
/jemalloc-3.5.1.tar.bz2
/jemalloc-3.6.0.tar.bz2
/jemalloc-4.0.0.tar.bz2

View File

@ -0,0 +1,200 @@
From 5ef33a9f2b9f4fb56553529f7b31f4f5f57ce014 Mon Sep 17 00:00:00 2001
From: Jason Evans <jasone@canonware.com>
Date: Wed, 19 Aug 2015 14:12:05 -0700
Subject: [PATCH] Don't bitshift by negative amounts.
Don't bitshift by negative amounts when encoding/decoding run sizes in
chunk header maps. This affected systems with page sizes greater than 8
KiB.
Reported by Ingvar Hagelund <ingvar@redpill-linpro.com>.
---
ChangeLog | 6 ++++
include/jemalloc/internal/arena.h | 48 ++++++++++++++++++++++-----
include/jemalloc/internal/private_symbols.txt | 2 ++
src/arena.c | 7 ++--
4 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0cf887c..c98179c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,12 @@ brevity. Much more detail can be found in the git revision history:
https://github.com/jemalloc/jemalloc
+* 4.x.x (XXX)
+
+ Bug fixes:
+ - Don't bitshift by negative amounts when encoding/decoding run sizes in chunk
+ header maps. This affected systems with page sizes greater than 8 KiB.
+
* 4.0.0 (August 17, 2015)
This version contains many speed and space optimizations, both minor and
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index cb015ee..2347213 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -519,6 +519,7 @@ arena_chunk_map_misc_t *arena_run_to_miscelm(arena_run_t *run);
size_t *arena_mapbitsp_get(arena_chunk_t *chunk, size_t pageind);
size_t arena_mapbitsp_read(size_t *mapbitsp);
size_t arena_mapbits_get(arena_chunk_t *chunk, size_t pageind);
+size_t arena_mapbits_size_decode(size_t mapbits);
size_t arena_mapbits_unallocated_size_get(arena_chunk_t *chunk,
size_t pageind);
size_t arena_mapbits_large_size_get(arena_chunk_t *chunk, size_t pageind);
@@ -530,6 +531,7 @@ size_t arena_mapbits_decommitted_get(arena_chunk_t *chunk, size_t pageind);
size_t arena_mapbits_large_get(arena_chunk_t *chunk, size_t pageind);
size_t arena_mapbits_allocated_get(arena_chunk_t *chunk, size_t pageind);
void arena_mapbitsp_write(size_t *mapbitsp, size_t mapbits);
+size_t arena_mapbits_size_encode(size_t size);
void arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind,
size_t size, size_t flags);
void arena_mapbits_unallocated_size_set(arena_chunk_t *chunk, size_t pageind,
@@ -653,13 +655,28 @@ arena_mapbits_get(arena_chunk_t *chunk, size_t pageind)
}
JEMALLOC_ALWAYS_INLINE size_t
+arena_mapbits_size_decode(size_t mapbits)
+{
+ size_t size;
+
+ if (CHUNK_MAP_SIZE_SHIFT > 0)
+ size = (mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT;
+ else if (CHUNK_MAP_SIZE_SHIFT == 0)
+ size = mapbits & CHUNK_MAP_SIZE_MASK;
+ else
+ size = (mapbits & CHUNK_MAP_SIZE_MASK) << -CHUNK_MAP_SIZE_SHIFT;
+
+ return (size);
+}
+
+JEMALLOC_ALWAYS_INLINE size_t
arena_mapbits_unallocated_size_get(arena_chunk_t *chunk, size_t pageind)
{
size_t mapbits;
mapbits = arena_mapbits_get(chunk, pageind);
assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == 0);
- return ((mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT);
+ return (arena_mapbits_size_decode(mapbits));
}
JEMALLOC_ALWAYS_INLINE size_t
@@ -670,7 +687,7 @@ arena_mapbits_large_size_get(arena_chunk_t *chunk, size_t pageind)
mapbits = arena_mapbits_get(chunk, pageind);
assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) ==
(CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED));
- return ((mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT);
+ return (arena_mapbits_size_decode(mapbits));
}
JEMALLOC_ALWAYS_INLINE size_t
@@ -754,6 +771,22 @@ arena_mapbitsp_write(size_t *mapbitsp, size_t mapbits)
*mapbitsp = mapbits;
}
+JEMALLOC_ALWAYS_INLINE size_t
+arena_mapbits_size_encode(size_t size)
+{
+ size_t mapbits;
+
+ if (CHUNK_MAP_SIZE_SHIFT > 0)
+ mapbits = size << CHUNK_MAP_SIZE_SHIFT;
+ else if (CHUNK_MAP_SIZE_SHIFT == 0)
+ mapbits = size;
+ else
+ mapbits = size >> -CHUNK_MAP_SIZE_SHIFT;
+
+ assert((mapbits & ~CHUNK_MAP_SIZE_MASK) == 0);
+ return (mapbits);
+}
+
JEMALLOC_ALWAYS_INLINE void
arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, size_t size,
size_t flags)
@@ -761,11 +794,10 @@ arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, size_t size,
size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind);
assert((size & PAGE_MASK) == 0);
- assert(((size << CHUNK_MAP_SIZE_SHIFT) & ~CHUNK_MAP_SIZE_MASK) == 0);
assert((flags & CHUNK_MAP_FLAGS_MASK) == flags);
assert((flags & CHUNK_MAP_DECOMMITTED) == 0 || (flags &
(CHUNK_MAP_DIRTY|CHUNK_MAP_UNZEROED)) == 0);
- arena_mapbitsp_write(mapbitsp, (size << CHUNK_MAP_SIZE_SHIFT) |
+ arena_mapbitsp_write(mapbitsp, arena_mapbits_size_encode(size) |
CHUNK_MAP_BININD_INVALID | flags);
}
@@ -777,10 +809,9 @@ arena_mapbits_unallocated_size_set(arena_chunk_t *chunk, size_t pageind,
size_t mapbits = arena_mapbitsp_read(mapbitsp);
assert((size & PAGE_MASK) == 0);
- assert(((size << CHUNK_MAP_SIZE_SHIFT) & ~CHUNK_MAP_SIZE_MASK) == 0);
assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == 0);
- arena_mapbitsp_write(mapbitsp, (size << CHUNK_MAP_SIZE_SHIFT) | (mapbits
- & ~CHUNK_MAP_SIZE_MASK));
+ arena_mapbitsp_write(mapbitsp, arena_mapbits_size_encode(size) |
+ (mapbits & ~CHUNK_MAP_SIZE_MASK));
}
JEMALLOC_ALWAYS_INLINE void
@@ -799,11 +830,10 @@ arena_mapbits_large_set(arena_chunk_t *chunk, size_t pageind, size_t size,
size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind);
assert((size & PAGE_MASK) == 0);
- assert(((size << CHUNK_MAP_SIZE_SHIFT) & ~CHUNK_MAP_SIZE_MASK) == 0);
assert((flags & CHUNK_MAP_FLAGS_MASK) == flags);
assert((flags & CHUNK_MAP_DECOMMITTED) == 0 || (flags &
(CHUNK_MAP_DIRTY|CHUNK_MAP_UNZEROED)) == 0);
- arena_mapbitsp_write(mapbitsp, (size << CHUNK_MAP_SIZE_SHIFT) |
+ arena_mapbitsp_write(mapbitsp, arena_mapbits_size_encode(size) |
CHUNK_MAP_BININD_INVALID | flags | CHUNK_MAP_LARGE |
CHUNK_MAP_ALLOCATED);
}
diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt
index dbf6aa7..ed1f6c2 100644
--- a/include/jemalloc/internal/private_symbols.txt
+++ b/include/jemalloc/internal/private_symbols.txt
@@ -50,6 +50,8 @@ arena_mapbits_large_size_get
arena_mapbitsp_get
arena_mapbitsp_read
arena_mapbitsp_write
+arena_mapbits_size_decode
+arena_mapbits_size_encode
arena_mapbits_small_runind_get
arena_mapbits_small_set
arena_mapbits_unallocated_set
diff --git a/src/arena.c b/src/arena.c
index af48b39..bd76e96 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -39,7 +39,7 @@ JEMALLOC_INLINE_C arena_chunk_map_misc_t *
arena_miscelm_key_create(size_t size)
{
- return ((arena_chunk_map_misc_t *)((size << CHUNK_MAP_SIZE_SHIFT) |
+ return ((arena_chunk_map_misc_t *)(arena_mapbits_size_encode(size) |
CHUNK_MAP_KEY));
}
@@ -58,8 +58,7 @@ arena_miscelm_key_size_get(const arena_chunk_map_misc_t *miscelm)
assert(arena_miscelm_is_key(miscelm));
- return (((uintptr_t)miscelm & CHUNK_MAP_SIZE_MASK) >>
- CHUNK_MAP_SIZE_SHIFT);
+ return (arena_mapbits_size_decode((uintptr_t)miscelm));
}
JEMALLOC_INLINE_C size_t
@@ -73,7 +72,7 @@ arena_miscelm_size_get(arena_chunk_map_misc_t *miscelm)
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(miscelm);
pageind = arena_miscelm_to_pageind(miscelm);
mapbits = arena_mapbits_get(chunk, pageind);
- return ((mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT);
+ return (arena_mapbits_size_decode(mapbits));
}
JEMALLOC_INLINE_C int

View File

@ -1,7 +1,7 @@
Name: jemalloc
Version: 3.6.0
Version: 4.0.0
Release: 9%{?dist}
Release: 1%{?dist}
Summary: General-purpose scalable concurrent malloc implementation
Group: System Environment/Libraries
@ -10,13 +10,12 @@ URL: http://www.canonware.com/jemalloc/
Source0: http://www.canonware.com/download/jemalloc/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# Remove pprof, as it already exists in google-perftools
Patch0: jemalloc-3.5.1.no_pprof.patch
# ARMv5tel has no atomic operations
Patch2: jemalloc-armv5-force-atomic.patch
# RHEL5/POWER has no atomic operations
Patch3: jemalloc-3.0.0.atomic_h_ppc_32bit_operations.patch
Patch4: jemalloc-3.6.0.no_explicit_altivec.patch
Patch6: jemalloc-4.0.0.negative_bitshift.patch
BuildRequires: /usr/bin/xsltproc
%ifnarch s390
BuildRequires: valgrind-devel
@ -37,15 +36,15 @@ developing applications that use %{name}.
%prep
%setup -q
%patch0
%patch2 -p1 -b .armv5tel
#% patch2 -p1 -b .armv5tel
%ifarch ppc ppc64
%if 0%{?rhel} == 5
%patch3 -b .ppc
%patch4 -b .ppc
%endif
%endif
%patch6 -p1
%build
%ifarch i686
@ -53,10 +52,13 @@ developing applications that use %{name}.
CFLAGS="%{optflags} -msse2"
%endif
%endif
%if 0%{?rhel} && 0%{?rhel} < 7
export LDFLAGS="%{?__global_ldflags} -lrt"
%endif
%configure
make %{?_smp_mflags}
%check
make check
@ -79,6 +81,9 @@ rm -rf %{buildroot}
%defattr(-,root,root,-)
%{_libdir}/libjemalloc.so.*
%{_bindir}/jemalloc.sh
%{_bindir}/jemalloc-config
%{_bindir}/jeprof
%{_libdir}/pkgconfig/jemalloc.pc
%doc COPYING README VERSION
%doc doc/jemalloc.html
%ifarch ppc ppc64
@ -98,6 +103,14 @@ rm -rf %{buildroot}
%postun -p /sbin/ldconfig
%changelog
* Wed Aug 19 2015 Ingvar Hagelund <ingvar@redpill-linpro.com> - 4.0.0-1
- New upstream release
- Removed the no-pprof patch, as jemalloc now comes with its own prof variant
- Removed atomic.h patch for armv5tel. jemalloc now provides a specific
variant for armv5tel
- Added a patch from upstream for errnous bitshift by negative amounts on pagesize >8KiB
- Added -lrt to LDFLAGS for rhel<7
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.6.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

View File

@ -1 +1 @@
e76665b63a8fddf4c9f26d2fa67afdf2 jemalloc-3.6.0.tar.bz2
87ceedfb5427676f4e059a42d939b0df jemalloc-4.0.0.tar.bz2