summaryrefslogtreecommitdiff
path: root/linux
AgeCommit message (Collapse)Author
2023-12-10bcachefs-tools: Fix typo in 872cd43Chris Webb
6% of physical RAM is info.totalram >> 4 not info.totalram << 4. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-09bcachefs-tools: Avoid glibc-specific mallinfo() in shrinkerChris Webb
Before 326d7c1, the shrinker used freeram and totalram from a struct sysinfo (constructed from /proc/meminfo) to target 25% free physical memory. As well as the slowness of repeatedly reading /proc/meminfo, this was a problem as freeram rises when the system starts to swap. We don't want swapping to reduce our estimate of memory pressure. To work around this, in 326d7c1 the shrinker started to use the total allocated heap from a glibc-specific interface mallinfo2(), aiming to shrink such that our heap is less than 80% of physical memory, unless overall free memory is less than 6% so that becomes the determining factor. Unfortunately, a sign error in the calculation means this heuristic never worked. It would shrink aggressively when the process was small, and not at all when the process grew beyond 80% of physical RAM. Only the fallback test ensuring the free physical RAM doesn't fall below 6% would actually kick in under memory pressure. It also breaks portability to anything other than recent glibc. Later, in 2440469 the mallinfo2() was replaced with the older mallinfo() to improve compatibility with older glibc. This is even more problematic: it's still not portable but also struct mallinfo has (signed) int fields which overflow for large processes on 32-bit machines with a 3G/1G split. Rather than trying to use libc-specific debug interfaces and our own heap to inform the shrinker, use the information about free and total swap we already have from sysinfo(2) to explicitly compensate for swapping in our estimate of free physical memory. Target free memory of 6% of physical RAM adjusted for zero swap use when calculating the pressure on the shrinker, based on the effective behaviour of 326d7c1 in practice given the sign error. As well as fixing portability to non-glibc systems, this loosens the assumption that we are the only process using significant memory when setting the shrinker target. It wouldn't be unreasonable to run two fsck jobs against independent devices on a large RAM machine and want to balance physical RAM between them. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-09bcachefs-tools: Use sysinfo(2) directly to implement si_meminfo()Chris Webb
Use a single sysinfo(2) call to fill out struct sysinfo instead of multiple libc sysconf(3) requests, which will only make sysinfo(2) calls internally anyway. This also enables us to access other struct sysinfo fields, not just the three filled-out previously. As we provide our own definition of struct sysinfo in include/linux/mm.h to match the kernel, which is not guaranteed to align with the definition libc provides in <sys/sysinfo.h>, use syscall(SYS_sysinfo, ...) directly instead of the libc wrapper. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-07fix build for glibc prior to 2.33Alexander Fougner
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
2023-12-05Disable shrinker thread shutdownKent Overstreet
We seem to be hitting a rare crash in the exit path of fsck - when shutting down the shrinker thread. Disable exiting the shrinker thread as a workaround. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-11-30Update bcachefs sources to 71a5b27e017d bcachefs: Make backpointer fsck wb ↵Kent Overstreet
flush check more rigorous Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-11-24improve kmalloc performanceDaniel Hill
Reading from /proc/meminfo is really slow We don't want to start swapping to disk. Deceptively, memory available goes up when we start to swap to disk making performance even worse. To mitigate this: 1. replace reading from meminfo with proper system calls. 2. attempt to lock allocations in physical memory space. 3. check our own allocated memory instead of available memory. 4. still check available memory in the off chance we're trying to play nice with other apps. Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-11-22Update bcachefs sources to 783085c3cc44 kbuild: Allow gcov to be enabled on ↵Kent Overstreet
the command line Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-11-02Update bcachefs sources to b9bd69421f73 bcachefs: x-macro-ify inode flags enumv1.3.1Kent Overstreet
2023-10-25Update bcachefs sources to 0d63ed13ea3d closures: Fix race in closure_sync()v1.3Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-09-29Handle -EAGAIN from io_submit()Kent Overstreet
If io_submit() returns -EAGAIN, that just means the io context is full and we need to wait for completions - no need to die. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-09-23Update bcachefs sources to f9c612bbf82d bcachefs: Fixes for building in ↵Kent Overstreet
userspace Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-09-01Fix one second delay when exitingTorge Matthies
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
2023-08-17Update bcachefs sources to a8115093df bcachefs: Fix divide by zero in ↵Kent Overstreet
rebalance_work()
2023-07-20Run shrinkers when pthread_create failsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-07-15Update bcachefs sources to e14d7c7195 bcachefs: Compression levelsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-06-27Update bcachefs sources to 84f132d569 bcachefs: fsck: Break walk_inode() up ↵Kent Overstreet
into multiple functions Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-06-18Update bcachefs sources to 99175e5712 bcachefs: Fix ↵Kent Overstreet
bch2_check_discard_freespace_key()
2023-06-10Update bcachefs sources to ed6b7f81a7 six locks: Disable percpu read lock ↵Kent Overstreet
mode in userspace Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-06-04Update bcachefs sources to 7c0fe6f104 bcachefs: Fix bch2_fsck_ask_yn()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-05-25Update bcachefs sources to 31c09369cd six locks: Fix an unitialized varKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-03-31Update bcachefs sources to 8fd009dd76 bcachefs: Rip out code for storing ↵v0.28Kent Overstreet
backpointers in alloc keys Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-03-14Update bcachefs sources to 72405e7ff8 bcachefs: Fix ↵Kent Overstreet
bch2_check_extents_to_backpointers()
2023-03-08linux shim: Fix dropped O_DIRECT flagKent Overstreet
A recent libbcachefs update accidentally committed a change that dropped the O_DIRECT flag - we definitely didn't want to do that. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-03-04Update bcachefs sources to 171da96d76 bcachefs: Drop some anonymous structs, ↵Kent Overstreet
unions
2023-02-27Update bcachefs sources to ca97ee3577 bcachefs: ↵Kent Overstreet
bch2_btree_iter_peek_and_restart_outlined() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-17Update bcachefs sources to 1b14994029 bcachefs: Fragmentation LRUv0.27Kent Overstreet
2023-02-09Update bcachefs sources to ea93c26e98 fixup! bcachefs: We can handle missing ↵Kent Overstreet
btree roots for all alloc btrees Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2022-12-19Change memory reclaimKent Overstreet
- 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>
2022-11-26Update bcachefs sources to 5963d1b1a4 bcacehfs: Fix ↵Kent Overstreet
bch2_get_alloc_in_memory_pos()
2022-11-19linux/blkdev.c: Fall back to buffered IO when O_DIRECT failsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2022-11-13Update bcachefs sources to 8d3fc97ca3 bcachefs: Fixes for building in userspaceKent Overstreet
2022-10-22Update bcachefs sources to cd779e0cc5 bcachefs: Skip inode unpack/pack in ↵v0.23Kent Overstreet
bch2_extent_update()
2022-10-15Update bcachefs sources to 3e93567c51 bcachefs: Switch to local_clock() for ↵Kent Overstreet
fastpath time source
2022-10-11Update bcachefs sources to 6dc2a699c6 bcachefs: bch2_path_put_nokeep()Kent Overstreet
2022-10-11Don't run shrinkers without GFP_KERNELKent Overstreet
This would correspond to GFP_RECLAIM in the kernel - but we don't distinguish between different types of reclaim here. This solves a deadlock in the btree node memory allocation path - we allocate with the btree node cache lock held but without GFP_KERNEL set. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2022-10-10Update bcachefs sources to 47ffed9fad bcachefs: ↵Kent Overstreet
bch2_btree_delete_range_trans() now uses peek_upto()
2022-10-09Update bcachefs sources to cbccc6d869 bcachefs: Ratelimit ec error messageKent Overstreet
2022-09-28Update bcachefs sources to 24c6361e20 bcachefs: Fix a trans path overflow in ↵Kent Overstreet
bch2_btree_delete_range_trans() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2022-09-04Update bcachefs sources to 176718966e bcachefs: Re-enable hash_redo_key()Kent Overstreet
2022-08-18Update bcachefs sources to dfaf9a6ee2 lib/printbuf: Clean up headersKent Overstreet
2022-08-11Update bcachefs sources to 90a9c61e2b bcachefs: Switch ↵Kent Overstreet
bch2_btree_delete_range() to bch2_trans_run()
2022-06-22Fix bdev_logical_block_size()Kent Overstreet
We were returning sectors instead of bytes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-06-22Fix printk_ratelimited()Kent Overstreet
printk_ratelimited was behind an #ifdef CONFIG_PRINTK, which we don't define, so it was a complete noop - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-06-18cmd_dump: Use buffered IO for reading device metadataKent Overstreet
We're reading device metadat in mostly sequential order - buffered IO will be faster than O_DIRECT. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-06-09Update bcachefs sources to 24f7e08cd8 bcachefs: shrinker.to_text() methodsKent Overstreet
2022-05-30Update bcachefs sources to fad6d13aa5 fixup! bcachefs: Add persistent countersKent Overstreet
2022-04-08Update bcachefs sources to 6ddf061e68 bcachefs: Use a genradix for reading ↵Kent Overstreet
journal entries
2022-03-28Heap code fixKent Overstreet
When deleting an entry from a heap that was at entry h->used - 1, we'd end up calling heap_sift() on an entry outside the heap - the entry we just removed - which would end up re-adding it to the heap and deleting something we didn't want to delete. Oops... Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-03-21Shrinker improvementsKent Overstreet
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>