After memory allocation failure, don't rely on /proc/meminfo to figure
out how much memory we should free - instead unconditionally free 1/8th
of each cache.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
bcachefs assumes kmalloc & krealloc give out allocations that are
naturally aligned, like the kernel allocators do.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
posix_memalign doesn't have the restriction that size must be a multiply
of alignment.
This also reverts the fix in commit f3fdbbfa92.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
* Add missing linux/stddef.h includes
* Explicitly cast PAGE_SIZE to size_t. PAGE_SIZE is defined without UL
suffix in musl
* Musl doesn't define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, so
initialize the mutexes with pthread_once.