size_t is apparently not an unsigned long on 32 bit, which is what
rounddown_pow_of_two() returns.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
- Spin up a background thread to call the shrinkers every 1 second
- Memory allocations will only call reclaim after a failed allocation,
not every single time
This will be a major performance boost on allocation intensive
workloads.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
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.