musl/src
Rich Felker c4694f4061 rewrite bump allocator to fix corner cases, decouple from expand_heap
this affects the bump allocator used when static linking in programs
that don't need allocation metadata due to not using realloc, free,
etc.

commit e3bc22f1ef refactored the bump
allocator to share code with __expand_heap, used by malloc, for the
purpose of fixing the case (mainly nommu) where brk doesn't work.
however, the geometric growth behavior of __expand_heap is not
actually well-suited to the bump allocator, and can produce
significant excessive memory usage. in particular, by repeatedly
requesting just over the remaining free space in the current
mmap-allocated area, the total mapped memory will be roughly double
the nominal usage. and since the main user of the no-brk mmap fallback
in the bump allocator is nommu, this excessive usage is not just
virtual address space but physical memory.

in addition, even on systems with brk, having a unified size request
to __expand_heap without knowing whether the brk or mmap backend would
get used made it so the brk could be expanded twice as far as needed.
for example, with malloc(n) and n-1 bytes available before the current
brk, the brk would be expanded by n bytes rounded up to page size,
when expansion by just one page would have sufficed.

the new implementation computes request size separately for the cases
where brk expansion is being attempted vs using mmap, and also
performs individual mmap of large allocations without moving to a new
bump area and throwing away the rest of the old one. this greatly
reduces the need for geometric area size growth and limits the extent
to which free space at the end of one bump area might be unusable for
future allocations.

as a bonus, the resulting code size is somewhat smaller than the
combined old version plus __expand_heap.
2020-06-03 18:13:18 -04:00
..
aio disable lfs64 aliases for remapped time64 functions 2019-10-28 19:26:52 -04:00
complex fix incorrect results for catanf and catanl with some inputs 2020-02-05 09:40:11 -05:00
conf fix build regression in sysconf for archs with variable page size 2018-09-14 16:25:56 -04:00
crypt reduce spurious inclusion of libc.h 2018-09-12 14:34:37 -04:00
ctype fix wcwidth wrongly returning 0 for most of planes 4 and up 2020-01-01 20:02:51 -05:00
dirent fail fdopendir for O_PATH file descriptors 2019-02-07 12:51:02 -05:00
env add secure_getenv function 2019-08-08 11:33:18 -04:00
errno improve strerror speed 2020-03-14 21:23:37 -04:00
exit split internal lock API out of libc.h, creating lock.h 2018-09-12 18:40:35 -04:00
fcntl remove spurious inclusion of libc.h for LFS64 ABI aliases 2018-09-12 14:34:38 -04:00
fenv fix sh fesetround failure to clear old mode 2020-04-18 03:23:40 -04:00
include refactor thrd_sleep and nanosleep in terms of clock_nanosleep 2019-07-27 02:46:57 -04:00
internal move malloc_impl.h from src/internal to src/malloc 2020-06-02 21:40:05 -04:00
ipc fix corrupt sysvipc timestamps on 32-bit archs with old kernels 2020-03-14 21:23:37 -04:00
ldso fix time64 link regression of dlsym stub for static-linked programs 2019-11-03 01:19:01 -05:00
legacy remove spurious inclusion of libc.h for LFS64 ABI aliases 2018-09-12 14:34:38 -04:00
linux reformat clock_adjtime with always-true condition removed 2020-06-02 20:21:48 -04:00
locale fix accidentlly-external cmp symbol introduced with catgets 2019-08-13 10:19:09 -04:00
malloc rewrite bump allocator to fix corner cases, decouple from expand_heap 2020-06-03 18:13:18 -04:00
math math: add x86_64 remquol 2020-03-24 16:31:36 -04:00
misc spare archs without time32 legacy the cost of ioctl fallback conversions 2019-12-22 13:25:58 -05:00
mman revert unwanted and inadvertent change that slipped into mmap.c 2019-12-20 21:27:39 -05:00
mq mq_timedsend, mq_timedreceive: add time64, decouple 32-bit time_t 2019-07-28 17:09:30 -04:00
multibyte fix aliasing-based undefined behavior in mbsrtowcs 2019-10-13 17:21:36 -04:00
network fix return value of res_send, res_query on errors from nameserver 2020-05-19 19:25:42 -04:00
passwd fix format strings for uid/gid values in putpwent/putgrent 2019-05-16 17:19:03 -04:00
prng split internal lock API out of libc.h, creating lock.h 2018-09-12 18:40:35 -04:00
process add posix_spawn [f]chdir file actions 2019-08-30 16:21:36 -04:00
regex fix failure of glob to match broken symlinks under some conditions 2019-08-07 02:38:45 -04:00
sched sched_rr_get_interval: don't assume time_t is 32-bit on 32-bit archs 2019-07-29 12:31:20 -04:00
search new tsearch implementation 2018-09-20 17:57:47 -04:00
select fix regression in select with no timeout 2019-08-07 02:57:53 -04:00
setjmp fix mips setjmp/longjmp fpu state on r6, related issues 2019-09-26 23:46:09 -04:00
signal arm: avoid conditional branch to PLT in sigsetjmp 2019-12-07 13:02:05 -05:00
stat fix remaining direct use of stat syscalls outside fstatat.c 2020-02-12 17:34:17 -05:00
stdio move __string_read into vsscanf source file 2020-04-17 16:18:07 -04:00
stdlib fix undefined behavior in wcsto[ld] family functions 2020-04-24 10:39:17 -04:00
string handle possibility that SIGEMT replaces SIGSTKFLT in strsignal 2020-05-21 16:25:12 -04:00
temp remove spurious inclusion of libc.h for LFS64 ABI aliases 2018-09-12 14:34:38 -04:00
termios reduce spurious inclusion of libc.h 2018-09-12 14:34:37 -04:00
thread restore lock-skipping for processes that return to single-threaded state 2020-05-22 17:45:47 -04:00
time fix parsing offsets after long timezone names 2020-03-21 12:47:09 -04:00
unistd use setitimer function rather than syscall to implement alarm 2019-08-05 21:16:30 -04:00