git: DragonFly_RELEASE_4_6 libc - Fix malloc() alignment for small allocations
Matthew Dillon
dillon at crater.dragonflybsd.org
Sat Sep 3 10:32:06 PDT 2016
commit 322960dc2f43c50a9116ea9ecdca6e231e6e77f7
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Sat Sep 3 10:24:56 2016 -0700
libc - Fix malloc() alignment for small allocations
* malloc()'s slab allocator was set to use 8-byte alignment
for any allocation < 128 bytes that was not otherwise on
an integral alignment boundary. This breaks GCC-7 which assumes
16-byte alignment for non-16-integral sizes < 128 bytes. e.g.
if 18 bytes is allocated, GCC-7 assumes the resulting pointer will
be 16-byte-aligned.
* The standard is somewhat deficient in its characterization of what the
required alignment should be, because there are already instructions
which prefer 32 and 64 byte alignments, but are relaxed on Intel to
only require 16-byte alignments (aka %ymm and %zmm registers in the
vector extensions), and its stupid to enforce even larger alignments
for tiny allocations.
* But generally speaking it makes sense to enforce a 16-byte alignment
for any allocations >= 16 bytes, regardless of the size being passed-in
not being 16-byte aligned, and this change does that. Allocations of
less than 16 bytes will still be 8-byte aligned because it is phenominally
wasteful for them not to be.
Reported-by: marino
Summary of changes:
lib/libc/stdlib/nmalloc.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/322960dc2f43c50a9116ea9ecdca6e231e6e77f7
--
DragonFly BSD source repository
More information about the Commits
mailing list